Skip to content

Commit 83d9b6f

Browse files
client_wrapper: merge common/client_wrapper (sony#361)
Merged the latest source files from flutter/engine repo. * src/flutter/shell/platform/common/client_wrapper/include/flutter/encodable_value.h => flutter/engine@a3c5a31 * src/flutter/shell/platform/common/client_wrapper/include/flutter/event_channel.h src/flutter/shell/platform/common/client_wrapper/include/flutter/event_stream_handler.h => flutter/engine@52574ef * src/flutter/shell/platform/common/client_wrapper/include/flutter/method_channel.h => flutter/engine@4165d4b * src/flutter/shell/platform/common/client_wrapper/include/flutter/plugin_registrar.h => flutter/engine@6d263ea * src/flutter/shell/platform/common/client_wrapper/standard_codec.cc => flutter/engine@71ee5f1 Signed-off-by: Hidenori Matsubayashi <[email protected]>
1 parent 589c117 commit 83d9b6f

File tree

6 files changed

+26
-15
lines changed

6 files changed

+26
-15
lines changed

src/flutter/shell/platform/common/client_wrapper/include/flutter/encodable_value.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,13 @@ class EncodableValue : public internal::EncodableValueVariant {
215215
}
216216
return std::get<int64_t>(*this);
217217
}
218+
219+
// Explicitly provide operator<, delegating to std::variant's operator<.
220+
// There are issues with with the way the standard library-provided
221+
// < and <=> comparisons interact with classes derived from variant.
222+
friend bool operator<(const EncodableValue& lhs, const EncodableValue& rhs) {
223+
return static_cast<const super&>(lhs) < static_cast<const super&>(rhs);
224+
}
218225
};
219226

220227
} // namespace flutter

src/flutter/shell/platform/common/client_wrapper/include/flutter/event_channel.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class EventChannel {
106106
if (error) {
107107
result = codec->EncodeErrorEnvelope(error->error_code,
108108
error->error_message,
109-
error->error_details);
109+
error->error_details.get());
110110
} else {
111111
result = codec->EncodeSuccessEnvelope();
112112
}
@@ -119,7 +119,7 @@ class EventChannel {
119119
if (error) {
120120
result = codec->EncodeErrorEnvelope(error->error_code,
121121
error->error_message,
122-
error->error_details);
122+
error->error_details.get());
123123
} else {
124124
result = codec->EncodeSuccessEnvelope();
125125
}

src/flutter/shell/platform/common/client_wrapper/include/flutter/event_stream_handler.h

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
#ifndef FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_EVENT_STREAM_HANDLER_H_
66
#define FLUTTER_SHELL_PLATFORM_COMMON_CLIENT_WRAPPER_INCLUDE_FLUTTER_EVENT_STREAM_HANDLER_H_
77

8+
#include <memory>
9+
#include <string>
10+
811
#include "event_sink.h"
912

1013
namespace flutter {
@@ -13,16 +16,16 @@ class EncodableValue;
1316

1417
template <typename T = EncodableValue>
1518
struct StreamHandlerError {
16-
const std::string& error_code;
17-
const std::string& error_message;
18-
const T* error_details;
19+
const std::string error_code;
20+
const std::string error_message;
21+
const std::unique_ptr<T> error_details;
1922

20-
StreamHandlerError(const std::string& error_code,
21-
const std::string& error_message,
22-
const T* error_details)
23+
StreamHandlerError(const std::string error_code,
24+
const std::string error_message,
25+
std::unique_ptr<T>&& error_details)
2326
: error_code(error_code),
2427
error_message(error_message),
25-
error_details(error_details) {}
28+
error_details(std::move(error_details)) {}
2629
};
2730

2831
// Handler for stream setup and teardown requests.

src/flutter/shell/platform/common/client_wrapper/include/flutter/method_channel.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,10 @@ class MethodChannel {
9191
// Registers a handler that should be called any time a method call is
9292
// received on this channel. A null handler will remove any previous handler.
9393
//
94-
// Note that the MethodChannel does not own the handler, and will not
95-
// unregister it on destruction, so the caller is responsible for
96-
// unregistering explicitly if it should no longer be called.
94+
// The handler will be owned by the underlying BinaryMessageHandler.
95+
// Destroying the MethodChannel will not unregister the handler, so
96+
// the caller is responsible for unregistering explicitly if the handler
97+
// stops being valid before the engine is destroyed.
9798
void SetMethodCallHandler(MethodCallHandler<T> handler) const {
9899
if (!handler) {
99100
messenger_->SetMessageHandler(name_, nullptr);

src/flutter/shell/platform/common/client_wrapper/include/flutter/plugin_registrar.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ class PluginRegistrar {
4949
// Takes ownership of |plugin|.
5050
//
5151
// Plugins are not required to call this method if they have other lifetime
52-
// management, but this is a convient place for plugins to be owned to ensure
53-
// that they stay valid for any registered callbacks.
52+
// management, but this is a convenient place for plugins to be owned to
53+
// ensure that they stay valid for any registered callbacks.
5454
void AddPlugin(std::unique_ptr<Plugin> plugin);
5555

5656
protected:

src/flutter/shell/platform/common/client_wrapper/standard_codec.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ EncodableValue StandardCodecSerializer::ReadValue(
9898
void StandardCodecSerializer::WriteValue(const EncodableValue& value,
9999
ByteStreamWriter* stream) const {
100100
stream->WriteByte(static_cast<uint8_t>(EncodedTypeForValue(value)));
101-
// TODO: Consider replacing this this with a std::visitor.
101+
// TODO(cbracken): Consider replacing this with std::visit.
102102
switch (value.index()) {
103103
case 0:
104104
case 1:

0 commit comments

Comments
 (0)