forked from flutter-tizen/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove engine dependency of LifecycleChannel (flutter-tizen#127)
* Remove engine dependency of LifecycleChannel * Implement StringSerializer * Remove StringSerializer and implement StringCodec
- Loading branch information
Showing
6 changed files
with
82 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// Copyright 2021 Samsung Electronics Co., Ltd. All rights reserved. | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef EMBEDDER_STRING_CODEC_H_ | ||
#define EMBEDDER_STRING_CODEC_H_ | ||
|
||
#include <memory> | ||
#include <string> | ||
#include <variant> | ||
|
||
#include "flutter/shell/platform/common/client_wrapper/include/flutter/encodable_value.h" | ||
#include "flutter/shell/platform/common/client_wrapper/include/flutter/message_codec.h" | ||
|
||
namespace flutter { | ||
|
||
// A string message encoding/decoding mechanism for communications to/from the | ||
// Flutter engine via message channels. | ||
class StringCodec : public MessageCodec<EncodableValue> { | ||
public: | ||
~StringCodec() = default; | ||
|
||
// Returns an instance of the codec. | ||
static const StringCodec& GetInstance() { | ||
static StringCodec sInstance; | ||
return sInstance; | ||
} | ||
|
||
// Prevent copying. | ||
StringCodec(StringCodec const&) = delete; | ||
StringCodec& operator=(StringCodec const&) = delete; | ||
|
||
protected: | ||
// |flutter::MessageCodec| | ||
std::unique_ptr<EncodableValue> DecodeMessageInternal( | ||
const uint8_t* binary_message, | ||
const size_t message_size) const override { | ||
return std::make_unique<EncodableValue>(std::string( | ||
reinterpret_cast<const char*>(binary_message), message_size)); | ||
} | ||
|
||
// |flutter::MessageCodec| | ||
std::unique_ptr<std::vector<uint8_t>> EncodeMessageInternal( | ||
const EncodableValue& message) const override { | ||
auto string_value = std::get<std::string>(message); | ||
return std::make_unique<std::vector<uint8_t>>(string_value.begin(), | ||
string_value.end()); | ||
} | ||
|
||
private: | ||
// Instances should be obtained via GetInstance. | ||
explicit StringCodec() = default; | ||
}; | ||
|
||
} // namespace flutter | ||
|
||
#endif // EMBEDDER_STRING_CODEC_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters