Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 39d87f2

Browse files
blerouxharryterkelsen
authored andcommitted
[Linux] Rename 'set_allow_channel_overflow' to 'set_warns_on_channel_… (#46360)
## Description This PR is a follow-up to #44636 which introduces the `set_allow_channel_overflow` function. It renames this function to `set_warns_on_channel_overflow`. The previous naming was inspired by the framework side implementation. https://github.com/flutter/engine/blob/93e8901490e78c7ba7e319cce4470d9c6478c6dc/lib/ui/channel_buffers.dart#L574 During the review of the iOS/macOS implementation, #44848 (comment), we agreed that the existing naming is confusing because it implies that overflow will be allowed, but this not the case this function is used to enable/disable error messages when a channel overflows. ## Related Issue Follow-up for flutter/flutter#132386. ## Tests Updates 2 tests.
1 parent 1c81dde commit 39d87f2

File tree

6 files changed

+43
-43
lines changed

6 files changed

+43
-43
lines changed

shell/platform/linux/fl_binary_messenger.cc

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -359,28 +359,28 @@ static void resize_channel(FlBinaryMessenger* messenger,
359359
nullptr);
360360
}
361361

362-
// Called when a response is received for the allow channel overflow message.
363-
static void set_allow_channel_overflowl_response_cb(GObject* object,
364-
GAsyncResult* result,
365-
gpointer user_data) {
362+
// Called when a response is received for the warns on overflow message.
363+
static void set_warns_on_channel_overflow_response_cb(GObject* object,
364+
GAsyncResult* result,
365+
gpointer user_data) {
366366
g_autoptr(GError) error = nullptr;
367367
if (!finish_method(object, result, &error)) {
368-
g_warning("Failed to set allow channel overflow: %s", error->message);
368+
g_warning("Failed to set warns on channel overflow: %s", error->message);
369369
}
370370
}
371371

372-
static void set_allow_channel_overflow(FlBinaryMessenger* messenger,
373-
const gchar* channel,
374-
bool allowed) {
372+
static void set_warns_on_channel_overflow(FlBinaryMessenger* messenger,
373+
const gchar* channel,
374+
bool warns) {
375375
g_autoptr(FlStandardMethodCodec) codec = fl_standard_method_codec_new();
376376
g_autoptr(FlValue) args = fl_value_new_list();
377377
fl_value_append_take(args, fl_value_new_string(channel));
378-
fl_value_append_take(args, fl_value_new_bool(allowed));
378+
fl_value_append_take(args, fl_value_new_bool(!warns));
379379
g_autoptr(GBytes) message = fl_method_codec_encode_method_call(
380380
FL_METHOD_CODEC(codec), kOverflowMethod, args, nullptr);
381381
fl_binary_messenger_send_on_channel(
382382
messenger, kControlChannelName, message, nullptr,
383-
set_allow_channel_overflowl_response_cb, nullptr);
383+
set_warns_on_channel_overflow_response_cb, nullptr);
384384
}
385385

386386
static void fl_binary_messenger_impl_class_init(
@@ -395,7 +395,7 @@ static void fl_binary_messenger_impl_iface_init(
395395
iface->send_on_channel = send_on_channel;
396396
iface->send_on_channel_finish = send_on_channel_finish;
397397
iface->resize_channel = resize_channel;
398-
iface->set_allow_channel_overflow = set_allow_channel_overflow;
398+
iface->set_warns_on_channel_overflow = set_warns_on_channel_overflow;
399399
}
400400

401401
static void fl_binary_messenger_impl_init(FlBinaryMessengerImpl* self) {
@@ -481,12 +481,12 @@ G_MODULE_EXPORT void fl_binary_messenger_resize_channel(FlBinaryMessenger* self,
481481
new_size);
482482
}
483483

484-
G_MODULE_EXPORT void fl_binary_messenger_set_allow_channel_overflow(
484+
G_MODULE_EXPORT void fl_binary_messenger_set_warns_on_channel_overflow(
485485
FlBinaryMessenger* self,
486486
const gchar* channel,
487-
bool allowed) {
487+
bool warns) {
488488
g_return_if_fail(FL_IS_BINARY_MESSENGER(self));
489489

490-
return FL_BINARY_MESSENGER_GET_IFACE(self)->set_allow_channel_overflow(
491-
self, channel, allowed);
490+
return FL_BINARY_MESSENGER_GET_IFACE(self)->set_warns_on_channel_overflow(
491+
self, channel, warns);
492492
}

shell/platform/linux/fl_binary_messenger_test.cc

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,9 @@ static void resize_channel(FlBinaryMessenger* messenger,
136136
// Fake implementation. Do nothing.
137137
}
138138

139-
static void set_allow_channel_overflow(FlBinaryMessenger* messenger,
140-
const gchar* channel,
141-
bool allowed) {
139+
static void set_warns_on_channel_overflow(FlBinaryMessenger* messenger,
140+
const gchar* channel,
141+
bool warns) {
142142
// Fake implementation. Do nothing.
143143
}
144144

@@ -149,7 +149,7 @@ static void fl_fake_binary_messenger_iface_init(
149149
iface->send_on_channel = send_on_channel;
150150
iface->send_on_channel_finish = send_on_channel_finish;
151151
iface->resize_channel = resize_channel;
152-
iface->set_allow_channel_overflow = set_allow_channel_overflow;
152+
iface->set_warns_on_channel_overflow = set_warns_on_channel_overflow;
153153
}
154154

155155
static void fl_fake_binary_messenger_init(FlFakeBinaryMessenger* self) {}
@@ -455,7 +455,7 @@ TEST(FlBinaryMessengerTest, ResizeChannel) {
455455
}
456456

457457
// Checks if the 'overflow' command is sent and is well-formed.
458-
TEST(FlBinaryMessengerTest, AllowOverflowChannel) {
458+
TEST(FlBinaryMessengerTest, WarnsOnOverflowChannel) {
459459
g_autoptr(FlEngine) engine = make_mock_engine();
460460
FlutterEngineProcTable* embedder_api = fl_engine_get_embedder_api(engine);
461461

@@ -495,8 +495,8 @@ TEST(FlBinaryMessengerTest, AllowOverflowChannel) {
495495
EXPECT_EQ(error, nullptr);
496496

497497
FlBinaryMessenger* messenger = fl_binary_messenger_new(engine);
498-
fl_binary_messenger_set_allow_channel_overflow(messenger, "flutter/test",
499-
true);
498+
fl_binary_messenger_set_warns_on_channel_overflow(messenger, "flutter/test",
499+
false);
500500

501501
EXPECT_TRUE(called);
502502
}
@@ -542,8 +542,8 @@ TEST(FlBinaryMessengerTest, ControlChannelErrorResponse) {
542542
return kInvalidArguments;
543543
}));
544544

545-
fl_binary_messenger_set_allow_channel_overflow(messenger, "flutter/test",
546-
true);
545+
fl_binary_messenger_set_warns_on_channel_overflow(messenger, "flutter/test",
546+
false);
547547

548548
EXPECT_TRUE(called);
549549

shell/platform/linux/fl_keyboard_manager_test.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,10 +222,10 @@ static void fl_mock_binary_messenger_resize_channel(
222222
// Mock implementation. Do nothing.
223223
}
224224

225-
static void fl_mock_binary_messenger_set_allow_channel_overflow(
225+
static void fl_mock_binary_messenger_set_warns_on_channel_overflow(
226226
FlBinaryMessenger* messenger,
227227
const gchar* channel,
228-
bool allowed) {
228+
bool warns) {
229229
// Mock implementation. Do nothing.
230230
}
231231

@@ -251,8 +251,8 @@ static void fl_mock_key_binary_messenger_iface_init(
251251
iface->send_on_channel_finish =
252252
fl_mock_key_binary_messenger_send_on_channel_finish;
253253
iface->resize_channel = fl_mock_binary_messenger_resize_channel;
254-
iface->set_allow_channel_overflow =
255-
fl_mock_binary_messenger_set_allow_channel_overflow;
254+
iface->set_warns_on_channel_overflow =
255+
fl_mock_binary_messenger_set_warns_on_channel_overflow;
256256
}
257257

258258
static void fl_mock_key_binary_messenger_init(FlMockKeyBinaryMessenger* self) {}

shell/platform/linux/public/flutter_linux/fl_binary_messenger.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,9 @@ struct _FlBinaryMessengerInterface {
9898
const gchar* channel,
9999
int64_t new_size);
100100

101-
void (*set_allow_channel_overflow)(FlBinaryMessenger* messenger,
102-
const gchar* channel,
103-
bool allowed);
101+
void (*set_warns_on_channel_overflow)(FlBinaryMessenger* messenger,
102+
const gchar* channel,
103+
bool warns);
104104
};
105105

106106
struct _FlBinaryMessengerResponseHandleClass {
@@ -210,19 +210,19 @@ void fl_binary_messenger_resize_channel(FlBinaryMessenger* messenger,
210210
int64_t new_size);
211211

212212
/**
213-
* fl_binary_messenger_set_allow_channel_overflow:
213+
* fl_binary_messenger_set_warns_on_channel_overflow:
214214
* @messenger: an #FlBinaryMessenger.
215215
* @channel: channel to be allowed to overflow silently.
216-
* @allowed: when true the channel is expected to overflow and warning messages
216+
* @warns: when false, the channel is expected to overflow and warning messages
217217
* will not be shown.
218218
*
219219
* Sends a message to the control channel asking to allow or disallow a channel
220220
* to overflow silently.
221221
*/
222-
void fl_binary_messenger_set_allow_channel_overflow(
222+
void fl_binary_messenger_set_warns_on_channel_overflow(
223223
FlBinaryMessenger* messenger,
224224
const gchar* channel,
225-
bool allowed);
225+
bool warns);
226226

227227
G_END_DECLS
228228

shell/platform/linux/testing/mock_binary_messenger.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,14 +131,14 @@ static void fl_mock_binary_messenger_resize_channel(
131131
self->mock->fl_binary_messenger_resize_channel(messenger, channel, new_size);
132132
}
133133

134-
static void fl_mock_binary_messenger_set_allow_channel_overflow(
134+
static void fl_mock_binary_messenger_set_warns_on_channel_overflow(
135135
FlBinaryMessenger* messenger,
136136
const gchar* channel,
137-
bool allowed) {
137+
bool warns) {
138138
g_return_if_fail(FL_IS_MOCK_BINARY_MESSENGER(messenger));
139139
FlMockBinaryMessenger* self = FL_MOCK_BINARY_MESSENGER(messenger);
140-
self->mock->fl_binary_messenger_set_allow_channel_overflow(messenger, channel,
141-
allowed);
140+
self->mock->fl_binary_messenger_set_warns_on_channel_overflow(messenger,
141+
channel, warns);
142142
}
143143

144144
static void fl_mock_binary_messenger_iface_init(
@@ -150,8 +150,8 @@ static void fl_mock_binary_messenger_iface_init(
150150
iface->send_on_channel_finish =
151151
fl_mock_binary_messenger_send_on_channel_finish;
152152
iface->resize_channel = fl_mock_binary_messenger_resize_channel;
153-
iface->set_allow_channel_overflow =
154-
fl_mock_binary_messenger_set_allow_channel_overflow;
153+
iface->set_warns_on_channel_overflow =
154+
fl_mock_binary_messenger_set_warns_on_channel_overflow;
155155
}
156156

157157
static void fl_mock_binary_messenger_init(FlMockBinaryMessenger* self) {}

shell/platform/linux/testing/mock_binary_messenger.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ class MockBinaryMessenger {
5959
int64_t new_size));
6060

6161
MOCK_METHOD(void,
62-
fl_binary_messenger_set_allow_channel_overflow,
62+
fl_binary_messenger_set_warns_on_channel_overflow,
6363
(FlBinaryMessenger * messenger,
6464
const gchar* channel,
65-
bool allowed));
65+
bool warns));
6666

6767
bool HasMessageHandler(const gchar* channel) const;
6868

0 commit comments

Comments
 (0)