OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
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 // This module contains the necessary code to register the Breakpad exception | 5 // This module contains the necessary code to register the Breakpad exception |
6 // handler. This implementation is based on Chrome crash reporting code. See: | 6 // handler. This implementation is based on Chrome crash reporting code. See: |
7 // - src/components/crash/content/app/breakpad_win.cc | 7 // - src/components/crash/content/app/breakpad_win.cc |
8 // - src/chrome/installer/setup/setup_main.cc | 8 // - src/chrome/installer/setup/setup_main.cc |
9 | 9 |
10 #include "remoting/base/breakpad.h" | 10 #include "remoting/base/breakpad.h" |
11 | 11 |
12 #include <windows.h> | 12 #include <windows.h> |
13 #include <string> | 13 #include <string> |
14 | 14 |
15 #include "base/atomicops.h" | 15 #include "base/atomicops.h" |
16 #include "base/file_version_info.h" | 16 #include "base/file_version_info.h" |
17 #include "base/lazy_instance.h" | 17 #include "base/lazy_instance.h" |
18 #include "base/logging.h" | 18 #include "base/logging.h" |
19 #include "base/macros.h" | 19 #include "base/macros.h" |
20 #include "base/memory/scoped_ptr.h" | 20 #include "base/memory/scoped_ptr.h" |
21 #include "base/process/memory.h" | |
22 #include "base/strings/utf_string_conversions.h" | 21 #include "base/strings/utf_string_conversions.h" |
| 22 #include "base/win/current_module.h" |
23 #include "base/win/wrapped_window_proc.h" | 23 #include "base/win/wrapped_window_proc.h" |
24 #include "breakpad/src/client/windows/handler/exception_handler.h" | 24 #include "breakpad/src/client/windows/handler/exception_handler.h" |
25 | 25 |
26 namespace remoting { | 26 namespace remoting { |
27 void InitializeCrashReportingForTest(const wchar_t* pipe_name); | 27 void InitializeCrashReportingForTest(const wchar_t* pipe_name); |
28 } // namespace remoting | 28 } // namespace remoting |
29 | 29 |
30 namespace { | 30 namespace { |
31 | 31 |
32 const wchar_t kBreakpadProductName[] = L"Chromoting"; | 32 const wchar_t kBreakpadProductName[] = L"Chromoting"; |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 NOTREACHED(); | 137 NOTREACHED(); |
138 } | 138 } |
139 | 139 |
140 // static | 140 // static |
141 BreakpadWin* BreakpadWin::GetInstance() { | 141 BreakpadWin* BreakpadWin::GetInstance() { |
142 return &g_instance.Get(); | 142 return &g_instance.Get(); |
143 } | 143 } |
144 | 144 |
145 // Returns the Custom information to be used for crash reporting. | 145 // Returns the Custom information to be used for crash reporting. |
146 google_breakpad::CustomClientInfo* BreakpadWin::GetCustomInfo() { | 146 google_breakpad::CustomClientInfo* BreakpadWin::GetCustomInfo() { |
147 HMODULE binary = base::GetModuleFromAddress( | |
148 reinterpret_cast<void*>(&remoting::InitializeCrashReporting)); | |
149 scoped_ptr<FileVersionInfo> version_info( | 147 scoped_ptr<FileVersionInfo> version_info( |
150 FileVersionInfo::CreateFileVersionInfoForModule(binary)); | 148 FileVersionInfo::CreateFileVersionInfoForModule(CURRENT_MODULE())); |
151 | 149 |
152 static wchar_t version[64]; | 150 static wchar_t version[64]; |
153 if (version_info.get()) { | 151 if (version_info.get()) { |
154 wcscpy_s(version, version_info->product_version().c_str()); | 152 wcscpy_s(version, version_info->product_version().c_str()); |
155 } else { | 153 } else { |
156 wcscpy_s(version, kBreakpadVersionDefault); | 154 wcscpy_s(version, kBreakpadVersionDefault); |
157 } | 155 } |
158 | 156 |
159 static google_breakpad::CustomInfoEntry ver_entry( | 157 static google_breakpad::CustomInfoEntry ver_entry( |
160 kBreakpadVersionEntry, version); | 158 kBreakpadVersionEntry, version); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 // Touch the object to make sure it is initialized. | 199 // Touch the object to make sure it is initialized. |
202 BreakpadWin::GetInstance(); | 200 BreakpadWin::GetInstance(); |
203 } | 201 } |
204 | 202 |
205 void InitializeCrashReportingForTest(const wchar_t* pipe_name) { | 203 void InitializeCrashReportingForTest(const wchar_t* pipe_name) { |
206 BreakpadWin::pipe_name_ = pipe_name; | 204 BreakpadWin::pipe_name_ = pipe_name; |
207 InitializeCrashReporting(); | 205 InitializeCrashReporting(); |
208 } | 206 } |
209 | 207 |
210 } // namespace remoting | 208 } // namespace remoting |
OLD | NEW |