| Flutter macOS Embedder |

standard_message_codec.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_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_STANDARD_MESSAGE_CODEC_H_
6 #define FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_STANDARD_MESSAGE_CODEC_H_
7
8 #include <memory>
9
10 #include "encodable_value.h"
11 #include "message_codec.h"
12 #include "standard_codec_serializer.h"
13
14 namespace flutter {
15
16 // A binary message encoding/decoding mechanism for communications to/from the
17 // Flutter engine via message channels.
18 class StandardMessageCodec : public MessageCodec<EncodableValue> {
19 public:
20 // Returns an instance of the codec, optionally using a custom serializer to
21 // add support for more types.
22 //
23 // If provided, |serializer| must be long-lived. If no serializer is provided,
24 // the default will be used.
25 //
26 // The instance returned for a given |serializer| will be shared, and
27 // any instance returned from this will be long-lived, and can be safely
28 // passed to, e.g., channel constructors.
29 static const StandardMessageCodec& GetInstance(
30 const StandardCodecSerializer* serializer = nullptr);
31
32 ~StandardMessageCodec();
33
34 // Prevent copying.
35 StandardMessageCodec(StandardMessageCodec const&) = delete;
36 StandardMessageCodec& operator=(StandardMessageCodec const&) = delete;
37
38 protected:
39 // |flutter::MessageCodec|
40 std::unique_ptr<EncodableValue> DecodeMessageInternal(
41 const uint8_t* binary_message,
42 const size_t message_size) const override;
43
44 // |flutter::MessageCodec|
45 std::unique_ptr<std::vector<uint8_t>> EncodeMessageInternal(
46 const EncodableValue& message) const override;
47
48 private:
49 // Instances should be obtained via GetInstance.
50 explicit StandardMessageCodec(const StandardCodecSerializer* serializer);
51
52 const StandardCodecSerializer* serializer_;
53 };
54
55 } // namespace flutter
56
57 #endif // FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_STANDARD_MESSAGE_CODEC_H_
flutter::EncodableValue
Definition: encodable_value.h:165
flutter::MessageCodec
Definition: message_codec.h:17
flutter::StandardCodecSerializer
Definition: standard_codec_serializer.h:18
flutter::StandardMessageCodec
Definition: standard_message_codec.h:18
flutter::StandardMessageCodec::~StandardMessageCodec
~StandardMessageCodec()
flutter::StandardMessageCodec::GetInstance
static const StandardMessageCodec & GetInstance(const StandardCodecSerializer *serializer=nullptr)
Definition: standard_codec.cc:293
flutter::StandardMessageCodec::operator=
StandardMessageCodec & operator=(StandardMessageCodec const &)=delete
flutter::StandardMessageCodec::DecodeMessageInternal
std::unique_ptr< EncodableValue > DecodeMessageInternal(const uint8_t *binary_message, const size_t message_size) const override
Definition: standard_codec.cc:318
flutter::StandardMessageCodec::StandardMessageCodec
StandardMessageCodec(StandardMessageCodec const &)=delete
flutter::StandardMessageCodec::EncodeMessageInternal
std::unique_ptr< std::vector< uint8_t > > EncodeMessageInternal(const EncodableValue &message) const override
Definition: standard_codec.cc:329
encodable_value.h
message_codec.h
flutter
Definition: AccessibilityBridgeMac.h:16
standard_codec_serializer.h