Flutter iOS Embedder
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
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 
6 
8 
10 
11 namespace flutter {
12 
13 PlatformMessageResponseDarwin::PlatformMessageResponseDarwin(
15  fml::RefPtr<fml::TaskRunner> platform_task_runner)
16  : callback_(callback), platform_task_runner_(std::move(platform_task_runner)) {}
17 
18 PlatformMessageResponseDarwin::~PlatformMessageResponseDarwin() = default;
19 
20 void PlatformMessageResponseDarwin::Complete(std::unique_ptr<fml::Mapping> data) {
21  fml::RefPtr<PlatformMessageResponseDarwin> self(this);
22  platform_task_runner_->PostTask(fml::MakeCopyable([self, data = std::move(data)]() mutable {
23  self->callback_(CopyMappingPtrToNSData(std::move(data)));
24  }));
25 }
26 
27 void PlatformMessageResponseDarwin::CompleteEmpty() {
28  fml::RefPtr<PlatformMessageResponseDarwin> self(this);
29  platform_task_runner_->PostTask(fml::MakeCopyable([self]() mutable { self->callback_(nil); }));
30 }
31 
32 } // namespace flutter
NSData * CopyMappingPtrToNSData(std::unique_ptr< fml::Mapping > mapping)
void(^ PlatformMessageResponseCallback)(NSData *)