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

Commit d132ada

Browse files
authored
iOS: Eliminate ScopedBlock, ScopedTypeRef, ScopedPolicy (#56410)
Eliminates the two remaining uses of ScopedBlock and with it, ScopedTypeRef which was only used by ScopedBlock. ARC automatically generates the necessary block copy/retain/release calls, including moving blocks to the heap during a retain so manual _Block_copy/_Block_release calls are no longer required. No test changes since no semantic changes. Issue: flutter/flutter#137801 [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
1 parent a2ada9a commit d132ada

File tree

9 files changed

+6
-224
lines changed

9 files changed

+6
-224
lines changed

ci/licenses_golden/licenses_flutter

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42729,12 +42729,9 @@ ORIGIN: ../../../flutter/fml/platform/darwin/message_loop_darwin.mm + ../../../f
4272942729
ORIGIN: ../../../flutter/fml/platform/darwin/paths_darwin.mm + ../../../flutter/LICENSE
4273042730
ORIGIN: ../../../flutter/fml/platform/darwin/platform_version.h + ../../../flutter/LICENSE
4273142731
ORIGIN: ../../../flutter/fml/platform/darwin/platform_version.mm + ../../../flutter/LICENSE
42732-
ORIGIN: ../../../flutter/fml/platform/darwin/scoped_block.h + ../../../flutter/LICENSE
42733-
ORIGIN: ../../../flutter/fml/platform/darwin/scoped_block.mm + ../../../flutter/LICENSE
4273442732
ORIGIN: ../../../flutter/fml/platform/darwin/scoped_nsautorelease_pool.cc + ../../../flutter/LICENSE
4273542733
ORIGIN: ../../../flutter/fml/platform/darwin/scoped_nsautorelease_pool.h + ../../../flutter/LICENSE
4273642734
ORIGIN: ../../../flutter/fml/platform/darwin/scoped_policy.h + ../../../flutter/LICENSE
42737-
ORIGIN: ../../../flutter/fml/platform/darwin/scoped_typeref.h + ../../../flutter/LICENSE
4273842735
ORIGIN: ../../../flutter/fml/platform/darwin/string_range_sanitization.h + ../../../flutter/LICENSE
4273942736
ORIGIN: ../../../flutter/fml/platform/darwin/string_range_sanitization.mm + ../../../flutter/LICENSE
4274042737
ORIGIN: ../../../flutter/fml/platform/fuchsia/log_interest_listener.cc + ../../../flutter/LICENSE
@@ -45592,12 +45589,9 @@ FILE: ../../../flutter/fml/platform/darwin/message_loop_darwin.mm
4559245589
FILE: ../../../flutter/fml/platform/darwin/paths_darwin.mm
4559345590
FILE: ../../../flutter/fml/platform/darwin/platform_version.h
4559445591
FILE: ../../../flutter/fml/platform/darwin/platform_version.mm
45595-
FILE: ../../../flutter/fml/platform/darwin/scoped_block.h
45596-
FILE: ../../../flutter/fml/platform/darwin/scoped_block.mm
4559745592
FILE: ../../../flutter/fml/platform/darwin/scoped_nsautorelease_pool.cc
4559845593
FILE: ../../../flutter/fml/platform/darwin/scoped_nsautorelease_pool.h
4559945594
FILE: ../../../flutter/fml/platform/darwin/scoped_policy.h
45600-
FILE: ../../../flutter/fml/platform/darwin/scoped_typeref.h
4560145595
FILE: ../../../flutter/fml/platform/darwin/string_range_sanitization.h
4560245596
FILE: ../../../flutter/fml/platform/darwin/string_range_sanitization.mm
4560345597
FILE: ../../../flutter/fml/platform/fuchsia/log_interest_listener.cc

fml/BUILD.gn

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,9 @@ source_set("fml") {
147147
"platform/darwin/paths_darwin.mm",
148148
"platform/darwin/platform_version.h",
149149
"platform/darwin/platform_version.mm",
150-
"platform/darwin/scoped_block.h",
151-
"platform/darwin/scoped_block.mm",
152150
"platform/darwin/scoped_nsautorelease_pool.cc",
153151
"platform/darwin/scoped_nsautorelease_pool.h",
154152
"platform/darwin/scoped_policy.h",
155-
"platform/darwin/scoped_typeref.h",
156153
"platform/darwin/string_range_sanitization.h",
157154
"platform/darwin/string_range_sanitization.mm",
158155
]

fml/platform/darwin/scoped_block.h

Lines changed: 0 additions & 46 deletions
This file was deleted.

fml/platform/darwin/scoped_block.mm

Lines changed: 0 additions & 11 deletions
This file was deleted.

fml/platform/darwin/scoped_typeref.h

Lines changed: 0 additions & 146 deletions
This file was deleted.

shell/platform/darwin/ios/framework/Source/platform_message_response_darwin.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
#include "flutter/fml/macros.h"
1111
#include "flutter/fml/make_copyable.h"
12-
#include "flutter/fml/platform/darwin/scoped_block.h"
1312
#include "flutter/fml/task_runner.h"
1413
#include "flutter/lib/ui/window/platform_message_response.h"
1514
#import "flutter/shell/platform/darwin/common/buffer_conversions.h"
@@ -30,7 +29,7 @@ class PlatformMessageResponseDarwin : public flutter::PlatformMessageResponse {
3029

3130
~PlatformMessageResponseDarwin() override;
3231

33-
fml::ScopedBlock<PlatformMessageResponseCallback> callback_;
32+
PlatformMessageResponseCallback callback_;
3433
fml::RefPtr<fml::TaskRunner> platform_task_runner_;
3534

3635
FML_FRIEND_MAKE_REF_COUNTED(PlatformMessageResponseDarwin);

shell/platform/darwin/ios/framework/Source/platform_message_response_darwin.mm

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,20 @@
1313
PlatformMessageResponseDarwin::PlatformMessageResponseDarwin(
1414
PlatformMessageResponseCallback callback,
1515
fml::RefPtr<fml::TaskRunner> platform_task_runner)
16-
: callback_(callback, fml::scoped_policy::OwnershipPolicy::kRetain),
17-
platform_task_runner_(std::move(platform_task_runner)) {}
16+
: callback_(callback), platform_task_runner_(std::move(platform_task_runner)) {}
1817

1918
PlatformMessageResponseDarwin::~PlatformMessageResponseDarwin() = default;
2019

2120
void PlatformMessageResponseDarwin::Complete(std::unique_ptr<fml::Mapping> data) {
2221
fml::RefPtr<PlatformMessageResponseDarwin> self(this);
2322
platform_task_runner_->PostTask(fml::MakeCopyable([self, data = std::move(data)]() mutable {
24-
self->callback_.get()(CopyMappingPtrToNSData(std::move(data)));
23+
self->callback_(CopyMappingPtrToNSData(std::move(data)));
2524
}));
2625
}
2726

2827
void PlatformMessageResponseDarwin::CompleteEmpty() {
2928
fml::RefPtr<PlatformMessageResponseDarwin> self(this);
30-
platform_task_runner_->PostTask(
31-
fml::MakeCopyable([self]() mutable { self->callback_.get()(nil); }));
29+
platform_task_runner_->PostTask(fml::MakeCopyable([self]() mutable { self->callback_(nil); }));
3230
}
3331

3432
} // namespace flutter

shell/platform/darwin/ios/platform_message_handler_ios.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
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 "flutter/fml/platform/darwin/scoped_block.h"
98
#include "flutter/fml/task_runner.h"
109
#include "flutter/shell/common/platform_message_handler.h"
1110
#import "flutter/shell/platform/darwin/ios/flutter_task_queue_dispatch.h"
@@ -33,7 +32,7 @@ class PlatformMessageHandlerIos : public PlatformMessageHandler {
3332

3433
struct HandlerInfo {
3534
NSObject<FlutterTaskQueueDispatch>* task_queue;
36-
fml::ScopedBlock<FlutterBinaryMessageHandler> handler;
35+
FlutterBinaryMessageHandler handler;
3736
};
3837

3938
private:

shell/platform/darwin/ios/platform_message_handler_ios.mm

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,7 @@ - (void)dispatch:(dispatch_block_t)block {
125125
if (handler) {
126126
message_handlers_[channel] = {
127127
.task_queue = (NSObject<FlutterTaskQueueDispatch>*)task_queue,
128-
.handler =
129-
fml::ScopedBlock<FlutterBinaryMessageHandler>{
130-
handler, fml::scoped_policy::OwnershipPolicy::kRetain},
128+
.handler = handler,
131129
};
132130
}
133131
}

0 commit comments

Comments
 (0)