Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(442)

Side by Side Diff: chrome_frame/crash_server_init.cc

Issue 7219007: Fix up crash reporting in unit tests and the Chrome Frame helper processes: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
grt (UTC plus 2) 2011/06/22 14:15:01 2011
robertshield 2011/06/23 02:22:51 Done.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome_frame/crash_server_init.h" 5 #include "chrome_frame/crash_server_init.h"
6 6
7 #include <sddl.h>
8 #include <Shlobj.h>
7 #include "version.h" // NOLINT 9 #include "version.h" // NOLINT
8 10
9 const wchar_t kChromePipeName[] = L"\\\\.\\pipe\\ChromeCrashServices"; 11 const wchar_t kChromePipeName[] = L"\\\\.\\pipe\\ChromeCrashServices";
10 const wchar_t kGoogleUpdatePipeName[] = L"\\\\.\\pipe\\GoogleCrashServices\\"; 12 const wchar_t kGoogleUpdatePipeName[] = L"\\\\.\\pipe\\GoogleCrashServices\\";
11 const wchar_t kSystemPrincipalSid[] = L"S-1-5-18"; 13 const wchar_t kSystemPrincipalSid[] = L"S-1-5-18";
12 14
13 const wchar_t kFullMemoryCrashReport[] = L"full-memory-crash-report"; 15 const wchar_t kFullMemoryCrashReport[] = L"full-memory-crash-report";
grt (UTC plus 2) 2011/06/22 14:15:01 Looks like this isn't used anymore. Please remove
robertshield 2011/06/23 02:22:51 The only place CF-related that it is used is by np
14 16
15 const MINIDUMP_TYPE kLargerDumpType = static_cast<MINIDUMP_TYPE>( 17 const MINIDUMP_TYPE kLargerDumpType = static_cast<MINIDUMP_TYPE>(
16 MiniDumpWithProcessThreadData | // Get PEB and TEB. 18 MiniDumpWithProcessThreadData | // Get PEB and TEB.
17 MiniDumpWithUnloadedModules | // Get unloaded modules when available. 19 MiniDumpWithUnloadedModules | // Get unloaded modules when available.
18 MiniDumpWithIndirectlyReferencedMemory); // Get memory referenced by stack. 20 MiniDumpWithIndirectlyReferencedMemory); // Get memory referenced by stack.
19 21
22 // Builds a string representation of the user's SID and places it in user_sid.
23 bool GetUserSidString(std::wstring* user_sid) {
24 bool success = false;
25 if (user_sid) {
26 const DWORD kSize = sizeof(TOKEN_USER) + SECURITY_MAX_SID_SIZE;
grt (UTC plus 2) 2011/06/22 14:15:01 Google style guide says to use sizeof(varname) rat
robertshield 2011/06/23 02:22:51 Good idea, much nicer.
27 BYTE buffer[kSize];
28 TOKEN_USER* user = reinterpret_cast<TOKEN_USER*>(buffer);
29
30 HANDLE token = NULL;
31 if (OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token)) {
32 DWORD out_size;
33 if (GetTokenInformation(token, TokenUser, user, kSize, &out_size)) {
34 wchar_t* user_sid_value = NULL;
35 if (user->User.Sid && ConvertSidToStringSid(user->User.Sid,
36 &user_sid_value)) {
37 *user_sid = user_sid_value;
38 LocalFree(user_sid_value);
39 user_sid_value = NULL;
40 success = true;
41 }
42 }
43 CloseHandle(token);
44 }
45 }
46
47 return success;
48 }
49
50 bool IsRunningSystemInstall() {
51 wchar_t exe_path[MAX_PATH * 2] = {0};
52 GetModuleFileName(NULL, exe_path, MAX_PATH * 2);
grt (UTC plus 2) 2011/06/22 14:15:01 Will this not return the path to iexplore.exe when
grt (UTC plus 2) 2011/06/22 14:15:01 Rather than repeat MAX_PATH * 2, how about _counto
robertshield 2011/06/23 02:22:51 This code is only linked into chrome_launcher.exe
robertshield 2011/06/23 02:22:51 Done.
53
54 bool is_system = false;
55
56 wchar_t program_files_path[MAX_PATH] = {0};
57 if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_PROGRAM_FILES, NULL,
58 SHGFP_TYPE_CURRENT, program_files_path))) {
59 if (wcsstr(exe_path, program_files_path)) {
grt (UTC plus 2) 2011/06/22 14:15:01 To be strictly correct, this should be: if (wcss
robertshield 2011/06/23 02:22:51 Done.
60 is_system = true;
61 }
62 }
63
64 return is_system;
65 }
66
20 google_breakpad::CustomClientInfo* GetCustomInfo() { 67 google_breakpad::CustomClientInfo* GetCustomInfo() {
21 static google_breakpad::CustomInfoEntry ver_entry( 68 static google_breakpad::CustomInfoEntry ver_entry(
22 L"ver", TEXT(CHROME_VERSION_STRING)); 69 L"ver", TEXT(CHROME_VERSION_STRING));
23 static google_breakpad::CustomInfoEntry prod_entry(L"prod", L"ChromeFrame"); 70 static google_breakpad::CustomInfoEntry prod_entry(L"prod", L"ChromeFrame");
24 static google_breakpad::CustomInfoEntry plat_entry(L"plat", L"Win32"); 71 static google_breakpad::CustomInfoEntry plat_entry(L"plat", L"Win32");
25 static google_breakpad::CustomInfoEntry type_entry(L"ptype", L"chrome_frame"); 72 static google_breakpad::CustomInfoEntry type_entry(L"ptype", L"chrome_frame");
26 static google_breakpad::CustomInfoEntry entries[] = { 73 static google_breakpad::CustomInfoEntry entries[] = {
27 ver_entry, prod_entry, plat_entry, type_entry }; 74 ver_entry, prod_entry, plat_entry, type_entry };
28 static google_breakpad::CustomClientInfo custom_info = { 75 static google_breakpad::CustomClientInfo custom_info = {
29 entries, ARRAYSIZE(entries) }; 76 entries, ARRAYSIZE(entries) };
30 return &custom_info; 77 return &custom_info;
31 } 78 }
32 79
33 google_breakpad::ExceptionHandler* InitializeCrashReporting( 80 google_breakpad::ExceptionHandler* InitializeCrashReporting(
34 const wchar_t* cmd_line) { 81 CrashReportingFlags flags) {
35 if (cmd_line == NULL) {
36 return NULL;
37 }
38
39 wchar_t temp_path[MAX_PATH + 1] = {0}; 82 wchar_t temp_path[MAX_PATH + 1] = {0};
40 DWORD path_len = ::GetTempPath(MAX_PATH, temp_path); 83 DWORD path_len = ::GetTempPath(MAX_PATH, temp_path);
41 84
42 std::wstring pipe_name; 85 std::wstring pipe_name;
43 if (wcsstr(cmd_line, kFullMemoryCrashReport) != NULL) { 86 if (flags == HEADLESS) {
87 // This flag is used for testing, connect to the test crash service.
44 pipe_name = kChromePipeName; 88 pipe_name = kChromePipeName;
45 } else { 89 } else {
46 // TODO(robertshield): Figure out if we're a per-user install and connect 90 // Otherwise, build a pipe name corresponding to either user or
47 // to the per-user named pipe instead. 91 // system-level Omaha.
48 pipe_name = kGoogleUpdatePipeName; 92 pipe_name = kGoogleUpdatePipeName;
49 pipe_name += kSystemPrincipalSid; 93 if (IsRunningSystemInstall()) {
94 pipe_name += kSystemPrincipalSid;
95 } else {
96 std::wstring user_sid;
97 if (GetUserSidString(&user_sid)) {
98 pipe_name += user_sid;
99 } else {
100 // We don't think we're a system install, but we couldn't get the
101 // user SID. Try connecting to the system-level crash service as a
102 // last ditch effort.
103 pipe_name += kSystemPrincipalSid;
104 }
105 }
50 } 106 }
51 107
52 google_breakpad::ExceptionHandler* breakpad = 108 google_breakpad::ExceptionHandler* breakpad =
53 new google_breakpad::ExceptionHandler( 109 new google_breakpad::ExceptionHandler(
54 temp_path, NULL, NULL, NULL, 110 temp_path, NULL, NULL, NULL,
55 google_breakpad::ExceptionHandler::HANDLER_ALL, kLargerDumpType, 111 google_breakpad::ExceptionHandler::HANDLER_ALL, kLargerDumpType,
56 pipe_name.c_str(), GetCustomInfo()); 112 pipe_name.c_str(), GetCustomInfo());
57 113
58 return breakpad; 114 return breakpad;
59 } 115 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698