blob: 0f522158b3de4bc1bea38be9e86946588b83b063 [file] [log] [blame]
[email protected]e4fe427b2010-09-03 19:57:421// Copyright (c) 2010 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "chrome_frame/crash_server_init.h"
6
7#include "version.h" // NOLINT
8
9const wchar_t kChromePipeName[] = L"\\\\.\\pipe\\ChromeCrashServices";
10const wchar_t kGoogleUpdatePipeName[] = L"\\\\.\\pipe\\GoogleCrashServices\\";
11const wchar_t kSystemPrincipalSid[] = L"S-1-5-18";
12
13const wchar_t kFullMemoryCrashReport[] = L"full-memory-crash-report";
14
15const MINIDUMP_TYPE kLargerDumpType = static_cast<MINIDUMP_TYPE>(
16 MiniDumpWithProcessThreadData | // Get PEB and TEB.
17 MiniDumpWithUnloadedModules | // Get unloaded modules when available.
18 MiniDumpWithIndirectlyReferencedMemory); // Get memory referenced by stack.
19
20google_breakpad::CustomClientInfo* GetCustomInfo() {
21 static google_breakpad::CustomInfoEntry ver_entry(
22 L"ver", TEXT(CHROME_VERSION_STRING));
23 static google_breakpad::CustomInfoEntry prod_entry(L"prod", L"ChromeFrame");
24 static google_breakpad::CustomInfoEntry plat_entry(L"plat", L"Win32");
25 static google_breakpad::CustomInfoEntry type_entry(L"ptype", L"chrome_frame");
26 static google_breakpad::CustomInfoEntry entries[] = {
27 ver_entry, prod_entry, plat_entry, type_entry };
28 static google_breakpad::CustomClientInfo custom_info = {
29 entries, ARRAYSIZE(entries) };
30 return &custom_info;
31}
32
33google_breakpad::ExceptionHandler* InitializeCrashReporting(
34 const wchar_t* cmd_line) {
35 if (cmd_line == NULL) {
36 return NULL;
37 }
38
39 wchar_t temp_path[MAX_PATH + 1] = {0};
40 DWORD path_len = ::GetTempPath(MAX_PATH, temp_path);
41
42 std::wstring pipe_name;
43 if (wcsstr(cmd_line, kFullMemoryCrashReport) != NULL) {
44 pipe_name = kChromePipeName;
45 } else {
46 // TODO(robertshield): Figure out if we're a per-user install and connect
47 // to the per-user named pipe instead.
48 pipe_name = kGoogleUpdatePipeName;
49 pipe_name += kSystemPrincipalSid;
50 }
51
52 google_breakpad::ExceptionHandler* breakpad =
53 new google_breakpad::ExceptionHandler(
54 temp_path, NULL, NULL, NULL,
55 google_breakpad::ExceptionHandler::HANDLER_ALL, kLargerDumpType,
56 pipe_name.c_str(), GetCustomInfo());
57
58 return breakpad;
59}