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 |
| 14 #include <memory> |
13 #include <string> | 15 #include <string> |
14 | 16 |
15 #include "base/atomicops.h" | 17 #include "base/atomicops.h" |
16 #include "base/file_version_info.h" | 18 #include "base/file_version_info.h" |
17 #include "base/lazy_instance.h" | 19 #include "base/lazy_instance.h" |
18 #include "base/logging.h" | 20 #include "base/logging.h" |
19 #include "base/macros.h" | 21 #include "base/macros.h" |
20 #include "base/memory/scoped_ptr.h" | |
21 #include "base/strings/utf_string_conversions.h" | 22 #include "base/strings/utf_string_conversions.h" |
22 #include "base/win/current_module.h" | 23 #include "base/win/current_module.h" |
23 #include "base/win/wrapped_window_proc.h" | 24 #include "base/win/wrapped_window_proc.h" |
24 #include "breakpad/src/client/windows/handler/exception_handler.h" | 25 #include "breakpad/src/client/windows/handler/exception_handler.h" |
25 | 26 |
26 namespace remoting { | 27 namespace remoting { |
27 void InitializeCrashReportingForTest(const wchar_t* pipe_name); | 28 void InitializeCrashReportingForTest(const wchar_t* pipe_name); |
28 } // namespace remoting | 29 } // namespace remoting |
29 | 30 |
30 namespace { | 31 namespace { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 static bool OnExceptionCallback(void* context, | 71 static bool OnExceptionCallback(void* context, |
71 EXCEPTION_POINTERS* exinfo, | 72 EXCEPTION_POINTERS* exinfo, |
72 MDRawAssertionInfo* assertion); | 73 MDRawAssertionInfo* assertion); |
73 | 74 |
74 // Crashes the process after generating a dump for the provided exception. | 75 // Crashes the process after generating a dump for the provided exception. |
75 // Note that the crash reporter should be initialized before calling this | 76 // Note that the crash reporter should be initialized before calling this |
76 // function for it to do anything. | 77 // function for it to do anything. |
77 static int OnWindowProcedureException(EXCEPTION_POINTERS* exinfo); | 78 static int OnWindowProcedureException(EXCEPTION_POINTERS* exinfo); |
78 | 79 |
79 // Breakpad's exception handler. | 80 // Breakpad's exception handler. |
80 scoped_ptr<google_breakpad::ExceptionHandler> breakpad_; | 81 std::unique_ptr<google_breakpad::ExceptionHandler> breakpad_; |
81 | 82 |
82 // This flag is used to indicate that an exception is already being handled. | 83 // This flag is used to indicate that an exception is already being handled. |
83 volatile AtomicWord handling_exception_; | 84 volatile AtomicWord handling_exception_; |
84 | 85 |
85 // The testing hook below allows overriding the crash server pipe name. | 86 // The testing hook below allows overriding the crash server pipe name. |
86 static const wchar_t* pipe_name_; | 87 static const wchar_t* pipe_name_; |
87 | 88 |
88 friend void ::remoting::InitializeCrashReportingForTest(const wchar_t*); | 89 friend void ::remoting::InitializeCrashReportingForTest(const wchar_t*); |
89 | 90 |
90 DISALLOW_COPY_AND_ASSIGN(BreakpadWin); | 91 DISALLOW_COPY_AND_ASSIGN(BreakpadWin); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 NOTREACHED(); | 138 NOTREACHED(); |
138 } | 139 } |
139 | 140 |
140 // static | 141 // static |
141 BreakpadWin* BreakpadWin::GetInstance() { | 142 BreakpadWin* BreakpadWin::GetInstance() { |
142 return &g_instance.Get(); | 143 return &g_instance.Get(); |
143 } | 144 } |
144 | 145 |
145 // Returns the Custom information to be used for crash reporting. | 146 // Returns the Custom information to be used for crash reporting. |
146 google_breakpad::CustomClientInfo* BreakpadWin::GetCustomInfo() { | 147 google_breakpad::CustomClientInfo* BreakpadWin::GetCustomInfo() { |
147 scoped_ptr<FileVersionInfo> version_info( | 148 std::unique_ptr<FileVersionInfo> version_info( |
148 FileVersionInfo::CreateFileVersionInfoForModule(CURRENT_MODULE())); | 149 FileVersionInfo::CreateFileVersionInfoForModule(CURRENT_MODULE())); |
149 | 150 |
150 static wchar_t version[64]; | 151 static wchar_t version[64]; |
151 if (version_info.get()) { | 152 if (version_info.get()) { |
152 wcscpy_s(version, version_info->product_version().c_str()); | 153 wcscpy_s(version, version_info->product_version().c_str()); |
153 } else { | 154 } else { |
154 wcscpy_s(version, kBreakpadVersionDefault); | 155 wcscpy_s(version, kBreakpadVersionDefault); |
155 } | 156 } |
156 | 157 |
157 static google_breakpad::CustomInfoEntry ver_entry( | 158 static google_breakpad::CustomInfoEntry ver_entry( |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 // Touch the object to make sure it is initialized. | 200 // Touch the object to make sure it is initialized. |
200 BreakpadWin::GetInstance(); | 201 BreakpadWin::GetInstance(); |
201 } | 202 } |
202 | 203 |
203 void InitializeCrashReportingForTest(const wchar_t* pipe_name) { | 204 void InitializeCrashReportingForTest(const wchar_t* pipe_name) { |
204 BreakpadWin::pipe_name_ = pipe_name; | 205 BreakpadWin::pipe_name_ = pipe_name; |
205 InitializeCrashReporting(); | 206 InitializeCrashReporting(); |
206 } | 207 } |
207 | 208 |
208 } // namespace remoting | 209 } // namespace remoting |
OLD | NEW |