Flutter Engine
platform_message_response_darwin.mm
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #import "flutter/shell/platform/darwin/ios/framework/Source/platform_message_response_darwin.h"
6 
7 namespace flutter {
8 
9 PlatformMessageResponseDarwin::PlatformMessageResponseDarwin(
11  fml::RefPtr<fml::TaskRunner> platform_task_runner)
12  : callback_(callback, fml::OwnershipPolicy::Retain),
13  platform_task_runner_(std::move(platform_task_runner)) {}
14 
15 PlatformMessageResponseDarwin::~PlatformMessageResponseDarwin() = default;
16 
17 void PlatformMessageResponseDarwin::Complete(std::unique_ptr<fml::Mapping> data) {
19  platform_task_runner_->PostTask(fml::MakeCopyable([self, data = std::move(data)]() mutable {
20  self->callback_.get()(GetNSDataFromMapping(std::move(data)));
21  }));
22 }
23 
26  platform_task_runner_->PostTask(
27  fml::MakeCopyable([self]() mutable { self->callback_.get()(nil); }));
28 }
29 
30 } // namespace flutter
void Complete(std::unique_ptr< fml::Mapping > data) override
Definition: ref_ptr.h:252
virtual void PostTask(const fml::closure &task)
Definition: task_runner.cc:24
void(^ PlatformMessageResponseCallback)(NSData *)
Definition: ascii_trie.cc:9
internal::CopyableLambda< T > MakeCopyable(T lambda)
Definition: make_copyable.h:57
OwnershipPolicy
Definition: scoped_block.h:17
NSData * GetNSDataFromMapping(std::unique_ptr< fml::Mapping > mapping)