47 fml::RefPtr<flutter::PlatformMessageResponse> completer = message->response();
48 HandlerInfo handler_info;
53 std::lock_guard lock(message_handlers_mutex_);
54 auto it = message_handlers_.find(message->channel());
55 if (it != message_handlers_.end()) {
56 handler_info = it->second;
59 if (handler_info.handler) {
62 if (message->hasData()) {
67 TRACE_EVENT_ASYNC_BEGIN1(
"flutter",
"PlatformChannel ScheduleHandler", platform_message_id,
68 "channel", message->channel().c_str());
69 dispatch_block_t run_handler = ^{
70 handler(data, ^(NSData* reply) {
71 TRACE_EVENT_ASYNC_END0(
"flutter",
"PlatformChannel ScheduleHandler", platform_message_id);
77 completer->CompleteEmpty();
83 if (handler_info.task_queue) {
84 [handler_info.task_queue dispatch:run_handler];
86 dispatch_async(dispatch_get_main_queue(), run_handler);
90 completer->CompleteEmpty();
void(^ FlutterBinaryMessageHandler)(NSData *_Nullable message, FlutterBinaryReply reply)
std::unique_ptr< fml::Mapping > ConvertNSDataToMappingPtr(NSData *data)
NSData * ConvertMappingToNSData(fml::MallocMapping buffer)