mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Migrate PlatformMessageHandlerIos to ARC (flutter/engine#52226)
Smart pointers support ARC as of https://github.com/flutter/engine/pull/47612, and the unit tests were migrated in https://github.com/flutter/engine/pull/48162. Migrate `PlatformMessageHandlerIos` from MRC to ARC. Clean up the `#include`s. Part of https://github.com/flutter/flutter/issues/137801.
This commit is contained in:
parent
c4415fb8e0
commit
374dc4a4e3
@ -117,6 +117,8 @@ source_set("flutter_framework_source_arc") {
|
||||
"ios_surface_metal_skia.mm",
|
||||
"ios_surface_software.h",
|
||||
"ios_surface_software.mm",
|
||||
"platform_message_handler_ios.h",
|
||||
"platform_message_handler_ios.mm",
|
||||
"rendering_api_selection.h",
|
||||
"rendering_api_selection.mm",
|
||||
]
|
||||
@ -180,8 +182,6 @@ source_set("flutter_framework_source") {
|
||||
"framework/Source/accessibility_text_entry.mm",
|
||||
"ios_external_view_embedder.h",
|
||||
"ios_external_view_embedder.mm",
|
||||
"platform_message_handler_ios.h",
|
||||
"platform_message_handler_ios.mm",
|
||||
"platform_view_ios.h",
|
||||
"platform_view_ios.mm",
|
||||
]
|
||||
|
||||
@ -5,13 +5,10 @@
|
||||
#ifndef FLUTTER_SHELL_PLATFORM_DARWIN_IOS_PLATFORM_MESSAGE_HANDLER_IOS_H_
|
||||
#define FLUTTER_SHELL_PLATFORM_DARWIN_IOS_PLATFORM_MESSAGE_HANDLER_IOS_H_
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
#include "flutter/common/task_runners.h"
|
||||
#include "flutter/fml/platform/darwin/scoped_block.h"
|
||||
#include "flutter/fml/platform/darwin/scoped_nsobject.h"
|
||||
#include "flutter/fml/task_runner.h"
|
||||
#include "flutter/shell/common/platform_message_handler.h"
|
||||
#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterBinaryMessenger.h"
|
||||
#import "flutter/shell/platform/darwin/ios/flutter_task_queue_dispatch.h"
|
||||
|
||||
namespace flutter {
|
||||
|
||||
@ -4,15 +4,17 @@
|
||||
|
||||
#import "flutter/shell/platform/darwin/ios/platform_message_handler_ios.h"
|
||||
|
||||
#import "flutter/fml/trace_event.h"
|
||||
#import "flutter/lib/ui/window/platform_message.h"
|
||||
#import "flutter/shell/platform/darwin/common/buffer_conversions.h"
|
||||
#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterBinaryMessenger.h"
|
||||
#include "flutter/fml/trace_event.h"
|
||||
#include "flutter/lib/ui/window/platform_message.h"
|
||||
#include "flutter/lib/ui/window/platform_message_response.h"
|
||||
#include "flutter/shell/platform/darwin/common/buffer_conversions.h"
|
||||
|
||||
FLUTTER_ASSERT_ARC
|
||||
|
||||
static uint64_t platform_message_counter = 1;
|
||||
|
||||
@interface FLTSerialTaskQueue : NSObject <FlutterTaskQueueDispatch>
|
||||
@property(nonatomic, strong) dispatch_queue_t queue;
|
||||
@property(nonatomic, readonly) dispatch_queue_t queue;
|
||||
@end
|
||||
|
||||
@implementation FLTSerialTaskQueue
|
||||
@ -24,11 +26,6 @@ static uint64_t platform_message_counter = 1;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
dispatch_release(_queue);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void)dispatch:(dispatch_block_t)block {
|
||||
dispatch_async(self.queue, block);
|
||||
}
|
||||
@ -37,7 +34,7 @@ static uint64_t platform_message_counter = 1;
|
||||
namespace flutter {
|
||||
|
||||
NSObject<FlutterTaskQueue>* PlatformMessageHandlerIos::MakeBackgroundTaskQueue() {
|
||||
return [[[FLTSerialTaskQueue alloc] init] autorelease];
|
||||
return [[FLTSerialTaskQueue alloc] init];
|
||||
}
|
||||
|
||||
PlatformMessageHandlerIos::PlatformMessageHandlerIos(
|
||||
@ -127,8 +124,8 @@ void PlatformMessageHandlerIos::SetMessageHandler(const std::string& channel,
|
||||
message_handlers_.erase(channel);
|
||||
if (handler) {
|
||||
message_handlers_[channel] = {
|
||||
.task_queue = fml::scoped_nsprotocol(
|
||||
[static_cast<NSObject<FlutterTaskQueueDispatch>*>(task_queue) retain]),
|
||||
.task_queue =
|
||||
fml::scoped_nsprotocol(static_cast<NSObject<FlutterTaskQueueDispatch>*>(task_queue)),
|
||||
.handler =
|
||||
fml::ScopedBlock<FlutterBinaryMessageHandler>{
|
||||
handler, fml::scoped_policy::OwnershipPolicy::kRetain},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user