Skip to content

Commit 8a6c885

Browse files
bergeretChromium LUCI CQ
authored and
Chromium LUCI CQ
committed
Change result code for successfully notifying an existing Chrome process
This CL is ensuring the process singleton notified reports an exit code that triggers an early exit. The top-level process exit code is not changing, just one used internally by Chrome (see chrome::IsNormalResultCode). This will early exit in BrowserMain(...) ================ content/browser/browser_main.cc ================ int exit_code = main_runner->Initialize(std::move(parameters)); if (exit_code >= 0) // Will exit here. return exit_code; exit_code = main_runner->Run(); // Skip this phase. main_runner->Shutdown(); ================================================================= The Shutdown(..) call will still be executed since it is called in the BrowserMainRunnerImpl's destructor. [email protected] Bug: 1340599 Change-Id: I063433be71aaefed503cbe559dfe6511e8e55f39 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3735155 Commit-Queue: Etienne Bergeron <[email protected]> Reviewed-by: Scott Violet <[email protected]> Auto-Submit: Etienne Bergeron <[email protected]> Reviewed-by: Trent Apted <[email protected]> Reviewed-by: Gabriel Charette <[email protected]> Cr-Commit-Position: refs/heads/main@{#1035070}
1 parent cf3832c commit 8a6c885

File tree

4 files changed

+7
-12
lines changed

4 files changed

+7
-12
lines changed

apps/DEPS

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ specific_include_rules = {
2020
"+chrome/browser/extensions/test_extension_environment.h",
2121
"+chrome/browser/profiles/profile_manager.h",
2222
"+chrome/browser/ui/simple_message_box_internal.h",
23+
"+chrome/common/chrome_result_codes.h",
2324
"+chrome/common/chrome_switches.h",
2425
"+chrome/test/base/testing_profile.h",
2526
# Temporary allowed testing include.

apps/load_and_launch_browsertest.cc

+3-2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "chrome/browser/extensions/load_error_reporter.h"
2323
#include "chrome/browser/profiles/profile_manager.h"
2424
#include "chrome/browser/ui/simple_message_box_internal.h"
25+
#include "chrome/common/chrome_result_codes.h"
2526
#include "chrome/common/chrome_switches.h"
2627
#include "content/public/common/content_switches.h"
2728
#include "content/public/test/browser_test.h"
@@ -82,7 +83,7 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest,
8283
int exit_code;
8384
ASSERT_TRUE(process.WaitForExitWithTimeout(TestTimeouts::action_timeout(),
8485
&exit_code));
85-
ASSERT_EQ(0, exit_code);
86+
ASSERT_EQ(chrome::RESULT_CODE_NORMAL_EXIT_PROCESS_NOTIFIED, exit_code);
8687
}
8788

8889
// TODO(jackhou): Enable this test once it works on OSX. It currently does not
@@ -124,7 +125,7 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest,
124125
int exit_code;
125126
ASSERT_TRUE(process.WaitForExitWithTimeout(TestTimeouts::action_timeout(),
126127
&exit_code));
127-
ASSERT_EQ(0, exit_code);
128+
ASSERT_EQ(chrome::RESULT_CODE_NORMAL_EXIT_PROCESS_NOTIFIED, exit_code);
128129
}
129130

130131
#endif // !BUILDFLAG(IS_CHROMEOS_LACROS)

chrome/browser/chrome_browser_main.cc

+1-9
Original file line numberDiff line numberDiff line change
@@ -1434,15 +1434,7 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
14341434
base::UTF16ToWide(l10n_util::GetStringUTF16(
14351435
IDS_USED_EXISTING_BROWSER)))
14361436
.c_str());
1437-
1438-
// Having a differentiated return type for testing allows for tests to
1439-
// verify proper handling of some switches. When not testing, stick to
1440-
// the standard Unix convention of returning zero when things went as
1441-
// expected.
1442-
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
1443-
switches::kTestType))
1444-
return chrome::RESULT_CODE_NORMAL_EXIT_PROCESS_NOTIFIED;
1445-
return content::RESULT_CODE_NORMAL_EXIT;
1437+
return chrome::RESULT_CODE_NORMAL_EXIT_PROCESS_NOTIFIED;
14461438

14471439
case ProcessSingleton::PROFILE_IN_USE:
14481440
return chrome::RESULT_CODE_PROFILE_IN_USE;

chrome/common/chrome_result_codes.cc

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ bool IsNormalResultCode(ResultCode code) {
1212
// translated back to the normal exit code to indicate nothing went wrong
1313
// here.
1414
if (code == RESULT_CODE_NORMAL_EXIT_UPGRADE_RELAUNCHED ||
15-
code == RESULT_CODE_NORMAL_EXIT_PACK_EXTENSION_SUCCESS) {
15+
code == RESULT_CODE_NORMAL_EXIT_PACK_EXTENSION_SUCCESS ||
16+
code == RESULT_CODE_NORMAL_EXIT_PROCESS_NOTIFIED) {
1617
return true;
1718
}
1819

0 commit comments

Comments
 (0)