From c70c748e0d2c730ce6a57799e4232c05b5011566 Mon Sep 17 00:00:00 2001 From: 0xZero Date: Fri, 4 Sep 2020 05:34:01 +0800 Subject: [PATCH] Member variables should appear before the |WeakPtrFactory|. (flutter/engine#20899) --- .../src/flutter/lib/ui/painting/image_decoder_unittests.cc | 6 +++--- engine/src/flutter/shell/common/rasterizer.h | 2 +- engine/src/flutter/shell/common/shell.cc | 4 ++-- engine/src/flutter/shell/common/shell.h | 3 +-- engine/src/flutter/shell/common/shell_io_manager.cc | 4 ++-- engine/src/flutter/shell/common/shell_io_manager.h | 4 ++-- .../flutter/shell/platform/fuchsia/flutter/vsync_waiter.cc | 4 ++-- .../flutter/shell/platform/fuchsia/flutter/vsync_waiter.h | 3 +-- 8 files changed, 14 insertions(+), 16 deletions(-) diff --git a/engine/src/flutter/lib/ui/painting/image_decoder_unittests.cc b/engine/src/flutter/lib/ui/painting/image_decoder_unittests.cc index 56130ee181b..5f3b1e3d845 100644 --- a/engine/src/flutter/lib/ui/painting/image_decoder_unittests.cc +++ b/engine/src/flutter/lib/ui/painting/image_decoder_unittests.cc @@ -35,8 +35,8 @@ class TestIOManager final : public IOManager { task_runner, fml::TimeDelta::FromNanoseconds(0))), runner_(task_runner), - weak_factory_(this), - is_gpu_disabled_sync_switch_(std::make_shared()) { + is_gpu_disabled_sync_switch_(std::make_shared()), + weak_factory_(this) { FML_CHECK(task_runner->RunsTasksOnCurrentThread()) << "The IO manager must be initialized its primary task runner. The " "test harness may not be setup correctly/safely."; @@ -85,8 +85,8 @@ class TestIOManager final : public IOManager { fml::RefPtr unref_queue_; fml::WeakPtr weak_prototype_; fml::RefPtr runner_; - fml::WeakPtrFactory weak_factory_; std::shared_ptr is_gpu_disabled_sync_switch_; + fml::WeakPtrFactory weak_factory_; FML_DISALLOW_COPY_AND_ASSIGN(TestIOManager); }; diff --git a/engine/src/flutter/shell/common/rasterizer.h b/engine/src/flutter/shell/common/rasterizer.h index 723f0ee8cfd..e400ff16b2e 100644 --- a/engine/src/flutter/shell/common/rasterizer.h +++ b/engine/src/flutter/shell/common/rasterizer.h @@ -428,8 +428,8 @@ class Rasterizer final : public SnapshotDelegate { fml::closure next_frame_callback_; bool user_override_resource_cache_bytes_; std::optional max_cache_bytes_; - fml::TaskRunnerAffineWeakPtrFactory weak_factory_; fml::RefPtr raster_thread_merger_; + fml::TaskRunnerAffineWeakPtrFactory weak_factory_; // |SnapshotDelegate| sk_sp MakeRasterSnapshot(sk_sp picture, diff --git a/engine/src/flutter/shell/common/shell.cc b/engine/src/flutter/shell/common/shell.cc index 4a423fa2084..ff576e4358c 100644 --- a/engine/src/flutter/shell/common/shell.cc +++ b/engine/src/flutter/shell/common/shell.cc @@ -327,8 +327,8 @@ Shell::Shell(DartVMRef vm, TaskRunners task_runners, Settings settings) settings_(std::move(settings)), vm_(std::move(vm)), is_gpu_disabled_sync_switch_(new fml::SyncSwitch()), - weak_factory_(this), - weak_factory_gpu_(nullptr) { + weak_factory_gpu_(nullptr), + weak_factory_(this) { FML_CHECK(vm_) << "Must have access to VM to create a shell."; FML_DCHECK(task_runners_.IsValid()); FML_DCHECK(task_runners_.GetPlatformTaskRunner()->RunsTasksOnCurrentThread()); diff --git a/engine/src/flutter/shell/common/shell.h b/engine/src/flutter/shell/common/shell.h index f7070f72cda..c8dad14e021 100644 --- a/engine/src/flutter/shell/common/shell.h +++ b/engine/src/flutter/shell/common/shell.h @@ -596,12 +596,11 @@ class Shell final : public PlatformView::Delegate, const ServiceProtocol::Handler::ServiceProtocolMap& params, rapidjson::Document* response); - fml::WeakPtrFactory weak_factory_; - // For accessing the Shell via the raster thread, necessary for various // rasterizer callbacks. std::unique_ptr> weak_factory_gpu_; + fml::WeakPtrFactory weak_factory_; friend class testing::ShellTest; FML_DISALLOW_COPY_AND_ASSIGN(Shell); diff --git a/engine/src/flutter/shell/common/shell_io_manager.cc b/engine/src/flutter/shell/common/shell_io_manager.cc index 3025c5c3c6d..52c74dd8165 100644 --- a/engine/src/flutter/shell/common/shell_io_manager.cc +++ b/engine/src/flutter/shell/common/shell_io_manager.cc @@ -65,8 +65,8 @@ ShellIOManager::ShellIOManager( std::move(unref_queue_task_runner), fml::TimeDelta::FromMilliseconds(8), GetResourceContext())), - weak_factory_(this), - is_gpu_disabled_sync_switch_(is_gpu_disabled_sync_switch) { + is_gpu_disabled_sync_switch_(is_gpu_disabled_sync_switch), + weak_factory_(this) { if (!resource_context_) { #ifndef OS_FUCHSIA FML_DLOG(WARNING) << "The IO manager was initialized without a resource " diff --git a/engine/src/flutter/shell/common/shell_io_manager.h b/engine/src/flutter/shell/common/shell_io_manager.h index e164183a4c3..9cbfbeda509 100644 --- a/engine/src/flutter/shell/common/shell_io_manager.h +++ b/engine/src/flutter/shell/common/shell_io_manager.h @@ -64,10 +64,10 @@ class ShellIOManager final : public IOManager { // Unref queue management. fml::RefPtr unref_queue_; - fml::WeakPtrFactory weak_factory_; - std::shared_ptr is_gpu_disabled_sync_switch_; + fml::WeakPtrFactory weak_factory_; + FML_DISALLOW_COPY_AND_ASSIGN(ShellIOManager); }; diff --git a/engine/src/flutter/shell/platform/fuchsia/flutter/vsync_waiter.cc b/engine/src/flutter/shell/platform/fuchsia/flutter/vsync_waiter.cc index e11ef10f2dc..bb16c0f7229 100644 --- a/engine/src/flutter/shell/platform/fuchsia/flutter/vsync_waiter.cc +++ b/engine/src/flutter/shell/platform/fuchsia/flutter/vsync_waiter.cc @@ -27,8 +27,8 @@ VsyncWaiter::VsyncWaiter(std::string debug_label, debug_label_(std::move(debug_label)), session_wait_(session_present_handle, SessionPresentSignal), vsync_offset_(vsync_offset), - weak_factory_(this), - weak_factory_ui_(nullptr) { + weak_factory_ui_(nullptr), + weak_factory_(this) { auto wait_handler = [&](async_dispatcher_t* dispatcher, // async::Wait* wait, // zx_status_t status, // diff --git a/engine/src/flutter/shell/platform/fuchsia/flutter/vsync_waiter.h b/engine/src/flutter/shell/platform/fuchsia/flutter/vsync_waiter.h index 199d3611d5b..117153c4910 100644 --- a/engine/src/flutter/shell/platform/fuchsia/flutter/vsync_waiter.h +++ b/engine/src/flutter/shell/platform/fuchsia/flutter/vsync_waiter.h @@ -37,11 +37,10 @@ class VsyncWaiter final : public flutter::VsyncWaiter { async::Wait session_wait_; fml::TimeDelta vsync_offset_ = fml::TimeDelta::FromMicroseconds(0); - fml::WeakPtrFactory weak_factory_; - // For accessing the VsyncWaiter via the UI thread, necessary for the callback // for AwaitVSync() std::unique_ptr> weak_factory_ui_; + fml::WeakPtrFactory weak_factory_; // |flutter::VsyncWaiter| void AwaitVSync() override;