| Flutter iOS Embedder |

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 #import "flutter/shell/platform/darwin/common/framework/Headers/FlutterMacros.h"
8
9 FLUTTER_ASSERT_ARC
10
11 namespace flutter {
12
13 PlatformMessageResponseDarwin::PlatformMessageResponseDarwin(
14 PlatformMessageResponseCallback callback,
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
FlutterMacros.h
FLUTTER_ASSERT_ARC
Definition: FlutterChannelKeyResponder.mm:13
flutter
Definition: accessibility_bridge.h:27
flutter::CopyMappingPtrToNSData
NSData * CopyMappingPtrToNSData(std::unique_ptr< fml::Mapping > mapping)
Definition: buffer_conversions.mm:43
platform_message_response_darwin.h
PlatformMessageResponseCallback
void(^ PlatformMessageResponseCallback)(NSData *)
Definition: platform_message_response_darwin.h:16