Skip to content

Commit ea9783c

Browse files
authored
[engine] Sync Flutter 3.10 source code (#36)
1 parent 9b11d80 commit ea9783c

File tree

5 files changed

+206
-40
lines changed

5 files changed

+206
-40
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class EventChannel {
9292
std::cerr << "Failed to cancel existing stream: "
9393
<< (error->error_code) << ", "
9494
<< (error->error_message) << ", "
95-
<< (error->error_details);
95+
<< (error->error_details.get());
9696
}
9797
}
9898
is_listening = true;
@@ -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
}

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.

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);

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(cbracken): Consider replacing this this with std::visit.
101+
// TODO(cbracken): Consider replacing this with std::visit.
102102
switch (value.index()) {
103103
case 0:
104104
case 1:

0 commit comments

Comments
 (0)