diff options
author | mseaborn@chromium.org <mseaborn@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-16 23:29:16 +0000 |
---|---|---|
committer | mseaborn@chromium.org <mseaborn@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-16 23:29:16 +0000 |
commit | 82790583773a1e65944abad49e62690d1293e7b3 (patch) | |
tree | fb4cf12a7841c3339a9ef68e9766a5aa53d6d2c7 | |
parent | a187ad47d59699fcfa17c4b58c7dcca8c4bf0d3e (diff) | |
download | chromium_src-82790583773a1e65944abad49e62690d1293e7b3.zip chromium_src-82790583773a1e65944abad49e62690d1293e7b3.tar.gz chromium_src-82790583773a1e65944abad49e62690d1293e7b3.tar.bz2 |
Windows Breakpad: Get metadata from chrome.exe instead of chrome.dll
Comments in the code indicate that getting the metadata from
chrome.dll in GetCustomInfo() is slow because the DLL might not have
loaded at the point where Breakpad is initialised. Getting the
metadata from the current module (which is either chrome.exe or
nacl64.exe) will be faster since the module is already loaded.
This will let us initialise Breakpad on the main thread in a later
change.
I tested this by adding the following debugging prints:
printf("product_version=%ls\n", version_info->product_version().c_str());
printf("product_short_name=%ls\n",
version_info->product_short_name().c_str());
printf("is_official_build=%i\n", version_info->is_official_build());
printf("special_build=%ls\n", version_info->special_build().c_str());
This produced the same output before and after the change:
product_version=19.0.1041.0
product_short_name=Chromium
is_official_build=0
special_build=
and it produced the same from nacl64.exe when NaCl was run. These are
all the fields of version_info that this code uses.
We rename "dll_path" to "exe_path" for clarity.
The other use of "dll_path", for IsPerUserInstall(), is safe to change
to use chrome.exe's path because this only looks at the directory of
the pathname.
We change chrome.exe to use the same method (GetModuleFileNameW()) as
nacl64.exe for getting the current executable's pathname.
BUG=111265
TEST=see above
Review URL: https://chromiumcodereview.appspot.com/9404034
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@122392 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/app/breakpad_win.cc | 17 | ||||
-rw-r--r-- | chrome/app/breakpad_win.h | 6 | ||||
-rw-r--r-- | chrome/app/client_util.cc | 2 | ||||
-rw-r--r-- | chrome/nacl/nacl_exe_win_64.cc | 6 |
4 files changed, 16 insertions, 15 deletions
diff --git a/chrome/app/breakpad_win.cc b/chrome/app/breakpad_win.cc index 0ff8df8..c08cc17 100644 --- a/chrome/app/breakpad_win.cc +++ b/chrome/app/breakpad_win.cc @@ -197,11 +197,11 @@ void SetPluginPath(const std::wstring& path) { // Returns the custom info structure based on the dll in parameter and the // process type. -google_breakpad::CustomClientInfo* GetCustomInfo(const std::wstring& dll_path, +google_breakpad::CustomClientInfo* GetCustomInfo(const std::wstring& exe_path, const std::wstring& type, const std::wstring& channel) { scoped_ptr<FileVersionInfo> - version_info(FileVersionInfo::CreateFileVersionInfo(FilePath(dll_path))); + version_info(FileVersionInfo::CreateFileVersionInfo(FilePath(exe_path))); std::wstring version, product; std::wstring special_build; @@ -329,7 +329,7 @@ google_breakpad::CustomClientInfo* GetCustomInfo(const std::wstring& dll_path, // Contains the information needed by the worker thread. struct CrashReporterInfo { google_breakpad::CustomClientInfo* custom_info; - std::wstring dll_path; + std::wstring exe_path; std::wstring process_type; }; @@ -610,7 +610,7 @@ static DWORD __stdcall InitCrashReporterThread(void* param) { reinterpret_cast<CrashReporterInfo*>(param)); bool is_per_user_install = - InstallUtil::IsPerUserInstall(info->dll_path.c_str()); + InstallUtil::IsPerUserInstall(info->exe_path.c_str()); std::wstring channel_string; GoogleUpdateSettings::GetChromeChannelAndModifiers(!is_per_user_install, @@ -618,7 +618,7 @@ static DWORD __stdcall InitCrashReporterThread(void* param) { // GetCustomInfo can take a few milliseconds to get the file information, so // we do it here so it can run in a separate thread. - info->custom_info = GetCustomInfo(info->dll_path, info->process_type, + info->custom_info = GetCustomInfo(info->exe_path, info->process_type, channel_string); google_breakpad::ExceptionHandler::MinidumpCallback callback = NULL; @@ -746,7 +746,7 @@ void InitDefaultCrashCallback(LPTOP_LEVEL_EXCEPTION_FILTER filter) { previous_filter = SetUnhandledExceptionFilter(filter); } -void InitCrashReporterWithDllPath(const std::wstring& dll_path) { +void InitCrashReporter() { const CommandLine& command = *CommandLine::ForCurrentProcess(); if (!command.HasSwitch(switches::kDisableBreakpad)) { // Disable the message box for assertions. @@ -759,7 +759,10 @@ void InitCrashReporterWithDllPath(const std::wstring& dll_path) { if (info->process_type.empty()) info->process_type = L"browser"; - info->dll_path = dll_path; + wchar_t exe_path[MAX_PATH]; + exe_path[0] = 0; + GetModuleFileNameW(NULL, exe_path, MAX_PATH); + info->exe_path = exe_path; // If this is not the browser, we can't be sure that we will be able to // initialize the crash_handler in another thread, so we run it right away. diff --git a/chrome/app/breakpad_win.h b/chrome/app/breakpad_win.h index f528ecc..0633c3a 100644 --- a/chrome/app/breakpad_win.h +++ b/chrome/app/breakpad_win.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -12,9 +12,9 @@ // The maximum number of 64-char URL chunks we will report. static const int kMaxUrlChunks = 8; -// Calls InitCrashReporterThread in it's own thread for the browser process +// Calls InitCrashReporterThread in its own thread for the browser process // or directly for the plugin and renderer process. -void InitCrashReporterWithDllPath(const std::wstring& dll_path); +void InitCrashReporter(); // Intercepts a crash but does not process it, just ask if we want to restart // the browser or not. diff --git a/chrome/app/client_util.cc b/chrome/app/client_util.cc index d5b6ea3..e8f5675 100644 --- a/chrome/app/client_util.cc +++ b/chrome/app/client_util.cc @@ -413,7 +413,7 @@ int MainDllLoader::Launch(HINSTANCE instance, scoped_ptr<base::Environment> env(base::Environment::Create()); env->SetVar(chrome::kChromeVersionEnvVar, WideToUTF8(version)); - InitCrashReporterWithDllPath(file); + InitCrashReporter(); OnBeforeLaunch(file); DLL_MAIN entry_point = diff --git a/chrome/nacl/nacl_exe_win_64.cc b/chrome/nacl/nacl_exe_win_64.cc index 9bddf80..00c2ce0 100644 --- a/chrome/nacl/nacl_exe_win_64.cc +++ b/chrome/nacl/nacl_exe_win_64.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -48,9 +48,7 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t*, int) { base::AtExitManager exit_manager; CommandLine::Init(0, NULL); - wchar_t path[MAX_PATH]; - ::GetModuleFileNameW(NULL, path, MAX_PATH); - InitCrashReporterWithDllPath(std::wstring(path)); + InitCrashReporter(); const CommandLine& command_line = *CommandLine::ForCurrentProcess(); std::string process_type = |