| Flutter iOS Embedder |

platform_message_handler_ios.h
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 #ifndef FLUTTER_SHELL_PLATFORM_DARWIN_IOS_PLATFORM_MESSAGE_HANDLER_IOS_H_
6 #define FLUTTER_SHELL_PLATFORM_DARWIN_IOS_PLATFORM_MESSAGE_HANDLER_IOS_H_
7
8 #include "flutter/fml/task_runner.h"
9 #include "flutter/shell/common/platform_message_handler.h"
10 #import "flutter/shell/platform/darwin/ios/flutter_task_queue_dispatch.h"
11
12 namespace flutter {
13
14 class PlatformMessageHandlerIos : public PlatformMessageHandler {
15 public:
16 static NSObject<FlutterTaskQueue>* MakeBackgroundTaskQueue();
17
18 explicit PlatformMessageHandlerIos(fml::RefPtr<fml::TaskRunner> platform_task_runner);
19
20 void HandlePlatformMessage(std::unique_ptr<PlatformMessage> message) override;
21
22 bool DoesHandlePlatformMessageOnPlatformThread() const override;
23
24 void InvokePlatformMessageResponseCallback(int response_id,
25 std::unique_ptr<fml::Mapping> mapping) override;
26
27 void InvokePlatformMessageEmptyResponseCallback(int response_id) override;
28
29 void SetMessageHandler(const std::string& channel,
30 FlutterBinaryMessageHandler handler,
31 NSObject<FlutterTaskQueue>* task_queue);
32
33 struct HandlerInfo {
34 NSObject<FlutterTaskQueueDispatch>* task_queue;
35 FlutterBinaryMessageHandler handler;
36 };
37
38 private:
39 std::unordered_map<std::string, HandlerInfo> message_handlers_;
40 const fml::RefPtr<fml::TaskRunner> platform_task_runner_;
41 std::mutex message_handlers_mutex_;
42 FML_DISALLOW_COPY_AND_ASSIGN(PlatformMessageHandlerIos);
43 };
44
45 } // namespace flutter
46
47 #endif // FLUTTER_SHELL_PLATFORM_DARWIN_IOS_PLATFORM_MESSAGE_HANDLER_IOS_H_
flutter::PlatformMessageHandlerIos::InvokePlatformMessageResponseCallback
void InvokePlatformMessageResponseCallback(int response_id, std::unique_ptr< fml::Mapping > mapping) override
Definition: platform_message_handler_ios.mm:100
flutter::PlatformMessageHandlerIos
Definition: platform_message_handler_ios.h:14
flutter::PlatformMessageHandlerIos::MakeBackgroundTaskQueue
static NSObject< FlutterTaskQueue > * MakeBackgroundTaskQueue()
Definition: platform_message_handler_ios.mm:36
flutter::PlatformMessageHandlerIos::DoesHandlePlatformMessageOnPlatformThread
bool DoesHandlePlatformMessageOnPlatformThread() const override
Definition: platform_message_handler_ios.mm:96
flutter_task_queue_dispatch.h
flutter::PlatformMessageHandlerIos::HandlerInfo
Definition: platform_message_handler_ios.h:33
flutter::PlatformMessageHandlerIos::HandlePlatformMessage
void HandlePlatformMessage(std::unique_ptr< PlatformMessage > message) override
Definition: platform_message_handler_ios.mm:44
flutter::PlatformMessageHandlerIos::InvokePlatformMessageEmptyResponseCallback
void InvokePlatformMessageEmptyResponseCallback(int response_id) override
Definition: platform_message_handler_ios.mm:108
flutter::PlatformMessageHandlerIos::HandlerInfo::task_queue
NSObject< FlutterTaskQueueDispatch > * task_queue
Definition: platform_message_handler_ios.h:34
FlutterBinaryMessageHandler
void(^ FlutterBinaryMessageHandler)(NSData *_Nullable message, FlutterBinaryReply reply)
Definition: FlutterBinaryMessenger.h:30
flutter::PlatformMessageHandlerIos::HandlerInfo::handler
FlutterBinaryMessageHandler handler
Definition: platform_message_handler_ios.h:35
flutter
Definition: accessibility_bridge.h:27
flutter::PlatformMessageHandlerIos::SetMessageHandler
void SetMessageHandler(const std::string &channel, FlutterBinaryMessageHandler handler, NSObject< FlutterTaskQueue > *task_queue)
Definition: platform_message_handler_ios.mm:114
flutter::PlatformMessageHandlerIos::PlatformMessageHandlerIos
PlatformMessageHandlerIos(fml::RefPtr< fml::TaskRunner > platform_task_runner)
Definition: platform_message_handler_ios.mm:40