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_FRAMEWORK_SOURCE_PLATFORM_MESSAGE_RESPONSE_DARWIN_H_ 6 #define FLUTTER_SHELL_PLATFORM_DARWIN_IOS_FRAMEWORK_SOURCE_PLATFORM_MESSAGE_RESPONSE_DARWIN_H_ 7 8 #include <Foundation/Foundation.h> 9 10 #include "flutter/fml/macros.h" 11 #include "flutter/fml/make_copyable.h" 12 #include "flutter/fml/platform/darwin/scoped_block.h" 13 #include "flutter/fml/task_runner.h" 14 #include "flutter/lib/ui/window/platform_message_response.h" 15 #include "flutter/shell/platform/darwin/common/buffer_conversions.h" 16 17 typedef void (^PlatformMessageResponseCallback)(NSData*); 18 19 namespace flutter { 20 21 class PlatformMessageResponseDarwin : public flutter::PlatformMessageResponse { 22 public: 23 void Complete(std::unique_ptr<fml::Mapping> data) override; 24 25 void CompleteEmpty() override; 26 27 private: 28 explicit PlatformMessageResponseDarwin(PlatformMessageResponseCallback callback, 29 fml::RefPtr<fml::TaskRunner> platform_task_runner); 30 31 ~PlatformMessageResponseDarwin() override; 32 33 fml::ScopedBlock<PlatformMessageResponseCallback> callback_; 34 fml::RefPtr<fml::TaskRunner> platform_task_runner_; 35 36 FML_FRIEND_MAKE_REF_COUNTED(PlatformMessageResponseDarwin); 37 }; 38 39 } // namespace flutter 40 41 #endif // FLUTTER_SHELL_PLATFORM_DARWIN_IOS_FRAMEWORK_SOURCE_PLATFORM_MESSAGE_RESPONSE_DARWIN_H_ 42