summaryrefslogtreecommitdiffstats
path: root/chrome_frame
diff options
context:
space:
mode:
authorrobertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-23 20:20:02 +0000
committerrobertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-23 20:20:02 +0000
commit15bb2f4987e01dbb765207d792edbfe48efe68d1 (patch)
treea8a59a5f87025e4b113c3ec754312d99456a8f45 /chrome_frame
parent710a98ded8a324b8ef534cd2ef9ad6735b1ee21c (diff)
downloadchromium_src-15bb2f4987e01dbb765207d792edbfe48efe68d1.zip
chromium_src-15bb2f4987e01dbb765207d792edbfe48efe68d1.tar.gz
chromium_src-15bb2f4987e01dbb765207d792edbfe48efe68d1.tar.bz2
Fix up crash reporting in unit tests and the Chrome Frame helper processes:
Bother to initialize crash reporting in chrome_frame_tests.exe. Correctly construct the crash reporting pipe name for non-admin installs. BUG=86846 TEST=Crash dumps are reported when running Chrome Frame tests in headless mode, user-level Chrome Frame helper processes connect to the crash service. Review URL: http://codereview.chromium.org/7219007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@90255 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame')
-rw-r--r--chrome_frame/chrome_frame.gyp6
-rw-r--r--chrome_frame/chrome_frame_helper_main.cc3
-rw-r--r--chrome_frame/chrome_launcher_main.cc7
-rw-r--r--chrome_frame/crash_server_init.cc86
-rw-r--r--chrome_frame/crash_server_init.h13
-rw-r--r--chrome_frame/test/run_all_unittests.cc7
6 files changed, 96 insertions, 26 deletions
diff --git a/chrome_frame/chrome_frame.gyp b/chrome_frame/chrome_frame.gyp
index e8fb9b5..ab5a3c5 100644
--- a/chrome_frame/chrome_frame.gyp
+++ b/chrome_frame/chrome_frame.gyp
@@ -260,6 +260,7 @@
],
'include_dirs': [
'<(DEPTH)/third_party/wtl/include',
+ '<(DEPTH)/breakpad/src',
],
'resource_include_dirs': [
'<(INTERMEDIATE_DIR)',
@@ -397,6 +398,9 @@
'chrome_tab_idl',
'npchrome_frame',
],
+ 'include_dirs': [
+ '<(DEPTH)/breakpad/src',
+ ],
'sources': [
'../net/url_request/url_request_unittest.cc',
'test/chrome_frame_test_utils.cc',
@@ -569,6 +573,7 @@
],
'include_dirs': [
'<(DEPTH)/third_party/wtl/include',
+ '<(DEPTH)/breakpad/src',
# To allow including "chrome_tab.h"
'<(INTERMEDIATE_DIR)',
],
@@ -644,7 +649,6 @@
{
'target_name': 'chrome_frame_utils',
# The intent is that shared util code can be built into a separate lib.
- # Currently on the resource loading code is here.
'type': 'static_library',
'dependencies': [
'../base/base.gyp:base_i18n',
diff --git a/chrome_frame/chrome_frame_helper_main.cc b/chrome_frame/chrome_frame_helper_main.cc
index 6408ecd..27e1555 100644
--- a/chrome_frame/chrome_frame_helper_main.cc
+++ b/chrome_frame/chrome_frame_helper_main.cc
@@ -223,9 +223,8 @@ void WaitCallback() {
}
int APIENTRY wWinMain(HINSTANCE hinstance, HINSTANCE, wchar_t*, int show_cmd) {
- const wchar_t* cmd_line = ::GetCommandLine();
google_breakpad::scoped_ptr<google_breakpad::ExceptionHandler> breakpad(
- InitializeCrashReporting(cmd_line));
+ InitializeCrashReporting(NORMAL));
if (IsSystemLevelChromeFrameInstalled()) {
// If we're running at startup, check for system-level Chrome Frame
diff --git a/chrome_frame/chrome_launcher_main.cc b/chrome_frame/chrome_launcher_main.cc
index 5716345..462a317 100644
--- a/chrome_frame/chrome_launcher_main.cc
+++ b/chrome_frame/chrome_launcher_main.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 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.
@@ -11,11 +11,10 @@
#include "chrome_frame/update_launcher.h"
int APIENTRY wWinMain(HINSTANCE, HINSTANCE, wchar_t*, int) {
- const wchar_t* cmd_line = ::GetCommandLine();
-
google_breakpad::scoped_ptr<google_breakpad::ExceptionHandler> breakpad(
- InitializeCrashReporting(cmd_line));
+ InitializeCrashReporting(NORMAL));
+ const wchar_t* cmd_line = ::GetCommandLine();
std::wstring update_command(
update_launcher::GetUpdateCommandFromArguments(cmd_line));
diff --git a/chrome_frame/crash_server_init.cc b/chrome_frame/crash_server_init.cc
index 0f52215..44b4049 100644
--- a/chrome_frame/crash_server_init.cc
+++ b/chrome_frame/crash_server_init.cc
@@ -1,22 +1,75 @@
-// 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.
#include "chrome_frame/crash_server_init.h"
+#include <sddl.h>
+#include <Shlobj.h>
+#include <stdlib.h>
#include "version.h" // NOLINT
const wchar_t kChromePipeName[] = L"\\\\.\\pipe\\ChromeCrashServices";
const wchar_t kGoogleUpdatePipeName[] = L"\\\\.\\pipe\\GoogleCrashServices\\";
const wchar_t kSystemPrincipalSid[] = L"S-1-5-18";
-const wchar_t kFullMemoryCrashReport[] = L"full-memory-crash-report";
-
const MINIDUMP_TYPE kLargerDumpType = static_cast<MINIDUMP_TYPE>(
MiniDumpWithProcessThreadData | // Get PEB and TEB.
MiniDumpWithUnloadedModules | // Get unloaded modules when available.
MiniDumpWithIndirectlyReferencedMemory); // Get memory referenced by stack.
+extern "C" IMAGE_DOS_HEADER __ImageBase;
+
+// Builds a string representation of the user's SID and places it in user_sid.
+bool GetUserSidString(std::wstring* user_sid) {
+ bool success = false;
+ if (user_sid) {
+ struct {
+ TOKEN_USER token_user;
+ BYTE buffer[SECURITY_MAX_SID_SIZE];
+ } token_info_buffer;
+
+ HANDLE token = NULL;
+ if (OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token)) {
+ DWORD out_size;
+ if (GetTokenInformation(token, TokenUser, &token_info_buffer.token_user,
+ sizeof(token_info_buffer), &out_size)) {
+ wchar_t* user_sid_value = NULL;
+ if (token_info_buffer.token_user.User.Sid &&
+ ConvertSidToStringSid(token_info_buffer.token_user.User.Sid,
+ &user_sid_value)) {
+ *user_sid = user_sid_value;
+ LocalFree(user_sid_value);
+ user_sid_value = NULL;
+ success = true;
+ }
+ }
+ CloseHandle(token);
+ }
+ }
+
+ return success;
+}
+
+bool IsRunningSystemInstall() {
+ wchar_t exe_path[MAX_PATH * 2] = {0};
+ GetModuleFileName(reinterpret_cast<HMODULE>(&__ImageBase),
+ exe_path,
+ _countof(exe_path));
+
+ bool is_system = false;
+
+ wchar_t program_files_path[MAX_PATH] = {0};
+ if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_PROGRAM_FILES, NULL,
+ SHGFP_TYPE_CURRENT, program_files_path))) {
+ if (wcsstr(exe_path, program_files_path) == exe_path) {
+ is_system = true;
+ }
+ }
+
+ return is_system;
+}
+
google_breakpad::CustomClientInfo* GetCustomInfo() {
static google_breakpad::CustomInfoEntry ver_entry(
L"ver", TEXT(CHROME_VERSION_STRING));
@@ -31,22 +84,31 @@ google_breakpad::CustomClientInfo* GetCustomInfo() {
}
google_breakpad::ExceptionHandler* InitializeCrashReporting(
- const wchar_t* cmd_line) {
- if (cmd_line == NULL) {
- return NULL;
- }
-
+ CrashReportingMode mode) {
wchar_t temp_path[MAX_PATH + 1] = {0};
DWORD path_len = ::GetTempPath(MAX_PATH, temp_path);
std::wstring pipe_name;
- if (wcsstr(cmd_line, kFullMemoryCrashReport) != NULL) {
+ if (mode == HEADLESS) {
+ // This flag is used for testing, connect to the test crash service.
pipe_name = kChromePipeName;
} else {
- // TODO(robertshield): Figure out if we're a per-user install and connect
- // to the per-user named pipe instead.
+ // Otherwise, build a pipe name corresponding to either user or
+ // system-level Omaha.
pipe_name = kGoogleUpdatePipeName;
- pipe_name += kSystemPrincipalSid;
+ if (IsRunningSystemInstall()) {
+ pipe_name += kSystemPrincipalSid;
+ } else {
+ std::wstring user_sid;
+ if (GetUserSidString(&user_sid)) {
+ pipe_name += user_sid;
+ } else {
+ // We don't think we're a system install, but we couldn't get the
+ // user SID. Try connecting to the system-level crash service as a
+ // last ditch effort.
+ pipe_name += kSystemPrincipalSid;
+ }
+ }
}
google_breakpad::ExceptionHandler* breakpad =
diff --git a/chrome_frame/crash_server_init.h b/chrome_frame/crash_server_init.h
index bf7ff95..0c46f43 100644
--- a/chrome_frame/crash_server_init.h
+++ b/chrome_frame/crash_server_init.h
@@ -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.
@@ -15,12 +15,13 @@ extern const wchar_t kChromePipeName[];
extern const wchar_t kGoogleUpdatePipeName[];
extern const wchar_t kSystemPrincipalSid[];
-// Assume this implies headless mode and use kChromePipeName if it shows
-// up in the command line.
-extern const wchar_t kFullMemoryCrashReport[];
-
extern const MINIDUMP_TYPE kLargerDumpType;
+enum CrashReportingMode {
+ HEADLESS, // Used for testing, uses crash_service.exe for dumps.
+ NORMAL // Regular mode, uses GoogleCrashService.exe for dumps.
+};
+
// Returns a pointer to a static instance of a CustomClientInfo structure
// containing Chrome Frame specific data.
google_breakpad::CustomClientInfo* GetCustomInfo();
@@ -29,6 +30,6 @@ google_breakpad::CustomClientInfo* GetCustomInfo();
// constructed ExceptionHandler object. It is the responsibility of the caller
// to delete this object which will shut down the crash reporting machinery.
google_breakpad::ExceptionHandler* InitializeCrashReporting(
- const wchar_t* cmd_line);
+ CrashReportingMode mode);
#endif // CHROME_FRAME_CRASH_SERVER_INIT_H_
diff --git a/chrome_frame/test/run_all_unittests.cc b/chrome_frame/test/run_all_unittests.cc
index 4f65f2d..d13376e 100644
--- a/chrome_frame/test/run_all_unittests.cc
+++ b/chrome_frame/test/run_all_unittests.cc
@@ -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.
@@ -9,6 +9,7 @@
#include "base/test/test_suite.h"
#include "base/threading/platform_thread.h"
#include "chrome/common/chrome_paths.h"
+#include "chrome_frame/crash_server_init.h"
#include "chrome_frame/test/chrome_frame_test_utils.h"
#include "chrome_frame/test/chrome_frame_ui_test_utils.h"
#include "chrome_frame/test_utils.h"
@@ -43,6 +44,10 @@ int main(int argc, char **argv) {
SetConfigBool(kChromeFrameAccessibleMode, true);
base::ProcessHandle crash_service = chrome_frame_test::StartCrashService();
+
+ google_breakpad::scoped_ptr<google_breakpad::ExceptionHandler> breakpad(
+ InitializeCrashReporting(HEADLESS));
+
int ret = -1;
// If mini_installer is used to register CF, we use the switch
// --no-registration to avoid repetitive registration.