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_CPP_CLIENT_WRAPPER_INCLUDE_FLUTTER_STANDARD_MESSAGE_CODEC_H_ 6 #define FLUTTER_SHELL_PLATFORM_COMMON_CPP_CLIENT_WRAPPER_INCLUDE_FLUTTER_STANDARD_MESSAGE_CODEC_H_ 7 8 #include "encodable_value.h" 9 #include "message_codec.h" 10 11 namespace flutter { 12 13 // A binary message encoding/decoding mechanism for communications to/from the 14 // Flutter engine via message channels. 15 class StandardMessageCodec : public MessageCodec<EncodableValue> { 16 public: 17 // Returns the shared instance of the codec. 18 static const StandardMessageCodec& GetInstance(); 19 20 ~StandardMessageCodec(); 21 22 // Prevent copying. 23 StandardMessageCodec(StandardMessageCodec const&) = delete; 24 StandardMessageCodec& operator=(StandardMessageCodec const&) = delete; 25 26 protected: 27 // Instances should be obtained via GetInstance. 28 StandardMessageCodec(); 29 30 // |flutter::MessageCodec| 31 std::unique_ptr<EncodableValue> DecodeMessageInternal( 32 const uint8_t* binary_message, 33 const size_t message_size) const override; 34 35 // |flutter::MessageCodec| 36 std::unique_ptr<std::vector<uint8_t>> EncodeMessageInternal( 37 const EncodableValue& message) const override; 38 }; 39 40 } // namespace flutter 41 42 #endif // FLUTTER_SHELL_PLATFORM_COMMON_CPP_CLIENT_WRAPPER_INCLUDE_FLUTTER_STANDARD_MESSAGE_CODEC_H_ 43