diff --git a/lib/ui/window/platform_configuration.cc b/lib/ui/window/platform_configuration.cc index 44f389a880272..981cbbf8b74de 100644 --- a/lib/ui/window/platform_configuration.cc +++ b/lib/ui/window/platform_configuration.cc @@ -124,12 +124,12 @@ Dart_Handle SendPlatformMessage(Dart_Handle window, } if (Dart_IsNull(data_handle)) { dart_state->platform_configuration()->client()->HandlePlatformMessage( - fml::MakeRefCounted(name, response)); + std::make_unique(name, response)); } else { tonic::DartByteData data(data_handle); const uint8_t* buffer = static_cast(data.data()); dart_state->platform_configuration()->client()->HandlePlatformMessage( - fml::MakeRefCounted( + std::make_unique( name, std::vector(buffer, buffer + data.length_in_bytes()), response)); } @@ -305,7 +305,7 @@ void PlatformConfiguration::UpdateAccessibilityFeatures(int32_t values) { } void PlatformConfiguration::DispatchPlatformMessage( - fml::RefPtr message) { + std::unique_ptr message) { std::shared_ptr dart_state = dispatch_platform_message_.dart_state().lock(); if (!dart_state) { diff --git a/lib/ui/window/platform_configuration.h b/lib/ui/window/platform_configuration.h index e6dacbb535b57..11aef73a2fff1 100644 --- a/lib/ui/window/platform_configuration.h +++ b/lib/ui/window/platform_configuration.h @@ -87,7 +87,8 @@ class PlatformConfigurationClient { /// @param[in] message The message from the Flutter application to send to /// the underlying platform. /// - virtual void HandlePlatformMessage(fml::RefPtr message) = 0; + virtual void HandlePlatformMessage( + std::unique_ptr message) = 0; //-------------------------------------------------------------------------- /// @brief Returns the current collection of fonts available on the @@ -309,7 +310,7 @@ class PlatformConfiguration final { /// @param[in] message The message sent from the embedder to the Dart /// application. /// - void DispatchPlatformMessage(fml::RefPtr message); + void DispatchPlatformMessage(std::unique_ptr message); //---------------------------------------------------------------------------- /// @brief Notifies the framework that the embedder encountered an diff --git a/lib/ui/window/platform_configuration_unittests.cc b/lib/ui/window/platform_configuration_unittests.cc index f38498614e187..3d5aa0b767f5d 100644 --- a/lib/ui/window/platform_configuration_unittests.cc +++ b/lib/ui/window/platform_configuration_unittests.cc @@ -29,7 +29,8 @@ class DummyPlatformConfigurationClient : public PlatformConfigurationClient { void ScheduleFrame() override {} void Render(Scene* scene) override {} void UpdateSemantics(SemanticsUpdate* update) override {} - void HandlePlatformMessage(fml::RefPtr message) override {} + void HandlePlatformMessage( + std::unique_ptr message) override {} FontCollection& GetFontCollection() override { return font_collection_; } void UpdateIsolateDescription(const std::string isolate_name, int64_t isolate_port) override {} diff --git a/lib/ui/window/platform_message.h b/lib/ui/window/platform_message.h index 58adac825169e..c0e807bf32aa9 100644 --- a/lib/ui/window/platform_message.h +++ b/lib/ui/window/platform_message.h @@ -14,11 +14,15 @@ namespace flutter { -class PlatformMessage : public fml::RefCountedThreadSafe { - FML_FRIEND_REF_COUNTED_THREAD_SAFE(PlatformMessage); - FML_FRIEND_MAKE_REF_COUNTED(PlatformMessage); - +class PlatformMessage { public: + PlatformMessage(std::string channel, + std::vector data, + fml::RefPtr response); + PlatformMessage(std::string channel, + fml::RefPtr response); + ~PlatformMessage(); + const std::string& channel() const { return channel_; } const std::vector& data() const { return data_; } bool hasData() { return hasData_; } @@ -28,13 +32,6 @@ class PlatformMessage : public fml::RefCountedThreadSafe { } private: - PlatformMessage(std::string channel, - std::vector data, - fml::RefPtr response); - PlatformMessage(std::string channel, - fml::RefPtr response); - ~PlatformMessage(); - std::string channel_; std::vector data_; bool hasData_; diff --git a/runtime/runtime_controller.cc b/runtime/runtime_controller.cc index d9abb720e1f21..f532cc772e956 100644 --- a/runtime/runtime_controller.cc +++ b/runtime/runtime_controller.cc @@ -239,7 +239,7 @@ bool RuntimeController::NotifyIdle(int64_t deadline, size_t freed_hint) { } bool RuntimeController::DispatchPlatformMessage( - fml::RefPtr message) { + std::unique_ptr message) { if (auto* platform_configuration = GetPlatformConfigurationIfAvailable()) { TRACE_EVENT1("flutter", "RuntimeController::DispatchPlatformMessage", "mode", "basic"); @@ -320,7 +320,7 @@ void RuntimeController::UpdateSemantics(SemanticsUpdate* update) { // |PlatformConfigurationClient| void RuntimeController::HandlePlatformMessage( - fml::RefPtr message) { + std::unique_ptr message) { client_.HandlePlatformMessage(std::move(message)); } diff --git a/runtime/runtime_controller.h b/runtime/runtime_controller.h index ca2381d46fe13..7734e85d50e8e 100644 --- a/runtime/runtime_controller.h +++ b/runtime/runtime_controller.h @@ -411,7 +411,8 @@ class RuntimeController : public PlatformConfigurationClient { /// @return If the message was dispatched to the running root isolate. /// This may fail is an isolate is not running. /// - virtual bool DispatchPlatformMessage(fml::RefPtr message); + virtual bool DispatchPlatformMessage( + std::unique_ptr message); //---------------------------------------------------------------------------- /// @brief Dispatch the specified pointer data message to the running @@ -655,7 +656,7 @@ class RuntimeController : public PlatformConfigurationClient { void UpdateSemantics(SemanticsUpdate* update) override; // |PlatformConfigurationClient| - void HandlePlatformMessage(fml::RefPtr message) override; + void HandlePlatformMessage(std::unique_ptr message) override; // |PlatformConfigurationClient| FontCollection& GetFontCollection() override; diff --git a/runtime/runtime_delegate.h b/runtime/runtime_delegate.h index d2e5e9ff14caf..ed57722e532f9 100644 --- a/runtime/runtime_delegate.h +++ b/runtime/runtime_delegate.h @@ -28,7 +28,8 @@ class RuntimeDelegate { virtual void UpdateSemantics(SemanticsNodeUpdates update, CustomAccessibilityActionUpdates actions) = 0; - virtual void HandlePlatformMessage(fml::RefPtr message) = 0; + virtual void HandlePlatformMessage( + std::unique_ptr message) = 0; virtual FontCollection& GetFontCollection() = 0; diff --git a/shell/common/engine.cc b/shell/common/engine.cc index 14b30b322c345..aae603952b6c7 100644 --- a/shell/common/engine.cc +++ b/shell/common/engine.cc @@ -203,13 +203,13 @@ Engine::RunStatus Engine::Run(RunConfiguration configuration) { auto service_id = runtime_controller_->GetRootIsolateServiceID(); if (service_id.has_value()) { - fml::RefPtr service_id_message = - fml::MakeRefCounted( + std::unique_ptr service_id_message = + std::make_unique( kIsolateChannel, std::vector(service_id.value().begin(), service_id.value().end()), nullptr); - HandlePlatformMessage(service_id_message); + HandlePlatformMessage(std::move(service_id_message)); } return Engine::RunStatus::Success; @@ -285,7 +285,7 @@ void Engine::SetViewportMetrics(const ViewportMetrics& metrics) { } } -void Engine::DispatchPlatformMessage(fml::RefPtr message) { +void Engine::DispatchPlatformMessage(std::unique_ptr message) { std::string channel = message->channel(); if (channel == kLifecycleChannel) { if (HandleLifecyclePlatformMessage(message.get())) { @@ -338,7 +338,7 @@ bool Engine::HandleLifecyclePlatformMessage(PlatformMessage* message) { } bool Engine::HandleNavigationPlatformMessage( - fml::RefPtr message) { + std::unique_ptr message) { const auto& data = message->data(); rapidjson::Document document; @@ -477,7 +477,7 @@ void Engine::UpdateSemantics(SemanticsNodeUpdates update, delegate_.OnEngineUpdateSemantics(std::move(update), std::move(actions)); } -void Engine::HandlePlatformMessage(fml::RefPtr message) { +void Engine::HandlePlatformMessage(std::unique_ptr message) { if (message->channel() == kAssetChannel) { HandleAssetPlatformMessage(std::move(message)); } else { @@ -520,7 +520,8 @@ void Engine::ScheduleSecondaryVsyncCallback(uintptr_t id, animator_->ScheduleSecondaryVsyncCallback(id, callback); } -void Engine::HandleAssetPlatformMessage(fml::RefPtr message) { +void Engine::HandleAssetPlatformMessage( + std::unique_ptr message) { fml::RefPtr response = message->response(); if (!response) { return; diff --git a/shell/common/engine.h b/shell/common/engine.h index 2043a11569a42..2b01253623b67 100644 --- a/shell/common/engine.h +++ b/shell/common/engine.h @@ -178,7 +178,7 @@ class Engine final : public RuntimeDelegate, /// the underlying platform. /// virtual void OnEngineHandlePlatformMessage( - fml::RefPtr message) = 0; + std::unique_ptr message) = 0; //-------------------------------------------------------------------------- /// @brief Notifies the delegate that the root isolate of the @@ -706,7 +706,7 @@ class Engine final : public RuntimeDelegate, /// @param[in] message The message sent from the embedder to the Dart /// application. /// - void DispatchPlatformMessage(fml::RefPtr message); + void DispatchPlatformMessage(std::unique_ptr message); //---------------------------------------------------------------------------- /// @brief Notifies the engine that the embedder has sent it a pointer @@ -930,7 +930,7 @@ class Engine final : public RuntimeDelegate, CustomAccessibilityActionUpdates actions) override; // |RuntimeDelegate| - void HandlePlatformMessage(fml::RefPtr message) override; + void HandlePlatformMessage(std::unique_ptr message) override; // |RuntimeDelegate| void OnRootIsolateCreated() override; @@ -954,13 +954,14 @@ class Engine final : public RuntimeDelegate, bool HandleLifecyclePlatformMessage(PlatformMessage* message); - bool HandleNavigationPlatformMessage(fml::RefPtr message); + bool HandleNavigationPlatformMessage( + std::unique_ptr message); bool HandleLocalizationPlatformMessage(PlatformMessage* message); void HandleSettingsPlatformMessage(PlatformMessage* message); - void HandleAssetPlatformMessage(fml::RefPtr message); + void HandleAssetPlatformMessage(std::unique_ptr message); bool GetAssetAsBuffer(const std::string& name, std::vector* data); diff --git a/shell/common/engine_unittests.cc b/shell/common/engine_unittests.cc index e2a9996c6b4a6..7878877a93228 100644 --- a/shell/common/engine_unittests.cc +++ b/shell/common/engine_unittests.cc @@ -25,7 +25,7 @@ class MockDelegate : public Engine::Delegate { MOCK_METHOD2(OnEngineUpdateSemantics, void(SemanticsNodeUpdates, CustomAccessibilityActionUpdates)); MOCK_METHOD1(OnEngineHandlePlatformMessage, - void(fml::RefPtr)); + void(std::unique_ptr)); MOCK_METHOD0(OnPreEngineRestart, void()); MOCK_METHOD0(OnRootIsolateCreated, void()); MOCK_METHOD2(UpdateIsolateDescription, void(const std::string, int64_t)); @@ -49,7 +49,7 @@ class MockRuntimeDelegate : public RuntimeDelegate { MOCK_METHOD1(Render, void(std::unique_ptr)); MOCK_METHOD2(UpdateSemantics, void(SemanticsNodeUpdates, CustomAccessibilityActionUpdates)); - MOCK_METHOD1(HandlePlatformMessage, void(fml::RefPtr)); + MOCK_METHOD1(HandlePlatformMessage, void(std::unique_ptr)); MOCK_METHOD0(GetFontCollection, FontCollection&()); MOCK_METHOD0(OnRootIsolateCreated, void()); MOCK_METHOD2(UpdateIsolateDescription, void(const std::string, int64_t)); @@ -65,13 +65,13 @@ class MockRuntimeController : public RuntimeController { MockRuntimeController(RuntimeDelegate& client, TaskRunners p_task_runners) : RuntimeController(client, p_task_runners) {} MOCK_METHOD0(IsRootIsolateRunning, bool()); - MOCK_METHOD1(DispatchPlatformMessage, bool(fml::RefPtr)); + MOCK_METHOD1(DispatchPlatformMessage, bool(std::unique_ptr)); MOCK_METHOD3(LoadDartDeferredLibraryError, void(intptr_t, const std::string, bool)); MOCK_CONST_METHOD0(GetDartVM, DartVM*()); }; -fml::RefPtr MakePlatformMessage( +std::unique_ptr MakePlatformMessage( const std::string& channel, const std::map& values, fml::RefPtr response) { @@ -92,7 +92,7 @@ fml::RefPtr MakePlatformMessage( document.Accept(writer); const uint8_t* data = reinterpret_cast(buffer.GetString()); - fml::RefPtr message = fml::MakeRefCounted( + std::unique_ptr message = std::make_unique( channel, std::vector(data, data + buffer.GetSize()), response); return message; } @@ -176,9 +176,9 @@ TEST_F(EngineTest, DispatchPlatformMessageUnknown) { fml::RefPtr response = fml::MakeRefCounted(); - fml::RefPtr message = - fml::MakeRefCounted("foo", response); - engine->DispatchPlatformMessage(message); + std::unique_ptr message = + std::make_unique("foo", response); + engine->DispatchPlatformMessage(std::move(message)); }); } @@ -206,9 +206,9 @@ TEST_F(EngineTest, DispatchPlatformMessageInitialRoute) { {"method", "setInitialRoute"}, {"args", "test_initial_route"}, }; - fml::RefPtr message = + std::unique_ptr message = MakePlatformMessage("flutter/navigation", values, response); - engine->DispatchPlatformMessage(message); + engine->DispatchPlatformMessage(std::move(message)); EXPECT_EQ(engine->InitialRoute(), "test_initial_route"); }); } @@ -239,9 +239,9 @@ TEST_F(EngineTest, DispatchPlatformMessageInitialRouteIgnored) { {"method", "setInitialRoute"}, {"args", "test_initial_route"}, }; - fml::RefPtr message = + std::unique_ptr message = MakePlatformMessage("flutter/navigation", values, response); - engine->DispatchPlatformMessage(message); + engine->DispatchPlatformMessage(std::move(message)); EXPECT_EQ(engine->InitialRoute(), ""); }); } diff --git a/shell/common/platform_view.cc b/shell/common/platform_view.cc index 5441184543040..6db8ba0c29be5 100644 --- a/shell/common/platform_view.cc +++ b/shell/common/platform_view.cc @@ -32,7 +32,7 @@ std::unique_ptr PlatformView::CreateVSyncWaiter() { } void PlatformView::DispatchPlatformMessage( - fml::RefPtr message) { + std::unique_ptr message) { delegate_.OnPlatformViewDispatchPlatformMessage(std::move(message)); } @@ -115,7 +115,8 @@ fml::WeakPtr PlatformView::GetWeakPtr() const { void PlatformView::UpdateSemantics(SemanticsNodeUpdates update, CustomAccessibilityActionUpdates actions) {} -void PlatformView::HandlePlatformMessage(fml::RefPtr message) { +void PlatformView::HandlePlatformMessage( + std::unique_ptr message) { if (auto response = message->response()) response->CompleteEmpty(); } diff --git a/shell/common/platform_view.h b/shell/common/platform_view.h index 4d05b92bb74ec..52d42cd19baef 100644 --- a/shell/common/platform_view.h +++ b/shell/common/platform_view.h @@ -114,7 +114,7 @@ class PlatformView { /// root isolate. /// virtual void OnPlatformViewDispatchPlatformMessage( - fml::RefPtr message) = 0; + std::unique_ptr message) = 0; //-------------------------------------------------------------------------- /// @brief Notifies the delegate that the platform view has encountered @@ -379,7 +379,7 @@ class PlatformView { /// /// @param[in] message The platform message to deliver to the root isolate. /// - void DispatchPlatformMessage(fml::RefPtr message); + void DispatchPlatformMessage(std::unique_ptr message); //---------------------------------------------------------------------------- /// @brief Overridden by embedders to perform actions in response to @@ -395,7 +395,7 @@ class PlatformView { /// /// @param[in] message The message /// - virtual void HandlePlatformMessage(fml::RefPtr message); + virtual void HandlePlatformMessage(std::unique_ptr message); //---------------------------------------------------------------------------- /// @brief Used by embedders to dispatch an accessibility action to a diff --git a/shell/common/shell.cc b/shell/common/shell.cc index e919c1b86a2f2..7b76d0f3d22bb 100644 --- a/shell/common/shell.cc +++ b/shell/common/shell.cc @@ -949,16 +949,16 @@ void Shell::OnPlatformViewSetViewportMetrics(const ViewportMetrics& metrics) { // |PlatformView::Delegate| void Shell::OnPlatformViewDispatchPlatformMessage( - fml::RefPtr message) { + std::unique_ptr message) { FML_DCHECK(is_setup_); FML_DCHECK(task_runners_.GetPlatformTaskRunner()->RunsTasksOnCurrentThread()); - task_runners_.GetUITaskRunner()->PostTask( - [engine = engine_->GetWeakPtr(), message = std::move(message)] { + task_runners_.GetUITaskRunner()->PostTask(fml::MakeCopyable( + [engine = engine_->GetWeakPtr(), message = std::move(message)]() mutable { if (engine) { engine->DispatchPlatformMessage(std::move(message)); } - }); + })); } // |PlatformView::Delegate| @@ -1203,7 +1203,7 @@ void Shell::OnEngineUpdateSemantics(SemanticsNodeUpdates update, // |Engine::Delegate| void Shell::OnEngineHandlePlatformMessage( - fml::RefPtr message) { + std::unique_ptr message) { FML_DCHECK(is_setup_); FML_DCHECK(task_runners_.GetUITaskRunner()->RunsTasksOnCurrentThread()); @@ -1213,14 +1213,15 @@ void Shell::OnEngineHandlePlatformMessage( } task_runners_.GetPlatformTaskRunner()->PostTask( - [view = platform_view_->GetWeakPtr(), message = std::move(message)]() { + fml::MakeCopyable([view = platform_view_->GetWeakPtr(), + message = std::move(message)]() mutable { if (view) { view->HandlePlatformMessage(std::move(message)); } - }); + })); } -void Shell::HandleEngineSkiaMessage(fml::RefPtr message) { +void Shell::HandleEngineSkiaMessage(std::unique_ptr message) { const auto& data = message->data(); rapidjson::Document document; @@ -1797,12 +1798,12 @@ bool Shell::ReloadSystemFonts() { rapidjson::Writer writer(buffer); document.Accept(writer); std::string message = buffer.GetString(); - fml::RefPtr fontsChangeMessage = - fml::MakeRefCounted( + std::unique_ptr fontsChangeMessage = + std::make_unique( kSystemChannel, std::vector(message.begin(), message.end()), nullptr); - OnPlatformViewDispatchPlatformMessage(fontsChangeMessage); + OnPlatformViewDispatchPlatformMessage(std::move(fontsChangeMessage)); return true; } diff --git a/shell/common/shell.h b/shell/common/shell.h index b830f61c36b16..15137d5ee5a71 100644 --- a/shell/common/shell.h +++ b/shell/common/shell.h @@ -476,7 +476,7 @@ class Shell final : public PlatformView::Delegate, // |PlatformView::Delegate| void OnPlatformViewDispatchPlatformMessage( - fml::RefPtr message) override; + std::unique_ptr message) override; // |PlatformView::Delegate| void OnPlatformViewDispatchPointerDataPacket( @@ -547,9 +547,9 @@ class Shell final : public PlatformView::Delegate, // |Engine::Delegate| void OnEngineHandlePlatformMessage( - fml::RefPtr message) override; + std::unique_ptr message) override; - void HandleEngineSkiaMessage(fml::RefPtr message); + void HandleEngineSkiaMessage(std::unique_ptr message); // |Engine::Delegate| void OnPreEngineRestart() override; diff --git a/shell/common/shell_test.cc b/shell/common/shell_test.cc index 00c12f05ca3cf..88c140fd60d31 100644 --- a/shell/common/shell_test.cc +++ b/shell/common/shell_test.cc @@ -26,16 +26,17 @@ ShellTest::ShellTest() void ShellTest::SendEnginePlatformMessage( Shell* shell, - fml::RefPtr message) { + std::unique_ptr message) { fml::AutoResetWaitableEvent latch; fml::TaskRunner::RunNowOrPostTask( shell->GetTaskRunners().GetPlatformTaskRunner(), - [shell, &latch, message = std::move(message)]() { - if (auto engine = shell->weak_engine_) { - engine->HandlePlatformMessage(std::move(message)); - } - latch.Signal(); - }); + fml::MakeCopyable( + [shell, &latch, message = std::move(message)]() mutable { + if (auto engine = shell->weak_engine_) { + engine->HandlePlatformMessage(std::move(message)); + } + latch.Signal(); + })); latch.Wait(); } diff --git a/shell/common/shell_test.h b/shell/common/shell_test.h index dbbbe8c2b8b3e..b2f1052fa98e1 100644 --- a/shell/common/shell_test.h +++ b/shell/common/shell_test.h @@ -51,7 +51,7 @@ class ShellTest : public FixtureTest { fml::TimePoint GetLatestFrameTargetTime(Shell* shell) const; void SendEnginePlatformMessage(Shell* shell, - fml::RefPtr message); + std::unique_ptr message); static void PlatformViewNotifyCreated( Shell* shell); // This creates the surface diff --git a/shell/common/shell_unittests.cc b/shell/common/shell_unittests.cc index d31c138fda7a4..b2f917ca1de22 100644 --- a/shell/common/shell_unittests.cc +++ b/shell/common/shell_unittests.cc @@ -57,7 +57,7 @@ class MockPlatformViewDelegate : public PlatformView::Delegate { void(const ViewportMetrics& metrics)); MOCK_METHOD1(OnPlatformViewDispatchPlatformMessage, - void(fml::RefPtr message)); + void(std::unique_ptr message)); MOCK_METHOD1(OnPlatformViewDispatchPointerDataPacket, void(std::unique_ptr packet)); @@ -1546,7 +1546,7 @@ TEST_F(ShellTest, SetResourceCacheSize) { "args": 10000 })json"; std::vector data(request_json.begin(), request_json.end()); - auto platform_message = fml::MakeRefCounted( + auto platform_message = std::make_unique( "flutter/skia", std::move(data), nullptr); SendEnginePlatformMessage(shell.get(), std::move(platform_message)); PumpOneFrame(shell.get()); diff --git a/shell/platform/android/jni/jni_mock.h b/shell/platform/android/jni/jni_mock.h index 52b38e1e84308..1a31db796a3ce 100644 --- a/shell/platform/android/jni/jni_mock.h +++ b/shell/platform/android/jni/jni_mock.h @@ -18,7 +18,8 @@ class JNIMock final : public PlatformViewAndroidJNI { public: MOCK_METHOD(void, FlutterViewHandlePlatformMessage, - (fml::RefPtr message, int responseId), + (std::unique_ptr message, + int responseId), (override)); MOCK_METHOD(void, diff --git a/shell/platform/android/jni/jni_mock_unittest.cc b/shell/platform/android/jni/jni_mock_unittest.cc index cdd50c6567c29..6c7564c714166 100644 --- a/shell/platform/android/jni/jni_mock_unittest.cc +++ b/shell/platform/android/jni/jni_mock_unittest.cc @@ -13,13 +13,16 @@ namespace testing { TEST(JNIMock, FlutterViewHandlePlatformMessage) { JNIMock mock; - auto message = - fml::MakeRefCounted("", nullptr); + auto message = std::make_unique("", nullptr); auto response_id = 1; - EXPECT_CALL(mock, FlutterViewHandlePlatformMessage(message, response_id)); + EXPECT_CALL(mock, + FlutterViewHandlePlatformMessage( + ::testing::Property(&std::unique_ptr::get, + message.get()), + response_id)); - mock.FlutterViewHandlePlatformMessage(message, response_id); + mock.FlutterViewHandlePlatformMessage(std::move(message), response_id); } } // namespace testing diff --git a/shell/platform/android/jni/platform_view_android_jni.h b/shell/platform/android/jni/platform_view_android_jni.h index 81323605de68c..eae098a6b8871 100644 --- a/shell/platform/android/jni/platform_view_android_jni.h +++ b/shell/platform/android/jni/platform_view_android_jni.h @@ -41,7 +41,7 @@ class PlatformViewAndroidJNI { /// @brief Sends a platform message. The message may be empty. /// virtual void FlutterViewHandlePlatformMessage( - fml::RefPtr message, + std::unique_ptr message, int responseId) = 0; //---------------------------------------------------------------------------- diff --git a/shell/platform/android/platform_view_android.cc b/shell/platform/android/platform_view_android.cc index 771420e799487..1420fbebe4b9b 100644 --- a/shell/platform/android/platform_view_android.cc +++ b/shell/platform/android/platform_view_android.cc @@ -190,7 +190,7 @@ void PlatformViewAndroid::DispatchPlatformMessage(JNIEnv* env, } PlatformView::DispatchPlatformMessage( - fml::MakeRefCounted( + std::make_unique( std::move(name), std::move(message), std::move(response))); } @@ -204,8 +204,8 @@ void PlatformViewAndroid::DispatchEmptyPlatformMessage(JNIEnv* env, } PlatformView::DispatchPlatformMessage( - fml::MakeRefCounted(std::move(name), - std::move(response))); + std::make_unique(std::move(name), + std::move(response))); } void PlatformViewAndroid::InvokePlatformMessageResponseCallback( @@ -243,14 +243,15 @@ void PlatformViewAndroid::InvokePlatformMessageEmptyResponseCallback( // |PlatformView| void PlatformViewAndroid::HandlePlatformMessage( - fml::RefPtr message) { + std::unique_ptr message) { int response_id = 0; if (auto response = message->response()) { response_id = next_response_id_++; pending_responses_[response_id] = response; } // This call can re-enter in InvokePlatformMessageXxxResponseCallback. - jni_facade_->FlutterViewHandlePlatformMessage(message, response_id); + jni_facade_->FlutterViewHandlePlatformMessage(std::move(message), + response_id); message = nullptr; } diff --git a/shell/platform/android/platform_view_android.h b/shell/platform/android/platform_view_android.h index 61d92c7631862..725b0f077c7a3 100644 --- a/shell/platform/android/platform_view_android.h +++ b/shell/platform/android/platform_view_android.h @@ -137,7 +137,7 @@ class PlatformViewAndroid final : public PlatformView { // |PlatformView| void HandlePlatformMessage( - fml::RefPtr message) override; + std::unique_ptr message) override; // |PlatformView| void OnPreEngineRestart() const override; diff --git a/shell/platform/android/platform_view_android_jni_impl.cc b/shell/platform/android/platform_view_android_jni_impl.cc index 4f957bbf62f8f..2e6e81c615376 100644 --- a/shell/platform/android/platform_view_android_jni_impl.cc +++ b/shell/platform/android/platform_view_android_jni_impl.cc @@ -1094,7 +1094,7 @@ PlatformViewAndroidJNIImpl::PlatformViewAndroidJNIImpl( PlatformViewAndroidJNIImpl::~PlatformViewAndroidJNIImpl() = default; void PlatformViewAndroidJNIImpl::FlutterViewHandlePlatformMessage( - fml::RefPtr message, + std::unique_ptr message, int responseId) { JNIEnv* env = fml::jni::AttachCurrentThread(); diff --git a/shell/platform/android/platform_view_android_jni_impl.h b/shell/platform/android/platform_view_android_jni_impl.h index 8fe0618929e95..34b80f07c6297 100644 --- a/shell/platform/android/platform_view_android_jni_impl.h +++ b/shell/platform/android/platform_view_android_jni_impl.h @@ -21,7 +21,7 @@ class PlatformViewAndroidJNIImpl final : public PlatformViewAndroidJNI { ~PlatformViewAndroidJNIImpl() override; void FlutterViewHandlePlatformMessage( - fml::RefPtr message, + std::unique_ptr message, int responseId) override; void FlutterViewHandlePlatformMessageResponse( diff --git a/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm b/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm index d5e3564ecffca..780bac01ea0f4 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm @@ -804,12 +804,12 @@ - (void)sendOnChannel:(NSString*)channel callback(reply); }, _shell->GetTaskRunners().GetPlatformTaskRunner()); - fml::RefPtr platformMessage = - (message == nil) ? fml::MakeRefCounted(channel.UTF8String, response) - : fml::MakeRefCounted( + std::unique_ptr platformMessage = + (message == nil) ? std::make_unique(channel.UTF8String, response) + : std::make_unique( channel.UTF8String, flutter::GetVectorFromNSData(message), response); - _shell->GetPlatformView()->DispatchPlatformMessage(platformMessage); + _shell->GetPlatformView()->DispatchPlatformMessage(std::move(platformMessage)); } - (FlutterBinaryMessengerConnection)setMessageHandlerOnChannel:(NSString*)channel diff --git a/shell/platform/darwin/ios/framework/Source/FlutterEnginePlatformViewTest.mm b/shell/platform/darwin/ios/framework/Source/FlutterEnginePlatformViewTest.mm index 2af636a71c13e..5710f832332d1 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterEnginePlatformViewTest.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterEnginePlatformViewTest.mm @@ -22,7 +22,7 @@ void OnPlatformViewCreated(std::unique_ptr surface) override {} void OnPlatformViewDestroyed() override {} void OnPlatformViewSetNextFrameCallback(const fml::closure& closure) override {} void OnPlatformViewSetViewportMetrics(const ViewportMetrics& metrics) override {} - void OnPlatformViewDispatchPlatformMessage(fml::RefPtr message) override {} + void OnPlatformViewDispatchPlatformMessage(std::unique_ptr message) override {} void OnPlatformViewDispatchPointerDataPacket(std::unique_ptr packet) override { } void OnPlatformViewDispatchKeyDataPacket(std::unique_ptr packet, diff --git a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsTest.mm b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsTest.mm index a9d6dbd9d8410..a22d182792e68 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsTest.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsTest.mm @@ -92,7 +92,7 @@ void OnPlatformViewCreated(std::unique_ptr surface) override {} void OnPlatformViewDestroyed() override {} void OnPlatformViewSetNextFrameCallback(const fml::closure& closure) override {} void OnPlatformViewSetViewportMetrics(const ViewportMetrics& metrics) override {} - void OnPlatformViewDispatchPlatformMessage(fml::RefPtr message) override {} + void OnPlatformViewDispatchPlatformMessage(std::unique_ptr message) override {} void OnPlatformViewDispatchPointerDataPacket(std::unique_ptr packet) override { } void OnPlatformViewDispatchKeyDataPacket(std::unique_ptr packet, diff --git a/shell/platform/darwin/ios/framework/Source/accessibility_bridge_test.mm b/shell/platform/darwin/ios/framework/Source/accessibility_bridge_test.mm index 35fd8aac9ffbc..5aac2e296ad63 100644 --- a/shell/platform/darwin/ios/framework/Source/accessibility_bridge_test.mm +++ b/shell/platform/darwin/ios/framework/Source/accessibility_bridge_test.mm @@ -75,7 +75,7 @@ void OnPlatformViewCreated(std::unique_ptr surface) override {} void OnPlatformViewDestroyed() override {} void OnPlatformViewSetNextFrameCallback(const fml::closure& closure) override {} void OnPlatformViewSetViewportMetrics(const ViewportMetrics& metrics) override {} - void OnPlatformViewDispatchPlatformMessage(fml::RefPtr message) override {} + void OnPlatformViewDispatchPlatformMessage(std::unique_ptr message) override {} void OnPlatformViewDispatchPointerDataPacket(std::unique_ptr packet) override { } void OnPlatformViewDispatchKeyDataPacket(std::unique_ptr packet, diff --git a/shell/platform/darwin/ios/framework/Source/platform_message_router.h b/shell/platform/darwin/ios/framework/Source/platform_message_router.h index ef80878dce635..e8927552ddc32 100644 --- a/shell/platform/darwin/ios/framework/Source/platform_message_router.h +++ b/shell/platform/darwin/ios/framework/Source/platform_message_router.h @@ -20,7 +20,7 @@ class PlatformMessageRouter { ~PlatformMessageRouter(); void HandlePlatformMessage( - fml::RefPtr message) const; + std::unique_ptr message) const; void SetMessageHandler(const std::string& channel, FlutterBinaryMessageHandler handler); diff --git a/shell/platform/darwin/ios/framework/Source/platform_message_router.mm b/shell/platform/darwin/ios/framework/Source/platform_message_router.mm index 8fb81cc4a9a28..70ae8d75cb586 100644 --- a/shell/platform/darwin/ios/framework/Source/platform_message_router.mm +++ b/shell/platform/darwin/ios/framework/Source/platform_message_router.mm @@ -15,7 +15,7 @@ PlatformMessageRouter::~PlatformMessageRouter() = default; void PlatformMessageRouter::HandlePlatformMessage( - fml::RefPtr message) const { + std::unique_ptr message) const { fml::RefPtr completer = message->response(); auto it = message_handlers_.find(message->channel()); if (it != message_handlers_.end()) { diff --git a/shell/platform/darwin/ios/platform_view_ios.h b/shell/platform/darwin/ios/platform_view_ios.h index cfff9d60b97b0..3af69b7b2bf8a 100644 --- a/shell/platform/darwin/ios/platform_view_ios.h +++ b/shell/platform/darwin/ios/platform_view_ios.h @@ -144,7 +144,7 @@ class PlatformViewIOS final : public PlatformView { std::vector platform_resolved_locale_; // |PlatformView| - void HandlePlatformMessage(fml::RefPtr message) override; + void HandlePlatformMessage(std::unique_ptr message) override; // |PlatformView| std::unique_ptr CreateRenderingSurface() override; diff --git a/shell/platform/darwin/ios/platform_view_ios.mm b/shell/platform/darwin/ios/platform_view_ios.mm index 17974a0700d1b..081bbe0db130a 100644 --- a/shell/platform/darwin/ios/platform_view_ios.mm +++ b/shell/platform/darwin/ios/platform_view_ios.mm @@ -72,7 +72,7 @@ } // |PlatformView| -void PlatformViewIOS::HandlePlatformMessage(fml::RefPtr message) { +void PlatformViewIOS::HandlePlatformMessage(std::unique_ptr message) { platform_message_router_.HandlePlatformMessage(std::move(message)); } diff --git a/shell/platform/embedder/embedder.cc b/shell/platform/embedder/embedder.cc index 57c3743740516..3c9760d7fecb1 100644 --- a/shell/platform/embedder/embedder.cc +++ b/shell/platform/embedder/embedder.cc @@ -730,7 +730,7 @@ InferExternalViewEmbedderFromArgs(const FlutterCompositor* compositor) { } struct _FlutterPlatformMessageResponseHandle { - fml::RefPtr message; + std::unique_ptr message; }; struct LoadedElfDeleter { @@ -1105,7 +1105,7 @@ FlutterEngineResult FlutterEngineInitialize(size_t version, if (SAFE_ACCESS(args, platform_message_callback, nullptr) != nullptr) { platform_message_response_callback = [ptr = args->platform_message_callback, - user_data](fml::RefPtr message) { + user_data](std::unique_ptr message) { auto handle = new FlutterPlatformMessageResponseHandle(); const FlutterPlatformMessage incoming_message = { sizeof(FlutterPlatformMessage), // struct_size @@ -1636,12 +1636,12 @@ FlutterEngineResult FlutterEngineSendPlatformMessage( response = response_handle->message->response(); } - fml::RefPtr message; + std::unique_ptr message; if (message_size == 0) { - message = fml::MakeRefCounted( + message = std::make_unique( flutter_message->channel, response); } else { - message = fml::MakeRefCounted( + message = std::make_unique( flutter_message->channel, std::vector(message_data, message_data + message_size), response); @@ -1680,7 +1680,7 @@ FlutterEngineResult FlutterPlatformMessageCreateResponseHandle( auto handle = new FlutterPlatformMessageResponseHandle(); - handle->message = fml::MakeRefCounted( + handle->message = std::make_unique( "", // The channel is empty and unused as the response handle is going // to referenced directly in the |FlutterEngineSendPlatformMessage| // with the container message discarded. @@ -1958,7 +1958,7 @@ static bool DispatchJSONPlatformMessage(FLUTTER_API_SYMBOL(FlutterEngine) return false; } - auto platform_message = fml::MakeRefCounted( + auto platform_message = std::make_unique( channel_name.c_str(), // channel std::vector{message, message + buffer.GetSize()}, // message nullptr // response diff --git a/shell/platform/embedder/embedder_engine.cc b/shell/platform/embedder/embedder_engine.cc index 0b0adf8793f63..f179130e27ad5 100644 --- a/shell/platform/embedder/embedder_engine.cc +++ b/shell/platform/embedder/embedder_engine.cc @@ -144,7 +144,7 @@ bool EmbedderEngine::DispatchKeyDataPacket( } bool EmbedderEngine::SendPlatformMessage( - fml::RefPtr message) { + std::unique_ptr message) { if (!IsValid() || !message) { return false; } @@ -154,7 +154,7 @@ bool EmbedderEngine::SendPlatformMessage( return false; } - platform_view->DispatchPlatformMessage(message); + platform_view->DispatchPlatformMessage(std::move(message)); return true; } diff --git a/shell/platform/embedder/embedder_engine.h b/shell/platform/embedder/embedder_engine.h index ab0de7b1f1d1b..a2b0e398fd599 100644 --- a/shell/platform/embedder/embedder_engine.h +++ b/shell/platform/embedder/embedder_engine.h @@ -68,7 +68,7 @@ class EmbedderEngine { bool DispatchKeyDataPacket(std::unique_ptr packet, KeyDataResponse callback); - bool SendPlatformMessage(fml::RefPtr message); + bool SendPlatformMessage(std::unique_ptr message); bool RegisterTexture(int64_t texture); diff --git a/shell/platform/embedder/platform_view_embedder.cc b/shell/platform/embedder/platform_view_embedder.cc index 0e566f3782aad..2cd020719944d 100644 --- a/shell/platform/embedder/platform_view_embedder.cc +++ b/shell/platform/embedder/platform_view_embedder.cc @@ -65,7 +65,7 @@ void PlatformViewEmbedder::UpdateSemantics( } void PlatformViewEmbedder::HandlePlatformMessage( - fml::RefPtr message) { + std::unique_ptr message) { if (!message) { return; } diff --git a/shell/platform/embedder/platform_view_embedder.h b/shell/platform/embedder/platform_view_embedder.h index e3d89c527869b..3ecc634b46b71 100644 --- a/shell/platform/embedder/platform_view_embedder.h +++ b/shell/platform/embedder/platform_view_embedder.h @@ -32,7 +32,7 @@ class PlatformViewEmbedder final : public PlatformView { using UpdateSemanticsCustomActionsCallback = std::function; using PlatformMessageResponseCallback = - std::function)>; + std::function)>; using ComputePlatformResolvedLocaleCallback = std::function>( const std::vector& supported_locale_data)>; @@ -85,8 +85,7 @@ class PlatformViewEmbedder final : public PlatformView { flutter::CustomAccessibilityActionUpdates actions) override; // |PlatformView| - void HandlePlatformMessage( - fml::RefPtr message) override; + void HandlePlatformMessage(std::unique_ptr message) override; private: std::shared_ptr external_view_embedder_; diff --git a/shell/platform/fuchsia/flutter/engine.cc b/shell/platform/fuchsia/flutter/engine.cc index 13018e75079fb..20f0417688de7 100644 --- a/shell/platform/fuchsia/flutter/engine.cc +++ b/shell/platform/fuchsia/flutter/engine.cc @@ -50,9 +50,9 @@ void UpdateNativeThreadLabelNames(const std::string& label, set_thread_name(runners.GetIOTaskRunner(), label, ".io"); } -fml::RefPtr MakeLocalizationPlatformMessage( +std::unique_ptr MakeLocalizationPlatformMessage( const fuchsia::intl::Profile& intl_profile) { - return fml::MakeRefCounted( + return std::make_unique( "flutter/localization", MakeLocalizationPlatformMessageData(intl_profile), nullptr); } @@ -402,7 +402,7 @@ Engine::Engine(Delegate& delegate, auto message = MakeLocalizationPlatformMessage(profile); FML_VLOG(-1) << "Sending LocalizationPlatformMessage"; flutter_runner_engine->shell_->GetPlatformView()->DispatchPlatformMessage( - message); + std::move(message)); }; FML_VLOG(-1) << "Requesting intl Profile"; diff --git a/shell/platform/fuchsia/flutter/fuchsia_intl.h b/shell/platform/fuchsia/flutter/fuchsia_intl.h index df099d76acd18..349d6c516cd49 100644 --- a/shell/platform/fuchsia/flutter/fuchsia_intl.h +++ b/shell/platform/fuchsia/flutter/fuchsia_intl.h @@ -12,7 +12,7 @@ namespace flutter_runner { // Make a byte vector containing the JSON string used for a localization // PlatformMessage, using the locale list in the given Profile. // -// This method does not return a `fml::RefPtr` for +// This method does not return a `std::unique_ptr` for // testing convenience; that would require an unreasonably large set of // dependencies for the unit tests. std::vector MakeLocalizationPlatformMessageData( diff --git a/shell/platform/fuchsia/flutter/platform_view.cc b/shell/platform/fuchsia/flutter/platform_view.cc index 66a276144810a..4cd0515663cfc 100644 --- a/shell/platform/fuchsia/flutter/platform_view.cc +++ b/shell/platform/fuchsia/flutter/platform_view.cc @@ -176,7 +176,7 @@ void PlatformView::DidUpdateState( document.Accept(writer); const uint8_t* data = reinterpret_cast(buffer.GetString()); - DispatchPlatformMessage(fml::MakeRefCounted( + DispatchPlatformMessage(std::make_unique( kTextInputChannel, // channel std::vector(data, data + buffer.GetSize()), // message nullptr) // response @@ -206,7 +206,7 @@ void PlatformView::OnAction(fuchsia::ui::input::InputMethodAction action) { document.Accept(writer); const uint8_t* data = reinterpret_cast(buffer.GetString()); - DispatchPlatformMessage(fml::MakeRefCounted( + DispatchPlatformMessage(std::make_unique( kTextInputChannel, // channel std::vector(data, data + buffer.GetSize()), // message nullptr) // response @@ -443,11 +443,11 @@ bool PlatformView::OnChildViewConnected(scenic::ResourceId view_holder_id) { << "}"; auto call = out.str(); - fml::RefPtr message = - fml::MakeRefCounted( + std::unique_ptr message = + std::make_unique( "flutter/platform_views", std::vector(call.begin(), call.end()), nullptr); - DispatchPlatformMessage(message); + DispatchPlatformMessage(std::move(message)); return true; } @@ -467,11 +467,11 @@ bool PlatformView::OnChildViewDisconnected(scenic::ResourceId view_holder_id) { << "}"; auto call = out.str(); - fml::RefPtr message = - fml::MakeRefCounted( + std::unique_ptr message = + std::make_unique( "flutter/platform_views", std::vector(call.begin(), call.end()), nullptr); - DispatchPlatformMessage(message); + DispatchPlatformMessage(std::move(message)); return true; } @@ -494,11 +494,11 @@ bool PlatformView::OnChildViewStateChanged(scenic::ResourceId view_holder_id, << "}"; auto call = out.str(); - fml::RefPtr message = - fml::MakeRefCounted( + std::unique_ptr message = + std::make_unique( "flutter/platform_views", std::vector(call.begin(), call.end()), nullptr); - DispatchPlatformMessage(message); + DispatchPlatformMessage(std::move(message)); return true; } @@ -645,7 +645,7 @@ void PlatformView::OnKeyEvent( document.Accept(writer); const uint8_t* data = reinterpret_cast(buffer.GetString()); - DispatchPlatformMessage(fml::MakeRefCounted( + DispatchPlatformMessage(std::make_unique( kKeyEventChannel, // channel std::vector(data, data + buffer.GetSize()), // data nullptr) // response @@ -707,7 +707,7 @@ PlatformView::CreateExternalViewEmbedder() { // |flutter::PlatformView| void PlatformView::HandlePlatformMessage( - fml::RefPtr message) { + std::unique_ptr message) { if (!message) { return; } @@ -760,7 +760,7 @@ void PlatformView::UpdateSemantics( // Channel handler for kAccessibilityChannel void PlatformView::HandleAccessibilityChannelPlatformMessage( - fml::RefPtr message) { + std::unique_ptr message) { FML_DCHECK(message->channel() == kAccessibilityChannel); const flutter::StandardMessageCodec& standard_message_codec = @@ -785,7 +785,7 @@ void PlatformView::HandleAccessibilityChannelPlatformMessage( // Channel handler for kFlutterPlatformChannel void PlatformView::HandleFlutterPlatformChannelPlatformMessage( - fml::RefPtr message) { + std::unique_ptr message) { FML_DCHECK(message->channel() == kFlutterPlatformChannel); const auto& data = message->data(); rapidjson::Document document; @@ -806,7 +806,7 @@ void PlatformView::HandleFlutterPlatformChannelPlatformMessage( // Channel handler for kTextInputChannel void PlatformView::HandleFlutterTextInputChannelPlatformMessage( - fml::RefPtr message) { + std::unique_ptr message) { FML_DCHECK(message->channel() == kTextInputChannel); const auto& data = message->data(); rapidjson::Document document; @@ -896,7 +896,7 @@ void PlatformView::HandleFlutterTextInputChannelPlatformMessage( } void PlatformView::HandleFlutterPlatformViewsChannelPlatformMessage( - fml::RefPtr message) { + std::unique_ptr message) { FML_DCHECK(message->channel() == kFlutterPlatformViewsChannel); const auto& data = message->data(); rapidjson::Document document; @@ -1067,8 +1067,8 @@ void PlatformView::HandleFlutterPlatformViewsChannelPlatformMessage( }); focuser_->RequestFocus( std::move(ref), - [view_ref = view_ref->value.GetUint64(), - message](fuchsia::ui::views::Focuser_RequestFocus_Result result) { + [view_ref = view_ref->value.GetUint64(), message = std::move(message)]( + fuchsia::ui::views::Focuser_RequestFocus_Result result) { if (message->response().get()) { int result_code = result.is_err() diff --git a/shell/platform/fuchsia/flutter/platform_view.h b/shell/platform/fuchsia/flutter/platform_view.h index 6cf1c345602ef..2b69a42ec17e6 100644 --- a/shell/platform/fuchsia/flutter/platform_view.h +++ b/shell/platform/fuchsia/flutter/platform_view.h @@ -139,7 +139,7 @@ class PlatformView final : public flutter::PlatformView, // |flutter::PlatformView| void HandlePlatformMessage( - fml::RefPtr message) override; + std::unique_ptr message) override; // |flutter::PlatformView| void UpdateSemantics( @@ -150,19 +150,19 @@ class PlatformView final : public flutter::PlatformView, // being used, but it is necessary to handle accessibility messages // that are sent by Flutter when semantics is enabled. void HandleAccessibilityChannelPlatformMessage( - fml::RefPtr message); + std::unique_ptr message); // Channel handler for kFlutterPlatformChannel void HandleFlutterPlatformChannelPlatformMessage( - fml::RefPtr message); + std::unique_ptr message); // Channel handler for kTextInputChannel void HandleFlutterTextInputChannelPlatformMessage( - fml::RefPtr message); + std::unique_ptr message); // Channel handler for kPlatformViewsChannel. void HandleFlutterPlatformViewsChannelPlatformMessage( - fml::RefPtr message); + std::unique_ptr message); const std::string debug_label_; // TODO(MI4-2490): remove once ViewRefControl is passed to Scenic and kept @@ -207,10 +207,10 @@ class PlatformView final : public flutter::PlatformView, std::unique_ptr last_text_state_; std::set down_pointers_; - std::map< - std::string /* channel */, - fit::function /* message */)> /* handler */> + std::map /* message */)> /* handler */> platform_message_handlers_; // These are the channels that aren't registered and have been notified as // such. Notifying via logs multiple times results in log-spam. See: diff --git a/shell/platform/fuchsia/flutter/platform_view_unittest.cc b/shell/platform/fuchsia/flutter/platform_view_unittest.cc index 3873081ddbab6..acee256d0b58e 100644 --- a/shell/platform/fuchsia/flutter/platform_view_unittest.cc +++ b/shell/platform/fuchsia/flutter/platform_view_unittest.cc @@ -83,7 +83,7 @@ class MockPlatformViewDelegate : public flutter::PlatformView::Delegate { } // |flutter::PlatformView::Delegate| void OnPlatformViewDispatchPlatformMessage( - fml::RefPtr message) { + std::unique_ptr message) { message_ = std::move(message); } // |flutter::PlatformView::Delegate| @@ -139,7 +139,7 @@ class MockPlatformViewDelegate : public flutter::PlatformView::Delegate { private: std::unique_ptr surface_; - fml::RefPtr message_; + std::unique_ptr message_; flutter::ViewportMetrics metrics_; int32_t semantics_features_ = 0; bool semantics_enabled_ = false; @@ -568,12 +568,12 @@ TEST_F(PlatformViewTests, EnableWireframeTest) { " }" "}"; - fml::RefPtr message = - fml::MakeRefCounted( + std::unique_ptr message = + std::make_unique( "flutter/platform_views", std::vector(txt, txt + sizeof(txt)), fml::RefPtr()); - base_view->HandlePlatformMessage(message); + base_view->HandlePlatformMessage(std::move(message)); RunLoopUntilIdle(); @@ -628,12 +628,12 @@ TEST_F(PlatformViewTests, CreateViewTest) { " }" "}"; - fml::RefPtr message = - fml::MakeRefCounted( + std::unique_ptr message = + std::make_unique( "flutter/platform_views", std::vector(txt, txt + sizeof(txt)), fml::RefPtr()); - base_view->HandlePlatformMessage(message); + base_view->HandlePlatformMessage(std::move(message)); RunLoopUntilIdle(); @@ -678,12 +678,12 @@ TEST_F(PlatformViewTests, UpdateViewTest) { " }" "}"; - fml::RefPtr message = - fml::MakeRefCounted( + std::unique_ptr message = + std::make_unique( "flutter/platform_views", std::vector(txt, txt + sizeof(txt)), fml::RefPtr()); - base_view->HandlePlatformMessage(message); + base_view->HandlePlatformMessage(std::move(message)); RunLoopUntilIdle(); @@ -735,12 +735,12 @@ TEST_F(PlatformViewTests, DestroyViewTest) { " }" "}"; - fml::RefPtr message = - fml::MakeRefCounted( + std::unique_ptr message = + std::make_unique( "flutter/platform_views", std::vector(txt, txt + sizeof(txt)), fml::RefPtr()); - base_view->HandlePlatformMessage(message); + base_view->HandlePlatformMessage(std::move(message)); RunLoopUntilIdle(); @@ -797,7 +797,7 @@ TEST_F(PlatformViewTests, ViewEventsTest) { << "}"; std::string create_view_call = create_view_message.str(); static_cast(&platform_view) - ->HandlePlatformMessage(fml::MakeRefCounted( + ->HandlePlatformMessage(std::make_unique( "flutter/platform_views", std::vector(create_view_call.begin(), create_view_call.end()), @@ -935,11 +935,11 @@ TEST_F(PlatformViewTests, RequestFocusTest) { EXPECT_CALL(*response, Complete(::testing::_)) .WillOnce(::testing::Invoke(&data_arg, &DataArg::Complete)); - fml::RefPtr message = - fml::MakeRefCounted( + std::unique_ptr message = + std::make_unique( "flutter/platform_views", std::vector(buff, buff + sizeof(buff)), response); - base_view->HandlePlatformMessage(message); + base_view->HandlePlatformMessage(std::move(message)); RunLoopUntilIdle(); @@ -998,11 +998,11 @@ TEST_F(PlatformViewTests, RequestFocusFailTest) { EXPECT_CALL(*response, Complete(::testing::_)) .WillOnce(::testing::Invoke(&data_arg, &DataArg::Complete)); - fml::RefPtr message = - fml::MakeRefCounted( + std::unique_ptr message = + std::make_unique( "flutter/platform_views", std::vector(buff, buff + sizeof(buff)), response); - base_view->HandlePlatformMessage(message); + base_view->HandlePlatformMessage(std::move(message)); RunLoopUntilIdle(); diff --git a/shell/testing/tester_main.cc b/shell/testing/tester_main.cc index 35ce2bf1ef1fd..bd751ca8ed46c 100644 --- a/shell/testing/tester_main.cc +++ b/shell/testing/tester_main.cc @@ -258,8 +258,8 @@ int RunTester(const flutter::Settings& settings, locale_json + std::strlen(locale_json)); fml::RefPtr response; shell->GetPlatformView()->DispatchPlatformMessage( - fml::MakeRefCounted("flutter/localization", - locale_bytes, response)); + std::make_unique("flutter/localization", + locale_bytes, response)); std::initializer_list protection = { fml::FileMapping::Protection::kRead};