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
15namespace flutter {
16
17class PlatformMessage : public fml::RefCountedThreadSafe<PlatformMessage> {
18 FML_FRIEND_REF_COUNTED_THREAD_SAFE(PlatformMessage);
19 FML_FRIEND_MAKE_REF_COUNTED(PlatformMessage);
20
21 public:
22 const std::string& channel() const { return channel_; }
23 const std::vector<uint8_t>& data() const { return data_; }
24 bool hasData() { return hasData_; }
25
26 const fml::RefPtr<PlatformMessageResponse>& response() const {
27 return response_;
28 }
29
30 private:
31 PlatformMessage(std::string channel,
32 std::vector<uint8_t> data,
33 fml::RefPtr<PlatformMessageResponse> response);
34 PlatformMessage(std::string channel,
35 fml::RefPtr<PlatformMessageResponse> response);
36 ~PlatformMessage();
37
38 std::string channel_;
39 std::vector<uint8_t> data_;
40 bool hasData_;
41 fml::RefPtr<PlatformMessageResponse> response_;
42};
43
44} // namespace flutter
45
46#endif // FLUTTER_LIB_UI_PLATFORM_PLATFORM_MESSAGE_H_
47