From a654c1625e302170ab1f173e234dbe6be46c40a7 Mon Sep 17 00:00:00 2001 From: schectman Date: Fri, 17 Mar 2023 16:38:53 -0400 Subject: [PATCH 1/6] Communicate exit request --- shell/platform/windows/platform_handler.cc | 57 +++++++++++++++++++++- shell/platform/windows/platform_handler.h | 13 +++++ 2 files changed, 69 insertions(+), 1 deletion(-) diff --git a/shell/platform/windows/platform_handler.cc b/shell/platform/windows/platform_handler.cc index 4c54b3d4cf09b..cf2e2607b799a 100644 --- a/shell/platform/windows/platform_handler.cc +++ b/shell/platform/windows/platform_handler.cc @@ -12,6 +12,7 @@ #include "flutter/fml/logging.h" #include "flutter/fml/macros.h" #include "flutter/fml/platform/win/wstring_conversion.h" +#include "flutter/shell/platform/common/client_wrapper/include/flutter/method_result_functions.h" #include "flutter/shell/platform/common/json_method_codec.h" #include "flutter/shell/platform/windows/flutter_windows_view.h" @@ -20,8 +21,20 @@ static constexpr char kChannelName[] = "flutter/platform"; static constexpr char kGetClipboardDataMethod[] = "Clipboard.getData"; static constexpr char kHasStringsClipboardMethod[] = "Clipboard.hasStrings"; static constexpr char kSetClipboardDataMethod[] = "Clipboard.setData"; +static constexpr char kExitApplicationMethod[] = "System.exitApplication"; +static constexpr char kRequestAppExitMethod[] = "System.requestAppExit"; static constexpr char kPlaySoundMethod[] = "SystemSound.play"; +static constexpr char kExitCodeKey[] = "exitCode"; + +static constexpr char kExitTypeKey[] = "type"; +static constexpr char kExitTypeCancelable[] = "cancelable"; +static constexpr char kExitTypeRequired[] = "required"; + +static constexpr char kExitResponseKey[] = "response"; +static constexpr char kExitResponseCancel[] = "cancel"; +static constexpr char kExitResponseExit[] = "exit"; + static constexpr char kTextPlainFormat[] = "text/plain"; static constexpr char kTextKey[] = "text"; static constexpr char kUnknownClipboardFormatMessage[] = @@ -340,11 +353,53 @@ void PlatformHandler::SystemSoundPlay( } } +void PlatformHandler::SystemExitApplication( + const std::string& exit_type, + int64_t exit_code, + std::unique_ptr> result) { + rapidjson::Document result_doc; + result_doc.SetObject(); + if (exit_type.compare(kExitTypeRequired) == 0) { + QuitApplication(exit_code); + result_doc.GetObjectW().AddMember(kExitResponseKey, kExitResponseExit, result_doc.GetAllocator()); + result->Success(result_doc); + } + else { + RequestAppExit(exit_type); + result_doc.GetObjectW().AddMember(kExitResponseKey, kExitResponseCancel, result_doc.GetAllocator()); + result->Success(result_doc); + } +} + +void PlatformHandler::RequestAppExit(const std::string& exit_type) { + auto callback = std::make_unique>([this](const rapidjson::Document* response) { RequestAppExitSuccess(response); }, nullptr, nullptr); + auto args = std::make_unique(); + args->SetObject(); + args->GetObjectW().AddMember(kExitTypeKey, exit_type, args->GetAllocator()); + channel_->InvokeMethod(kRequestAppExitMethod, std::move(args), std::move(callback)); +} + +void PlatformHandler::RequestAppExitSuccess(const rapidjson::Document* result) { + const std::string& exit_type = result[0][kExitResponseKey].GetString(); + if (exit_type.compare(kExitResponseExit) == 0) { + QuitApplication(0); + } +} + +void PlatformHandler::QuitApplication(int64_t exit_code) { + PostQuitMessage(exit_code); +} + void PlatformHandler::HandleMethodCall( const MethodCall& method_call, std::unique_ptr> result) { const std::string& method = method_call.method_name(); - if (method.compare(kGetClipboardDataMethod) == 0) { + if (method.compare(kExitApplicationMethod) == 0) { + const rapidjson::Value& arguments = method_call.arguments()[0]; + const std::string& exit_type = arguments[kExitTypeKey].GetString(); + int64_t exit_code = arguments[kExitCodeKey].GetInt64(); + SystemExitApplication(exit_type, exit_code, std::move(result)); + } else if (method.compare(kGetClipboardDataMethod) == 0) { // Only one string argument is expected. const rapidjson::Value& format = method_call.arguments()[0]; diff --git a/shell/platform/windows/platform_handler.h b/shell/platform/windows/platform_handler.h index 35f1cef14ff79..a5204d6421b5b 100644 --- a/shell/platform/windows/platform_handler.h +++ b/shell/platform/windows/platform_handler.h @@ -55,6 +55,19 @@ class PlatformHandler { const std::string& sound_type, std::unique_ptr> result); + virtual void SystemExitApplication( + const std::string& exit_type, + int64_t exit_code, + std::unique_ptr> result); + + virtual void QuitApplication(int64_t exit_code); + + virtual void RequestAppExit(const std::string& exit_type); + + virtual void RequestAppExitSuccess(const rapidjson::Document* result); + + + // A error type to use for error responses. static constexpr char kClipboardError[] = "Clipboard error"; From f0cc7c103cee2f045fb6e364073decd23e155963 Mon Sep 17 00:00:00 2001 From: schectman Date: Fri, 17 Mar 2023 17:17:59 -0400 Subject: [PATCH 2/6] Unit test exit message --- shell/platform/windows/platform_handler.cc | 7 ++- shell/platform/windows/platform_handler.h | 2 + .../windows/platform_handler_unittests.cc | 63 +++++++++++++++++++ 3 files changed, 70 insertions(+), 2 deletions(-) diff --git a/shell/platform/windows/platform_handler.cc b/shell/platform/windows/platform_handler.cc index cf2e2607b799a..ab3740bd31c8d 100644 --- a/shell/platform/windows/platform_handler.cc +++ b/shell/platform/windows/platform_handler.cc @@ -214,7 +214,8 @@ PlatformHandler::PlatformHandler( messenger, kChannelName, &JsonMethodCodec::GetInstance())), - engine_(engine) { + engine_(engine), + exit_code_(std::nullopt) { channel_->SetMethodCallHandler( [this](const MethodCall& call, std::unique_ptr> result) { @@ -365,6 +366,7 @@ void PlatformHandler::SystemExitApplication( result->Success(result_doc); } else { + exit_code_ = exit_code; RequestAppExit(exit_type); result_doc.GetObjectW().AddMember(kExitResponseKey, kExitResponseCancel, result_doc.GetAllocator()); result->Success(result_doc); @@ -382,8 +384,9 @@ void PlatformHandler::RequestAppExit(const std::string& exit_type) { void PlatformHandler::RequestAppExitSuccess(const rapidjson::Document* result) { const std::string& exit_type = result[0][kExitResponseKey].GetString(); if (exit_type.compare(kExitResponseExit) == 0) { - QuitApplication(0); + QuitApplication(*exit_code_); } + exit_code_ = std::nullopt; } void PlatformHandler::QuitApplication(int64_t exit_code) { diff --git a/shell/platform/windows/platform_handler.h b/shell/platform/windows/platform_handler.h index a5204d6421b5b..31326afdd1cd3 100644 --- a/shell/platform/windows/platform_handler.h +++ b/shell/platform/windows/platform_handler.h @@ -91,6 +91,8 @@ class PlatformHandler { std::function()> scoped_clipboard_provider_; + std::optional exit_code_; + FML_DISALLOW_COPY_AND_ASSIGN(PlatformHandler); }; diff --git a/shell/platform/windows/platform_handler_unittests.cc b/shell/platform/windows/platform_handler_unittests.cc index 71f383ae738e7..7ec66c72d4821 100644 --- a/shell/platform/windows/platform_handler_unittests.cc +++ b/shell/platform/windows/platform_handler_unittests.cc @@ -43,6 +43,14 @@ static constexpr char kClipboardSetDataUnknownTypeMessage[] = "{\"method\":\"Clipboard.setData\",\"args\":{\"madeuptype\":\"hello\"}}"; static constexpr char kSystemSoundTypeAlertMessage[] = "{\"method\":\"SystemSound.play\",\"args\":\"SystemSoundType.alert\"}"; +static constexpr char kSystemExitApplicationRequiredMessage[] = + "{\"method\":\"System.exitApplication\",\"args\":{\"type\":\"required\",\"exitCode\":1}}"; +static constexpr char kSystemExitApplicationCancelableMessage[] = + "{\"method\":\"System.exitApplication\",\"args\":{\"type\":\"cancelable\",\"exitCode\":2}}"; +static constexpr char kExitResponseCancelMessage[] = + "[{\"response\":\"cancel\"}]"; +static constexpr char kExitResponseExitMessage[] = + "[{\"response\":\"exit\"}]"; static constexpr int kAccessDeniedErrorCode = 5; static constexpr int kErrorSuccess = 0; @@ -73,6 +81,8 @@ class MockPlatformHandler : public PlatformHandler { void(const std::string&, std::unique_ptr>)); + MOCK_METHOD1(QuitApplication, void(int64_t exit_code)); + private: FML_DISALLOW_COPY_AND_ASSIGN(MockPlatformHandler); }; @@ -470,5 +480,58 @@ TEST_F(PlatformHandlerTest, PlaySystemSound) { EXPECT_EQ(result, "[null]"); } +TEST_F(PlatformHandlerTest, SystemExitApplicationRequired) { + use_headless_engine(); + int exit_code = -1; + + TestBinaryMessenger messenger([](const std::string& channel, const uint8_t* message, size_t size, BinaryReply reply) { + } ); + MockPlatformHandler platform_handler(&messenger, engine()); + + ON_CALL(platform_handler, QuitApplication).WillByDefault([&exit_code](int ec) {exit_code = ec;}); + EXPECT_CALL(platform_handler, QuitApplication).Times(1); + + std::string result = SimulatePlatformMessage(&messenger, kSystemExitApplicationRequiredMessage); + EXPECT_EQ(result, "[{\"response\":\"exit\"}]"); + EXPECT_EQ(exit_code, 1); +} + +TEST_F(PlatformHandlerTest, SystemExitApplicationCancelableCancel) { + use_headless_engine(); + bool called_cancel = false; + + TestBinaryMessenger messenger([&called_cancel](const std::string& channel, const uint8_t* message, size_t size, BinaryReply reply) { + reply(reinterpret_cast(kExitResponseCancelMessage), sizeof(kExitResponseCancelMessage)); + called_cancel = true; + } ); + MockPlatformHandler platform_handler(&messenger, engine()); + + EXPECT_CALL(platform_handler, QuitApplication).Times(0); + + std::string result = SimulatePlatformMessage(&messenger, kSystemExitApplicationCancelableMessage); + EXPECT_EQ(result, "[{\"response\":\"cancel\"}]"); + EXPECT_TRUE(called_cancel); +} + +TEST_F(PlatformHandlerTest, SystemExitApplicationCancelableExit) { + use_headless_engine(); + bool called_cancel = false; + int exit_code = -1; + + TestBinaryMessenger messenger([&called_cancel](const std::string& channel, const uint8_t* message, size_t size, BinaryReply reply) { + reply(reinterpret_cast(kExitResponseExitMessage), sizeof(kExitResponseExitMessage)); + called_cancel = true; + } ); + MockPlatformHandler platform_handler(&messenger, engine()); + + ON_CALL(platform_handler, QuitApplication).WillByDefault([&exit_code](int ec) {exit_code = ec;}); + EXPECT_CALL(platform_handler, QuitApplication).Times(1); + + std::string result = SimulatePlatformMessage(&messenger, kSystemExitApplicationCancelableMessage); + EXPECT_EQ(result, "[{\"response\":\"cancel\"}]"); + EXPECT_TRUE(called_cancel); + EXPECT_EQ(exit_code, 2); +} + } // namespace testing } // namespace flutter From 5039aab87f692d8fd2b2aa9df5a5125de7810b48 Mon Sep 17 00:00:00 2001 From: schectman Date: Fri, 17 Mar 2023 17:29:58 -0400 Subject: [PATCH 3/6] Comments --- shell/platform/windows/platform_handler.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/shell/platform/windows/platform_handler.h b/shell/platform/windows/platform_handler.h index 31326afdd1cd3..2fb94eb25ab86 100644 --- a/shell/platform/windows/platform_handler.h +++ b/shell/platform/windows/platform_handler.h @@ -55,15 +55,21 @@ class PlatformHandler { const std::string& sound_type, std::unique_ptr> result); + // Handle a request from the framework to exit the application. virtual void SystemExitApplication( const std::string& exit_type, int64_t exit_code, std::unique_ptr> result); + // Actually quit the application with the provided exit code. virtual void QuitApplication(int64_t exit_code); + // Send a request to the framework to test if a cancelable exit request + // should be canceled or honored. virtual void RequestAppExit(const std::string& exit_type); + // Callback from when the cancelable exit request response request is + // answered by the framework. virtual void RequestAppExitSuccess(const rapidjson::Document* result); @@ -91,6 +97,9 @@ class PlatformHandler { std::function()> scoped_clipboard_provider_; + // Store the exit code of the currently executing exit request, if a request + // must also be sent back to the framework. Cleared to nullopt when the + // request completes. std::optional exit_code_; FML_DISALLOW_COPY_AND_ASSIGN(PlatformHandler); From a3a5ec0e5733a04eee2cf09c4c0343909fb89b8a Mon Sep 17 00:00:00 2001 From: schectman Date: Fri, 17 Mar 2023 17:55:24 -0400 Subject: [PATCH 4/6] Formatting --- shell/platform/windows/platform_handler.cc | 18 ++++--- shell/platform/windows/platform_handler.h | 8 ++- .../windows/platform_handler_unittests.cc | 51 ++++++++++++------- 3 files changed, 47 insertions(+), 30 deletions(-) diff --git a/shell/platform/windows/platform_handler.cc b/shell/platform/windows/platform_handler.cc index ab3740bd31c8d..673e348a8eb6a 100644 --- a/shell/platform/windows/platform_handler.cc +++ b/shell/platform/windows/platform_handler.cc @@ -362,23 +362,29 @@ void PlatformHandler::SystemExitApplication( result_doc.SetObject(); if (exit_type.compare(kExitTypeRequired) == 0) { QuitApplication(exit_code); - result_doc.GetObjectW().AddMember(kExitResponseKey, kExitResponseExit, result_doc.GetAllocator()); + result_doc.GetObjectW().AddMember(kExitResponseKey, kExitResponseExit, + result_doc.GetAllocator()); result->Success(result_doc); - } - else { + } else { exit_code_ = exit_code; RequestAppExit(exit_type); - result_doc.GetObjectW().AddMember(kExitResponseKey, kExitResponseCancel, result_doc.GetAllocator()); + result_doc.GetObjectW().AddMember(kExitResponseKey, kExitResponseCancel, + result_doc.GetAllocator()); result->Success(result_doc); } } void PlatformHandler::RequestAppExit(const std::string& exit_type) { - auto callback = std::make_unique>([this](const rapidjson::Document* response) { RequestAppExitSuccess(response); }, nullptr, nullptr); + auto callback = std::make_unique>( + [this](const rapidjson::Document* response) { + RequestAppExitSuccess(response); + }, + nullptr, nullptr); auto args = std::make_unique(); args->SetObject(); args->GetObjectW().AddMember(kExitTypeKey, exit_type, args->GetAllocator()); - channel_->InvokeMethod(kRequestAppExitMethod, std::move(args), std::move(callback)); + channel_->InvokeMethod(kRequestAppExitMethod, std::move(args), + std::move(callback)); } void PlatformHandler::RequestAppExitSuccess(const rapidjson::Document* result) { diff --git a/shell/platform/windows/platform_handler.h b/shell/platform/windows/platform_handler.h index 2fb94eb25ab86..c0d385f3afb05 100644 --- a/shell/platform/windows/platform_handler.h +++ b/shell/platform/windows/platform_handler.h @@ -57,9 +57,9 @@ class PlatformHandler { // Handle a request from the framework to exit the application. virtual void SystemExitApplication( - const std::string& exit_type, - int64_t exit_code, - std::unique_ptr> result); + const std::string& exit_type, + int64_t exit_code, + std::unique_ptr> result); // Actually quit the application with the provided exit code. virtual void QuitApplication(int64_t exit_code); @@ -72,8 +72,6 @@ class PlatformHandler { // answered by the framework. virtual void RequestAppExitSuccess(const rapidjson::Document* result); - - // A error type to use for error responses. static constexpr char kClipboardError[] = "Clipboard error"; diff --git a/shell/platform/windows/platform_handler_unittests.cc b/shell/platform/windows/platform_handler_unittests.cc index 7ec66c72d4821..85d4f5a9a9713 100644 --- a/shell/platform/windows/platform_handler_unittests.cc +++ b/shell/platform/windows/platform_handler_unittests.cc @@ -44,13 +44,14 @@ static constexpr char kClipboardSetDataUnknownTypeMessage[] = static constexpr char kSystemSoundTypeAlertMessage[] = "{\"method\":\"SystemSound.play\",\"args\":\"SystemSoundType.alert\"}"; static constexpr char kSystemExitApplicationRequiredMessage[] = - "{\"method\":\"System.exitApplication\",\"args\":{\"type\":\"required\",\"exitCode\":1}}"; + "{\"method\":\"System.exitApplication\",\"args\":{\"type\":\"required\"," + "\"exitCode\":1}}"; static constexpr char kSystemExitApplicationCancelableMessage[] = - "{\"method\":\"System.exitApplication\",\"args\":{\"type\":\"cancelable\",\"exitCode\":2}}"; + "{\"method\":\"System.exitApplication\",\"args\":{\"type\":\"cancelable\"," + "\"exitCode\":2}}"; static constexpr char kExitResponseCancelMessage[] = "[{\"response\":\"cancel\"}]"; -static constexpr char kExitResponseExitMessage[] = - "[{\"response\":\"exit\"}]"; +static constexpr char kExitResponseExitMessage[] = "[{\"response\":\"exit\"}]"; static constexpr int kAccessDeniedErrorCode = 5; static constexpr int kErrorSuccess = 0; @@ -484,14 +485,17 @@ TEST_F(PlatformHandlerTest, SystemExitApplicationRequired) { use_headless_engine(); int exit_code = -1; - TestBinaryMessenger messenger([](const std::string& channel, const uint8_t* message, size_t size, BinaryReply reply) { - } ); + TestBinaryMessenger messenger([](const std::string& channel, + const uint8_t* message, size_t size, + BinaryReply reply) {}); MockPlatformHandler platform_handler(&messenger, engine()); - ON_CALL(platform_handler, QuitApplication).WillByDefault([&exit_code](int ec) {exit_code = ec;}); + ON_CALL(platform_handler, QuitApplication) + .WillByDefault([&exit_code](int ec) { exit_code = ec; }); EXPECT_CALL(platform_handler, QuitApplication).Times(1); - std::string result = SimulatePlatformMessage(&messenger, kSystemExitApplicationRequiredMessage); + std::string result = SimulatePlatformMessage( + &messenger, kSystemExitApplicationRequiredMessage); EXPECT_EQ(result, "[{\"response\":\"exit\"}]"); EXPECT_EQ(exit_code, 1); } @@ -500,15 +504,19 @@ TEST_F(PlatformHandlerTest, SystemExitApplicationCancelableCancel) { use_headless_engine(); bool called_cancel = false; - TestBinaryMessenger messenger([&called_cancel](const std::string& channel, const uint8_t* message, size_t size, BinaryReply reply) { - reply(reinterpret_cast(kExitResponseCancelMessage), sizeof(kExitResponseCancelMessage)); - called_cancel = true; - } ); + TestBinaryMessenger messenger( + [&called_cancel](const std::string& channel, const uint8_t* message, + size_t size, BinaryReply reply) { + reply(reinterpret_cast(kExitResponseCancelMessage), + sizeof(kExitResponseCancelMessage)); + called_cancel = true; + }); MockPlatformHandler platform_handler(&messenger, engine()); EXPECT_CALL(platform_handler, QuitApplication).Times(0); - std::string result = SimulatePlatformMessage(&messenger, kSystemExitApplicationCancelableMessage); + std::string result = SimulatePlatformMessage( + &messenger, kSystemExitApplicationCancelableMessage); EXPECT_EQ(result, "[{\"response\":\"cancel\"}]"); EXPECT_TRUE(called_cancel); } @@ -518,16 +526,21 @@ TEST_F(PlatformHandlerTest, SystemExitApplicationCancelableExit) { bool called_cancel = false; int exit_code = -1; - TestBinaryMessenger messenger([&called_cancel](const std::string& channel, const uint8_t* message, size_t size, BinaryReply reply) { - reply(reinterpret_cast(kExitResponseExitMessage), sizeof(kExitResponseExitMessage)); - called_cancel = true; - } ); + TestBinaryMessenger messenger( + [&called_cancel](const std::string& channel, const uint8_t* message, + size_t size, BinaryReply reply) { + reply(reinterpret_cast(kExitResponseExitMessage), + sizeof(kExitResponseExitMessage)); + called_cancel = true; + }); MockPlatformHandler platform_handler(&messenger, engine()); - ON_CALL(platform_handler, QuitApplication).WillByDefault([&exit_code](int ec) {exit_code = ec;}); + ON_CALL(platform_handler, QuitApplication) + .WillByDefault([&exit_code](int ec) { exit_code = ec; }); EXPECT_CALL(platform_handler, QuitApplication).Times(1); - std::string result = SimulatePlatformMessage(&messenger, kSystemExitApplicationCancelableMessage); + std::string result = SimulatePlatformMessage( + &messenger, kSystemExitApplicationCancelableMessage); EXPECT_EQ(result, "[{\"response\":\"cancel\"}]"); EXPECT_TRUE(called_cancel); EXPECT_EQ(exit_code, 2); From 80a383888969666e1b7689a8df66e712edd41309 Mon Sep 17 00:00:00 2001 From: schectman Date: Fri, 17 Mar 2023 18:18:21 -0400 Subject: [PATCH 5/6] Move exit code --- shell/platform/windows/platform_handler.cc | 17 +++++++---------- shell/platform/windows/platform_handler.h | 9 ++------- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/shell/platform/windows/platform_handler.cc b/shell/platform/windows/platform_handler.cc index 673e348a8eb6a..7fdf35cc897b2 100644 --- a/shell/platform/windows/platform_handler.cc +++ b/shell/platform/windows/platform_handler.cc @@ -214,8 +214,7 @@ PlatformHandler::PlatformHandler( messenger, kChannelName, &JsonMethodCodec::GetInstance())), - engine_(engine), - exit_code_(std::nullopt) { + engine_(engine) { channel_->SetMethodCallHandler( [this](const MethodCall& call, std::unique_ptr> result) { @@ -366,18 +365,17 @@ void PlatformHandler::SystemExitApplication( result_doc.GetAllocator()); result->Success(result_doc); } else { - exit_code_ = exit_code; - RequestAppExit(exit_type); + RequestAppExit(exit_type, exit_code); result_doc.GetObjectW().AddMember(kExitResponseKey, kExitResponseCancel, result_doc.GetAllocator()); result->Success(result_doc); } } -void PlatformHandler::RequestAppExit(const std::string& exit_type) { +void PlatformHandler::RequestAppExit(const std::string& exit_type, int64_t exit_code) { auto callback = std::make_unique>( - [this](const rapidjson::Document* response) { - RequestAppExitSuccess(response); + [this, exit_code](const rapidjson::Document* response) { + RequestAppExitSuccess(response, exit_code); }, nullptr, nullptr); auto args = std::make_unique(); @@ -387,12 +385,11 @@ void PlatformHandler::RequestAppExit(const std::string& exit_type) { std::move(callback)); } -void PlatformHandler::RequestAppExitSuccess(const rapidjson::Document* result) { +void PlatformHandler::RequestAppExitSuccess(const rapidjson::Document* result, int64_t exit_code) { const std::string& exit_type = result[0][kExitResponseKey].GetString(); if (exit_type.compare(kExitResponseExit) == 0) { - QuitApplication(*exit_code_); + QuitApplication(exit_code); } - exit_code_ = std::nullopt; } void PlatformHandler::QuitApplication(int64_t exit_code) { diff --git a/shell/platform/windows/platform_handler.h b/shell/platform/windows/platform_handler.h index c0d385f3afb05..6fbaa6fadbc24 100644 --- a/shell/platform/windows/platform_handler.h +++ b/shell/platform/windows/platform_handler.h @@ -66,11 +66,11 @@ class PlatformHandler { // Send a request to the framework to test if a cancelable exit request // should be canceled or honored. - virtual void RequestAppExit(const std::string& exit_type); + virtual void RequestAppExit(const std::string& exit_type, int64_t exit_code); // Callback from when the cancelable exit request response request is // answered by the framework. - virtual void RequestAppExitSuccess(const rapidjson::Document* result); + virtual void RequestAppExitSuccess(const rapidjson::Document* result, int64_t exit_code); // A error type to use for error responses. static constexpr char kClipboardError[] = "Clipboard error"; @@ -95,11 +95,6 @@ class PlatformHandler { std::function()> scoped_clipboard_provider_; - // Store the exit code of the currently executing exit request, if a request - // must also be sent back to the framework. Cleared to nullopt when the - // request completes. - std::optional exit_code_; - FML_DISALLOW_COPY_AND_ASSIGN(PlatformHandler); }; From b0d2d213c72d8677b5a5515151d92d991463e91f Mon Sep 17 00:00:00 2001 From: schectman Date: Mon, 20 Mar 2023 14:00:24 -0400 Subject: [PATCH 6/6] Formatting --- shell/platform/windows/platform_handler.cc | 6 ++++-- shell/platform/windows/platform_handler.h | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/shell/platform/windows/platform_handler.cc b/shell/platform/windows/platform_handler.cc index 7fdf35cc897b2..a33710becbf9d 100644 --- a/shell/platform/windows/platform_handler.cc +++ b/shell/platform/windows/platform_handler.cc @@ -372,7 +372,8 @@ void PlatformHandler::SystemExitApplication( } } -void PlatformHandler::RequestAppExit(const std::string& exit_type, int64_t exit_code) { +void PlatformHandler::RequestAppExit(const std::string& exit_type, + int64_t exit_code) { auto callback = std::make_unique>( [this, exit_code](const rapidjson::Document* response) { RequestAppExitSuccess(response, exit_code); @@ -385,7 +386,8 @@ void PlatformHandler::RequestAppExit(const std::string& exit_type, int64_t exit_ std::move(callback)); } -void PlatformHandler::RequestAppExitSuccess(const rapidjson::Document* result, int64_t exit_code) { +void PlatformHandler::RequestAppExitSuccess(const rapidjson::Document* result, + int64_t exit_code) { const std::string& exit_type = result[0][kExitResponseKey].GetString(); if (exit_type.compare(kExitResponseExit) == 0) { QuitApplication(exit_code); diff --git a/shell/platform/windows/platform_handler.h b/shell/platform/windows/platform_handler.h index 6fbaa6fadbc24..096378db4f414 100644 --- a/shell/platform/windows/platform_handler.h +++ b/shell/platform/windows/platform_handler.h @@ -70,7 +70,8 @@ class PlatformHandler { // Callback from when the cancelable exit request response request is // answered by the framework. - virtual void RequestAppExitSuccess(const rapidjson::Document* result, int64_t exit_code); + virtual void RequestAppExitSuccess(const rapidjson::Document* result, + int64_t exit_code); // A error type to use for error responses. static constexpr char kClipboardError[] = "Clipboard error";