| 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_LIB_UI_PLATFORM_PLATFORM_MESSAGE_H_ |
| 6 | #define FLUTTER_LIB_UI_PLATFORM_PLATFORM_MESSAGE_H_ |
| 7 | |
| 8 | #include <string> |
| 9 | #include <vector> |
| 10 | |
| 11 | #include "flutter/fml/memory/ref_counted.h" |
| 12 | #include "flutter/fml/memory/ref_ptr.h" |
| 13 | #include "flutter/lib/ui/window/platform_message_response.h" |
| 14 | |
| 15 | namespace flutter { |
| 16 | |
| 17 | class PlatformMessage { |
| 18 | public: |
| 19 | PlatformMessage(std::string channel, |
| 20 | fml::MallocMapping data, |
| 21 | fml::RefPtr<PlatformMessageResponse> response); |
| 22 | PlatformMessage(std::string channel, |
| 23 | fml::RefPtr<PlatformMessageResponse> response); |
| 24 | ~PlatformMessage(); |
| 25 | |
| 26 | const std::string& channel() const { return channel_; } |
| 27 | const fml::MallocMapping& data() const { return data_; } |
| 28 | bool hasData() { return hasData_; } |
| 29 | |
| 30 | const fml::RefPtr<PlatformMessageResponse>& response() const { |
| 31 | return response_; |
| 32 | } |
| 33 | |
| 34 | fml::MallocMapping releaseData() { return std::move(data_); } |
| 35 | |
| 36 | private: |
| 37 | std::string channel_; |
| 38 | fml::MallocMapping data_; |
| 39 | bool hasData_; |
| 40 | fml::RefPtr<PlatformMessageResponse> response_; |
| 41 | }; |
| 42 | |
| 43 | } // namespace flutter |
| 44 | |
| 45 | #endif // FLUTTER_LIB_UI_PLATFORM_PLATFORM_MESSAGE_H_ |
| 46 |
