1 // Copyright 2007, Google Inc.
3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions are met:
6 // 1. Redistributions of source code must retain the above copyright notice,
7 // this list of conditions and the following disclaimer.
8 // 2. Redistributions in binary form must reproduce the above copyright notice,
9 // this list of conditions and the following disclaimer in the documentation
10 // and/or other materials provided with the distribution.
11 // 3. Neither the name of Google Inc. nor the names of its contributors may be
12 // used to endorse or promote products derived from this software without
13 // specific prior written permission.
15 // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
16 // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
17 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
18 // EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
19 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
21 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
22 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
23 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
24 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 // Wrapper class for using the Breakpad crash reporting system.
28 // Be sure to modify kCrashReportProduct* in the .cc file to suit your project.
30 // To use this wrapper, you must also add this to your include path:
32 // And link with these files:
33 // /breakpad/src/client/windows/handler/exception_handler.cc
34 // /breakpad/src/client/windows/sender/crash_report_sender.cc
35 // /breakpad/src/common/windows/guid_string.cc
36 // /breakpad/src/common/windows/http_upload.cc
38 #ifndef GEARS_BASE_COMMON_EXCEPTION_HANDLER_WIN32_H__
39 #define GEARS_BASE_COMMON_EXCEPTION_HANDLER_WIN32_H__
41 // TODO(michaeln): rename this file to exception_handler.h
42 #if defined(WIN32) && !defined(WINCE)
44 namespace google_breakpad
{
45 class ExceptionHandler
;
50 // static ExceptionManager exception_manager(false);
51 // exception_manager.StartMonitoring();
54 class ExceptionManager
{
56 // If catch_entire_process is true, then all minidumps are captured.
57 // Otherwise, only crashes in this module are captured.
58 // Use the latter when running inside IE or Firefox.
59 // StartMonitoring needs to be called before any minidumps are captured.
60 ExceptionManager(bool catch_entire_process
);
63 // Starts monitoring for crashes. When a crash occurs a minidump will
64 // automatically be captured and sent.
65 void StartMonitoring();
67 // Manually captures and sends a minidump, returns true on success.
68 // If StartMonitoring has not been called, no minidump is sent and
70 static bool CaptureAndSendMinidump();
72 // TODO(michaeln): Cleanup. The following should not be called
73 // directly, ideally these should be private methods.
74 bool catch_entire_process() { return catch_entire_process_
; }
75 static void SendMinidump(const char *minidump_filename
);
76 static bool CanSendMinidump(); // considers throttling
79 static ExceptionManager
*instance_
;
81 bool catch_entire_process_
;
82 google_breakpad::ExceptionHandler
*exception_handler_
;
87 // Stub to allow compilation on OS'es for which we do not yet
88 // implement crash reporting.
89 class ExceptionManager
{
91 ExceptionManager(bool catch_entire_process
) {}
92 void StartMonitoring() {}
93 static bool CaptureAndSendMinidump() { return false; }
97 #endif // GEARS_BASE_COMMON_EXCEPTION_HANDLER_WIN32_H__