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

Commit 2d73fa2

Browse files
authored
Migrate PlatformMessageHandlerIos to ARC (#52226)
Smart pointers support ARC as of #47612, and the unit tests were migrated in #48162. Migrate `PlatformMessageHandlerIos` from MRC to ARC. Clean up the `#include`s. Part of flutter/flutter#137801.
1 parent cfa3f34 commit 2d73fa2

File tree

3 files changed

+13
-19
lines changed

3 files changed

+13
-19
lines changed

shell/platform/darwin/ios/BUILD.gn

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ source_set("flutter_framework_source_arc") {
117117
"ios_surface_metal_skia.mm",
118118
"ios_surface_software.h",
119119
"ios_surface_software.mm",
120+
"platform_message_handler_ios.h",
121+
"platform_message_handler_ios.mm",
120122
"rendering_api_selection.h",
121123
"rendering_api_selection.mm",
122124
]
@@ -180,8 +182,6 @@ source_set("flutter_framework_source") {
180182
"framework/Source/accessibility_text_entry.mm",
181183
"ios_external_view_embedder.h",
182184
"ios_external_view_embedder.mm",
183-
"platform_message_handler_ios.h",
184-
"platform_message_handler_ios.mm",
185185
"platform_view_ios.h",
186186
"platform_view_ios.mm",
187187
]

shell/platform/darwin/ios/platform_message_handler_ios.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,10 @@
55
#ifndef FLUTTER_SHELL_PLATFORM_DARWIN_IOS_PLATFORM_MESSAGE_HANDLER_IOS_H_
66
#define FLUTTER_SHELL_PLATFORM_DARWIN_IOS_PLATFORM_MESSAGE_HANDLER_IOS_H_
77

8-
#include <unordered_map>
9-
10-
#include "flutter/common/task_runners.h"
118
#include "flutter/fml/platform/darwin/scoped_block.h"
129
#include "flutter/fml/platform/darwin/scoped_nsobject.h"
10+
#include "flutter/fml/task_runner.h"
1311
#include "flutter/shell/common/platform_message_handler.h"
14-
#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterBinaryMessenger.h"
1512
#import "flutter/shell/platform/darwin/ios/flutter_task_queue_dispatch.h"
1613

1714
namespace flutter {

shell/platform/darwin/ios/platform_message_handler_ios.mm

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,17 @@
44

55
#import "flutter/shell/platform/darwin/ios/platform_message_handler_ios.h"
66

7-
#import "flutter/fml/trace_event.h"
8-
#import "flutter/lib/ui/window/platform_message.h"
9-
#import "flutter/shell/platform/darwin/common/buffer_conversions.h"
10-
#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterBinaryMessenger.h"
7+
#include "flutter/fml/trace_event.h"
8+
#include "flutter/lib/ui/window/platform_message.h"
9+
#include "flutter/lib/ui/window/platform_message_response.h"
10+
#include "flutter/shell/platform/darwin/common/buffer_conversions.h"
11+
12+
FLUTTER_ASSERT_ARC
1113

1214
static uint64_t platform_message_counter = 1;
1315

1416
@interface FLTSerialTaskQueue : NSObject <FlutterTaskQueueDispatch>
15-
@property(nonatomic, strong) dispatch_queue_t queue;
17+
@property(nonatomic, readonly) dispatch_queue_t queue;
1618
@end
1719

1820
@implementation FLTSerialTaskQueue
@@ -24,11 +26,6 @@ - (instancetype)init {
2426
return self;
2527
}
2628

27-
- (void)dealloc {
28-
dispatch_release(_queue);
29-
[super dealloc];
30-
}
31-
3229
- (void)dispatch:(dispatch_block_t)block {
3330
dispatch_async(self.queue, block);
3431
}
@@ -37,7 +34,7 @@ - (void)dispatch:(dispatch_block_t)block {
3734
namespace flutter {
3835

3936
NSObject<FlutterTaskQueue>* PlatformMessageHandlerIos::MakeBackgroundTaskQueue() {
40-
return [[[FLTSerialTaskQueue alloc] init] autorelease];
37+
return [[FLTSerialTaskQueue alloc] init];
4138
}
4239

4340
PlatformMessageHandlerIos::PlatformMessageHandlerIos(
@@ -127,8 +124,8 @@ - (void)dispatch:(dispatch_block_t)block {
127124
message_handlers_.erase(channel);
128125
if (handler) {
129126
message_handlers_[channel] = {
130-
.task_queue = fml::scoped_nsprotocol(
131-
[static_cast<NSObject<FlutterTaskQueueDispatch>*>(task_queue) retain]),
127+
.task_queue =
128+
fml::scoped_nsprotocol(static_cast<NSObject<FlutterTaskQueueDispatch>*>(task_queue)),
132129
.handler =
133130
fml::ScopedBlock<FlutterBinaryMessageHandler>{
134131
handler, fml::scoped_policy::OwnershipPolicy::kRetain},

0 commit comments

Comments
 (0)