Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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"
13
14namespace flutter {
15
16// A binary message encoding/decoding mechanism for communications to/from the
17// Flutter engine via message channels.
18class 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.
30 const StandardCodecSerializer* serializer = nullptr);
31
33
34 // Prevent copying.
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_
static const StandardMessageCodec & GetInstance(const StandardCodecSerializer *serializer=nullptr)
StandardMessageCodec & operator=(StandardMessageCodec const &)=delete
std::unique_ptr< EncodableValue > DecodeMessageInternal(const uint8_t *binary_message, const size_t message_size) const override
StandardMessageCodec(StandardMessageCodec const &)=delete
std::unique_ptr< std::vector< uint8_t > > EncodeMessageInternal(const EncodableValue &message) const override
Win32Message message