Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
json_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_JSON_MESSAGE_CODEC_H_
6#define FLUTTER_SHELL_PLATFORM_COMMON_JSON_MESSAGE_CODEC_H_
7
8#include <rapidjson/document.h>
9
10#include "flutter/shell/platform/common/client_wrapper/include/flutter/message_codec.h"
11
12namespace flutter {
13
14// A message encoding/decoding mechanism for communications to/from the
15// Flutter engine via JSON channels.
16class JsonMessageCodec : public MessageCodec<rapidjson::Document> {
17 public:
18 // Returns the shared instance of the codec.
19 static const JsonMessageCodec& GetInstance();
20
21 ~JsonMessageCodec() = default;
22
23 // Prevent copying.
26
27 protected:
28 // Instances should be obtained via GetInstance.
29 JsonMessageCodec() = default;
30
31 // |flutter::MessageCodec|
32 std::unique_ptr<rapidjson::Document> DecodeMessageInternal(
33 const uint8_t* binary_message,
34 const size_t message_size) const override;
35
36 // |flutter::MessageCodec|
37 std::unique_ptr<std::vector<uint8_t>> EncodeMessageInternal(
38 const rapidjson::Document& message) const override;
39};
40
41} // namespace flutter
42
43#endif // FLUTTER_SHELL_PLATFORM_COMMON_JSON_MESSAGE_CODEC_H_
static const JsonMessageCodec & GetInstance()
std::unique_ptr< rapidjson::Document > DecodeMessageInternal(const uint8_t *binary_message, const size_t message_size) const override
JsonMessageCodec(JsonMessageCodec const &)=delete
JsonMessageCodec & operator=(JsonMessageCodec const &)=delete
std::unique_ptr< std::vector< uint8_t > > EncodeMessageInternal(const rapidjson::Document &message) const override
Win32Message message