Chromium Code Reviews| Index: chrome_frame/chrome_frame_reporting.h |
| diff --git a/chrome_frame/chrome_frame_reporting.h b/chrome_frame/chrome_frame_reporting.h |
| index 94bfbdc8a3fd02a5e75d6ed44613bf87102e8f7f..2c2f86645bbdb190ab2ca2ae0cb1466bf022916d 100644 |
| --- a/chrome_frame/chrome_frame_reporting.h |
| +++ b/chrome_frame/chrome_frame_reporting.h |
| @@ -8,16 +8,71 @@ |
| #ifndef CHROME_FRAME_CHROME_FRAME_REPORTING_H_ |
| #define CHROME_FRAME_CHROME_FRAME_REPORTING_H_ |
| -#include "chrome_frame/crash_reporting/crash_report.h" |
| +#include "base/basictypes.h" |
| +#include "base/synchronization/lock.h" |
| -extern const wchar_t kSystemPrincipalSid[]; |
| +namespace base { |
| +template<typename Type> struct DefaultLazyInstanceTraits; |
| +} |
| -// Intialize crash reporting for Chrome Frame. Specific parameters here include |
| -// using the temp directory for dumps, determining if the install is system |
| -// wide or user specific, and customized client info. |
| -bool InitializeCrashReporting(); |
| +class ScopedCrashReporting; |
| -// Shut down crash reporting for Chrome Frame. |
| -bool ShutdownCrashReporting(); |
| +// Manages crash reporting for the Chrome Frame dll. Crash reporting cannot be |
| +// reliably started or stopped when the loader lock is held, so DllMain cannot |
| +// be used to start/stop reporting. Rather, a global instance of this class is |
| +// used. Each entrypoint into the dll must create a ScopedCrashReporting |
| +// instance on the stack. Crash reporting is automatically started when the |
| +// first such scoper is created and will ordinarily be stopped when the last one |
| +// is destroyed. If any scoper's Commit method is invoked, crash reporting will |
| +// stay running even after all scopers have gone away. This is the case when |
| +// objects have been returned by DllGetClassObject. Crash reporting will |
| +// continue to run until Decommit is called. |
| +class CrashReportingManager { |
| + public: |
| + // Causes crash reporting to be shut down either immediately or when the last |
| + // scoper is destroyed. |
| + static void Decommit(); |
|
robertshield
2013/03/06 13:50:32
nit: it seems slightly odd to have the public Comm
|
| + |
| + private: |
| + friend class ScopedCrashReporting; |
| + friend struct base::DefaultLazyInstanceTraits<CrashReportingManager>; |
| + |
| + CrashReportingManager(); |
| + ~CrashReportingManager(); |
| + static CrashReportingManager& Get(); |
| + void AddRef(); |
| + void Release(); |
| + void Commit(); |
| + void ShutdownIfNotCommittedAndUnreferenced(); |
| + |
| + base::Lock lock_; |
| + uint32 ref_count_; |
| + bool initialized_; |
| + bool committed_; |
| + DISALLOW_COPY_AND_ASSIGN(CrashReportingManager); |
| +}; |
| + |
| +// A class intended to be instantiated on the stack within entrypoints into the |
| +// Chrome Frame dll. Crash reporting is initialized upon construction if it is |
| +// not already running, and shut down when the last instance is destroyed unless |
| +// any such instance has invoked Commit. |
| +class ScopedCrashReporting { |
| + public: |
| + ScopedCrashReporting() : manager_(CrashReportingManager::Get()) { |
| + manager_.AddRef(); |
| + } |
| + ~ScopedCrashReporting() { |
| + manager_.Release(); |
| + } |
| + |
| + // Causes crash reporting to outlive this and all other instances. |
| + void Commit() { |
| + manager_.Commit(); |
| + } |
| + |
| + private: |
| + CrashReportingManager& manager_; |
| + DISALLOW_COPY_AND_ASSIGN(ScopedCrashReporting); |
| +}; |
| #endif // CHROME_FRAME_CHROME_FRAME_REPORTING_H_ |