Skip to content

Commit

Permalink
[Android] Rename allowChannelBufferOverflow to `setWarnsOnChannelOv… (
Browse files Browse the repository at this point in the history
#46361)

## Description

This PR is a follow-up to #44434 which introduces the `allowChannelBufferOverflow` function. It renames this function to `setWarnsOnChannelOverflow`.

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 1 test.
  • Loading branch information
bleroux committed Sep 28, 2023
1 parent 784a4ca commit 82b69da
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,11 @@ public void resizeChannelBuffer(int newSize) {

/**
* Toggles whether the channel should show warning messages when discarding messages due to
* overflow. When 'allowed' is true the channel is expected to overflow and warning messages will
* overflow. When 'warns' is false the channel is expected to overflow and warning messages will
* not be shown.
*/
public void allowChannelBufferOverflow(boolean allowed) {
allowChannelBufferOverflow(messenger, name, allowed);
public void setWarnsOnChannelOverflow(boolean warns) {
setWarnsOnChannelOverflow(messenger, name, warns);
}

private static ByteBuffer packetFromEncodedMessage(ByteBuffer message) {
Expand Down Expand Up @@ -182,13 +182,13 @@ public static void resizeChannelBuffer(

/**
* Toggles whether the channel should show warning messages when discarding messages due to
* overflow. When 'allowed' is true the channel is expected to overflow and warning messages will
* overflow. When 'warns' is false the channel is expected to overflow and warning messages will
* not be shown.
*/
public static void allowChannelBufferOverflow(
@NonNull BinaryMessenger messenger, @NonNull String channel, boolean allowed) {
public static void setWarnsOnChannelOverflow(
@NonNull BinaryMessenger messenger, @NonNull String channel, boolean warns) {
final StandardMethodCodec codec = StandardMethodCodec.INSTANCE;
Object[] arguments = {channel, allowed};
Object[] arguments = {channel, !warns};
MethodCall methodCall = new MethodCall("overflow", Arrays.asList(arguments));
ByteBuffer message = codec.encodeMethodCall(methodCall);
ByteBuffer packet = packetFromEncodedMessage(message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,11 @@ public void resizeChannelBuffer(int newSize) {

/**
* Toggles whether the channel should show warning messages when discarding messages due to
* overflow. When 'allowed' is true the channel is expected to overflow and warning messages will
* overflow. When 'warns' is false the channel is expected to overflow and warning messages will
* not be shown.
*/
public void allowChannelBufferOverflow(boolean allowed) {
BasicMessageChannel.allowChannelBufferOverflow(messenger, name, allowed);
public void setWarnsOnChannelOverflow(boolean warns) {
BasicMessageChannel.setWarnsOnChannelOverflow(messenger, name, warns);
}

/** A handler of incoming method calls. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void overflowChannelBufferMessageIsWellformed() {
String channel = "flutter/test";
MethodChannel rawChannel = new MethodChannel(dartExecutor, channel);

rawChannel.allowChannelBufferOverflow(true);
rawChannel.setWarnsOnChannelOverflow(false);

// Created from the following Dart code:
// MethodCall methodCall = const MethodCall('overflow', ['flutter/test', true]);
Expand Down

0 comments on commit 82b69da

Please sign in to comment.