Skip to content

Commit

Permalink
Take two at splitting result codes between content and chrome.
Browse files Browse the repository at this point in the history
content/common/result_codes.h contains only the codes defined in content. chrome/common/chrome_result_codes.h contains the codes defined in chrome and also includes (for convenience) the content header.

R=jam@chromium.org
BUG=76699
TEST=everything compiles

Review URL: http://codereview.chromium.org/7397004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@93082 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
dpranke@chromium.org committed Jul 19, 2011
1 parent b0dee8a commit 1fcfb20
Show file tree
Hide file tree
Showing 38 changed files with 202 additions and 141 deletions.
6 changes: 3 additions & 3 deletions chrome/app/breakpad_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
#include "breakpad/src/client/windows/handler/exception_handler.h"
#include "chrome/app/hard_error_handler_win.h"
#include "chrome/common/child_process_logging.h"
#include "chrome/common/chrome_result_codes.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/env_vars.h"
#include "chrome/installer/util/google_chrome_sxs_distribution.h"
#include "chrome/installer/util/google_update_settings.h"
#include "chrome/installer/util/install_util.h"
#include "content/common/result_codes.h"
#include "policy/policy_constants.h"

namespace {
Expand Down Expand Up @@ -403,7 +403,7 @@ bool WrapMessageBoxWithSEH(const wchar_t* text, const wchar_t* caption,
*exit_now = (IDOK != ::MessageBoxW(NULL, text, caption, flags));
} __except(EXCEPTION_EXECUTE_HANDLER) {
// Its not safe to continue executing, exit silently here.
::ExitProcess(ResultCodes::RESPAWN_FAILED);
::ExitProcess(chrome::RESULT_CODE_RESPAWN_FAILED);
}

return true;
Expand Down Expand Up @@ -452,7 +452,7 @@ extern "C" int __declspec(dllexport) CrashForException(
EXCEPTION_POINTERS* info) {
if (g_breakpad) {
g_breakpad->WriteMinidumpForException(info);
::ExitProcess(ResultCodes::KILLED);
::ExitProcess(content::RESULT_CODE_KILLED);
}
return EXCEPTION_CONTINUE_SEARCH;
}
Expand Down
4 changes: 2 additions & 2 deletions chrome/app/chrome_exe_main_win.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

Expand All @@ -25,7 +25,7 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t*, int) {
// We restarted because of a previous crash. Ask user if we should relaunch.
if (ShowRestartDialogIfCrashed(&exit_now)) {
if (exit_now)
return ResultCodes::NORMAL_EXIT;
return content::RESULT_CODE_NORMAL_EXIT;
}

// Initialize the commandline singleton from the environment.
Expand Down
8 changes: 4 additions & 4 deletions chrome/app/client_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
#include "chrome/app/breakpad_win.h"
#include "chrome/app/client_util.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_result_codes.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/installer/util/browser_distribution.h"
#include "chrome/installer/util/channel_info.h"
#include "chrome/installer/util/install_util.h"
#include "chrome/installer/util/google_update_constants.h"
#include "chrome/installer/util/google_update_settings.h"
#include "chrome/installer/util/util_constants.h"
#include "content/common/result_codes.h"

namespace {
// The entry point signature of chrome.dll.
Expand Down Expand Up @@ -243,7 +243,7 @@ int MainDllLoader::Launch(HINSTANCE instance,
std::wstring file;
dll_ = Load(&version, &file);
if (!dll_)
return ResultCodes::MISSING_DATA;
return chrome::RESULT_CODE_MISSING_DATA;

scoped_ptr<base::Environment> env(base::Environment::Create());
env->SetVar(chrome::kChromeVersionEnvVar, WideToUTF8(version));
Expand All @@ -254,7 +254,7 @@ int MainDllLoader::Launch(HINSTANCE instance,
DLL_MAIN entry_point =
reinterpret_cast<DLL_MAIN>(::GetProcAddress(dll_, "ChromeMain"));
if (!entry_point)
return ResultCodes::BAD_PROCESS_TYPE;
return chrome::RESULT_CODE_BAD_PROCESS_TYPE;

int rc = entry_point(instance, sbox_info, ::GetCommandLineW());
return OnBeforeExit(rc, file);
Expand Down Expand Up @@ -292,7 +292,7 @@ class ChromeDllLoader : public MainDllLoader {
// NORMAL_EXIT_CANCEL is used for experiments when the user cancels
// so we need to reset the did_run signal so omaha does not count
// this run as active usage.
if (ResultCodes::NORMAL_EXIT_CANCEL == return_code) {
if (chrome::RESULT_CODE_NORMAL_EXIT_CANCEL == return_code) {
ClearDidRun(dll_path);
}
return return_code;
Expand Down
24 changes: 12 additions & 12 deletions chrome/app/dummy_main_functions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,55 +2,55 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/common/chrome_result_codes.h"
#include "content/common/main_function_params.h"
#include "content/common/result_codes.h"

// Native Client binary for 64-bit Windows can run only the NaCl loader or
// the sandbox broker processes. Other process types are not supported.
int BrowserMain(const MainFunctionParams& parameters) {
return ResultCodes::BAD_PROCESS_TYPE;
return chrome::RESULT_CODE_BAD_PROCESS_TYPE;
}

int RendererMain(const MainFunctionParams& parameters) {
return ResultCodes::BAD_PROCESS_TYPE;
return chrome::RESULT_CODE_BAD_PROCESS_TYPE;
}

int PluginMain(const MainFunctionParams& parameters) {
return ResultCodes::BAD_PROCESS_TYPE;
return chrome::RESULT_CODE_BAD_PROCESS_TYPE;
}

int PpapiPluginMain(const MainFunctionParams& parameters) {
return ResultCodes::BAD_PROCESS_TYPE;
return chrome::RESULT_CODE_BAD_PROCESS_TYPE;
}

int PpapiBrokerMain(const MainFunctionParams& parameters) {
return ResultCodes::BAD_PROCESS_TYPE;
return chrome::RESULT_CODE_BAD_PROCESS_TYPE;
}

int WorkerMain(const MainFunctionParams& parameters) {
return ResultCodes::BAD_PROCESS_TYPE;
return chrome::RESULT_CODE_BAD_PROCESS_TYPE;
}

int UtilityMain(const MainFunctionParams& parameters) {
return ResultCodes::BAD_PROCESS_TYPE;
return chrome::RESULT_CODE_BAD_PROCESS_TYPE;
}

int ProfileImportMain(const MainFunctionParams& parameters) {
return ResultCodes::BAD_PROCESS_TYPE;
return chrome::RESULT_CODE_BAD_PROCESS_TYPE;
}

int ZygoteMain(const MainFunctionParams& parameters) {
return ResultCodes::BAD_PROCESS_TYPE;
return chrome::RESULT_CODE_BAD_PROCESS_TYPE;
}

int DiagnosticsMain(const CommandLine& command_line) {
return 1;
}

int GpuMain(const MainFunctionParams&) {
return ResultCodes::BAD_PROCESS_TYPE;
return chrome::RESULT_CODE_BAD_PROCESS_TYPE;
}

int ServiceProcessMain(const MainFunctionParams& parameters) {
return ResultCodes::BAD_PROCESS_TYPE;
return chrome::RESULT_CODE_BAD_PROCESS_TYPE;
}
35 changes: 18 additions & 17 deletions chrome/browser/browser_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
#include "chrome/browser/web_resource/gpu_blacklist_updater.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_result_codes.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/chrome_version_info.h"
#include "chrome/common/env_vars.h"
Expand All @@ -94,7 +95,6 @@
#include "content/common/content_client.h"
#include "content/common/hi_res_timer_manager.h"
#include "content/common/main_function_params.h"
#include "content/common/result_codes.h"
#include "grit/app_locale_settings.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
Expand Down Expand Up @@ -1426,12 +1426,12 @@ int BrowserMain(const MainFunctionParams& parameters) {
TryChromeDialogView::Result answer =
TryChromeDialogView::Show(try_chrome_int, &process_singleton);
if (answer == TryChromeDialogView::NOT_NOW)
return ResultCodes::NORMAL_EXIT_CANCEL;
return chrome::RESULT_CODE_NORMAL_EXIT_CANCEL;
if (answer == TryChromeDialogView::UNINSTALL_CHROME)
return ResultCodes::NORMAL_EXIT_EXP2;
return chrome::RESULT_CODE_NORMAL_EXIT_EXP2;
#else
// We don't support retention experiments on Mac or Linux.
return ResultCodes::NORMAL_EXIT;
return content::RESULT_CODE_NORMAL_EXIT;
#endif // defined(OS_WIN)
}

Expand Down Expand Up @@ -1562,17 +1562,18 @@ int BrowserMain(const MainFunctionParams& parameters) {
return HandleIconsCommands(parsed_command_line);
if (parsed_command_line.HasSwitch(switches::kMakeDefaultBrowser)) {
return ShellIntegration::SetAsDefaultBrowser() ?
ResultCodes::NORMAL_EXIT : ResultCodes::SHELL_INTEGRATION_FAILED;
static_cast<int>(content::RESULT_CODE_NORMAL_EXIT) :
static_cast<int>(chrome::RESULT_CODE_SHELL_INTEGRATION_FAILED);
}

// If the command line specifies --pack-extension, attempt the pack extension
// startup action and exit.
if (parsed_command_line.HasSwitch(switches::kPackExtension)) {
ExtensionsStartupUtil extension_startup_util;
if (extension_startup_util.PackExtension(parsed_command_line)) {
return ResultCodes::NORMAL_EXIT;
return content::RESULT_CODE_NORMAL_EXIT;
} else {
return ResultCodes::PACK_EXTENSION_ERROR;
return chrome::RESULT_CODE_PACK_EXTENSION_ERROR;
}
}

Expand All @@ -1598,18 +1599,18 @@ int BrowserMain(const MainFunctionParams& parameters) {
printf("%s\n", base::SysWideToNativeMB(UTF16ToWide(
l10n_util::GetStringUTF16(IDS_USED_EXISTING_BROWSER))).c_str());
#endif
return ResultCodes::NORMAL_EXIT;
return content::RESULT_CODE_NORMAL_EXIT;

case ProcessSingleton::PROFILE_IN_USE:
return ResultCodes::PROFILE_IN_USE;
return chrome::RESULT_CODE_PROFILE_IN_USE;

case ProcessSingleton::LOCK_ERROR:
LOG(ERROR) << "Failed to create a ProcessSingleton for your profile "
"directory. This means that running multiple instances "
"would start multiple browser processes rather than "
"opening a new window in the existing process. Aborting "
"now to avoid profile corruption.";
return ResultCodes::PROFILE_IN_USE;
return chrome::RESULT_CODE_PROFILE_IN_USE;

default:
NOTREACHED();
Expand Down Expand Up @@ -1657,7 +1658,7 @@ int BrowserMain(const MainFunctionParams& parameters) {

Profile* profile = CreateProfile(parameters, user_data_dir);
if (!profile)
return ResultCodes::NORMAL_EXIT;
return content::RESULT_CODE_NORMAL_EXIT;

// Post-profile init ---------------------------------------------------------

Expand Down Expand Up @@ -1699,7 +1700,7 @@ int BrowserMain(const MainFunctionParams& parameters) {
#if defined(OS_WIN)
// Do the tasks if chrome has been upgraded while it was last running.
if (!already_running && upgrade_util::DoUpgradeTasks(parsed_command_line))
return ResultCodes::NORMAL_EXIT;
return content::RESULT_CODE_NORMAL_EXIT;
#endif

// Check if there is any machine level Chrome installed on the current
Expand All @@ -1712,7 +1713,7 @@ int BrowserMain(const MainFunctionParams& parameters) {
// Do not allow this to occur for Chrome Frame user-to-system handoffs.
if (!parsed_command_line.HasSwitch(switches::kChromeFrame) &&
CheckMachineLevelInstall())
return ResultCodes::MACHINE_LEVEL_INSTALL_EXISTS;
return chrome::RESULT_CODE_MACHINE_LEVEL_INSTALL_EXISTS;

// Create the TranslateManager singleton.
TranslateManager* translate_manager = TranslateManager::GetInstance();
Expand All @@ -1725,7 +1726,7 @@ int BrowserMain(const MainFunctionParams& parameters) {
if (MaybeInstallFromDiskImage()) {
// The application was installed and the installed copy has been
// launched. This process is now obsolete. Exit.
return ResultCodes::NORMAL_EXIT;
return content::RESULT_CODE_NORMAL_EXIT;
}
}
#endif
Expand Down Expand Up @@ -1908,9 +1909,9 @@ int BrowserMain(const MainFunctionParams& parameters) {
if (parsed_command_line.HasSwitch(switches::kUninstallExtension)) {
ExtensionsStartupUtil ext_startup_util;
if (ext_startup_util.UninstallExtension(parsed_command_line, profile)) {
return ResultCodes::NORMAL_EXIT;
return content::RESULT_CODE_NORMAL_EXIT;
} else {
return ResultCodes::UNINSTALL_EXTENSION_ERROR;
return chrome::RESULT_CODE_UNINSTALL_EXTENSION_ERROR;
}
}

Expand Down Expand Up @@ -1955,7 +1956,7 @@ int BrowserMain(const MainFunctionParams& parameters) {
// Start watching all browser threads for responsiveness.
ThreadWatcherList::StartWatchingAll(parsed_command_line);

int result_code = ResultCodes::NORMAL_EXIT;
int result_code = content::RESULT_CODE_NORMAL_EXIT;
if (parameters.ui_task) {
// We are in test mode. Run one task and enter the main message loop.
if (pool)
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/browser_main_gtk.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
#include "chrome/browser/metrics/metrics_service.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/chrome_result_codes.h"
#include "content/browser/renderer_host/render_sandbox_host_linux.h"
#include "content/browser/zygote_host_linux.h"
#include "content/common/result_codes.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"
Expand Down Expand Up @@ -186,7 +186,7 @@ void RecordBrowserStartupTime() {
// From browser_main_win.h, stubs until we figure out the right thing...

int DoUninstallTasks(bool chrome_still_running) {
return ResultCodes::NORMAL_EXIT;
return content::RESULT_CODE_NORMAL_EXIT;
}

int HandleIconsCommands(const CommandLine &parsed_command_line) {
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/browser_main_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void WarnAboutMinimumSystemRequirements() {
// From browser_main_win.h, stubs until we figure out the right thing...

int DoUninstallTasks(bool chrome_still_running) {
return ResultCodes::NORMAL_EXIT;
return content::RESULT_CODE_NORMAL_EXIT;
}

int HandleIconsCommands(const CommandLine& parsed_command_line) {
Expand Down
18 changes: 10 additions & 8 deletions chrome/browser/browser_main_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/views/uninstall_view.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_result_codes.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/env_vars.h"
#include "chrome/installer/util/browser_distribution.h"
#include "chrome/installer/util/helper.h"
#include "chrome/installer/util/install_util.h"
#include "chrome/installer/util/shell_util.h"
#include "content/common/main_function_params.h"
#include "content/common/result_codes.h"
#include "crypto/nss_util.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
Expand Down Expand Up @@ -99,7 +99,7 @@ void RecordBrowserStartupTime() {
}

int AskForUninstallConfirmation() {
int ret = ResultCodes::NORMAL_EXIT;
int ret = content::RESULT_CODE_NORMAL_EXIT;
views::Widget::CreateWindow(new UninstallView(ret))->Show();
views::AcceleratorHandler accelerator_handler;
MessageLoopForUI::current()->Run(&accelerator_handler);
Expand All @@ -120,15 +120,15 @@ int DoUninstallTasks(bool chrome_still_running) {
// check once again after user acknowledges Uninstall dialog.
if (chrome_still_running) {
ShowCloseBrowserFirstMessageBox();
return ResultCodes::UNINSTALL_CHROME_ALIVE;
return chrome::RESULT_CODE_UNINSTALL_CHROME_ALIVE;
}
int ret = AskForUninstallConfirmation();
if (browser_util::IsBrowserAlreadyRunning()) {
ShowCloseBrowserFirstMessageBox();
return ResultCodes::UNINSTALL_CHROME_ALIVE;
return chrome::RESULT_CODE_UNINSTALL_CHROME_ALIVE;
}

if (ret != ResultCodes::UNINSTALL_USER_CANCEL) {
if (ret != chrome::RESULT_CODE_UNINSTALL_USER_CANCEL) {
// The following actions are just best effort.
VLOG(1) << "Executing uninstall actions";
if (!FirstRun::RemoveSentinel())
Expand Down Expand Up @@ -225,7 +225,7 @@ int HandleIconsCommands(const CommandLine& parsed_command_line) {
} else if (version >= base::win::VERSION_XP) {
cp_applet.assign(L"Add/Remove Programs"); // Windows XP.
} else {
return ResultCodes::UNSUPPORTED_PARAM; // Not supported
return chrome::RESULT_CODE_UNSUPPORTED_PARAM; // Not supported
}

const string16 msg =
Expand All @@ -234,10 +234,12 @@ int HandleIconsCommands(const CommandLine& parsed_command_line) {
const UINT flags = MB_OKCANCEL | MB_ICONWARNING | MB_TOPMOST;
if (IDOK == ui::MessageBox(NULL, msg, caption, flags))
ShellExecute(NULL, NULL, L"appwiz.cpl", NULL, NULL, SW_SHOWNORMAL);
return ResultCodes::NORMAL_EXIT; // Exit as we are not launching browser.

// Exit as we are not launching the browser.
return content::RESULT_CODE_NORMAL_EXIT;
}
// We don't hide icons so we shouldn't do anything special to show them
return ResultCodes::UNSUPPORTED_PARAM;
return chrome::RESULT_CODE_UNSUPPORTED_PARAM;
}

// Check if there is any machine level Chrome installed on the current
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ class ExtensionCrashRecoveryTest : public ExtensionBrowserTest {

RenderProcessHost* extension_rph =
extension_host->render_view_host()->process();
base::KillProcess(extension_rph->GetHandle(), ResultCodes::KILLED, false);
base::KillProcess(extension_rph->GetHandle(), content::RESULT_CODE_KILLED,
false);
ASSERT_TRUE(WaitForExtensionCrash(extension_id));
ASSERT_FALSE(
GetExtensionProcessManager()->GetBackgroundHostForExtension(extension));
Expand Down
Loading

0 comments on commit 1fcfb20

Please sign in to comment.