Chromium Code Reviews| Index: chrome_frame/chrome_tab.cc |
| diff --git a/chrome_frame/chrome_tab.cc b/chrome_frame/chrome_tab.cc |
| index 8b25a054daa7169bcf04aff5e838e1e385dde406..d0366baea0fe32c1d9f7bc14606803ab712d74eb 100644 |
| --- a/chrome_frame/chrome_tab.cc |
| +++ b/chrome_frame/chrome_tab.cc |
| @@ -11,6 +11,7 @@ |
| #include <objbase.h> |
| #include "base/at_exit.h" |
| +#include "base/basictypes.h" |
| #include "base/command_line.h" |
| #include "base/file_util.h" |
| #include "base/file_version_info.h" |
| @@ -48,16 +49,6 @@ |
| using base::win::RegKey; |
| namespace { |
| -// This function has the side effect of initializing an unprotected |
| -// vector pointer inside GoogleUrl. If this is called during DLL loading, |
| -// it has the effect of avoiding an initialization race on that pointer. |
| -// TODO(siggi): fix GoogleUrl. |
| -void InitGoogleUrl() { |
| - static const char kDummyUrl[] = "http://www.google.com"; |
| - |
| - url_util::IsStandard(kDummyUrl, |
| - url_parse::MakeRange(0, arraysize(kDummyUrl))); |
| -} |
| const wchar_t kInternetSettings[] = |
| L"Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings"; |
| @@ -83,7 +74,7 @@ const wchar_t kChromeFrameHelperWindowName[] = |
| L"ChromeFrameHelperWindowName"; |
| // {0562BFC3-2550-45b4-BD8E-A310583D3A6F} |
| -static const GUID kChromeFrameProvider = |
| +const GUID kChromeFrameProvider = |
| { 0x562bfc3, 0x2550, 0x45b4, |
| { 0xbd, 0x8e, 0xa3, 0x10, 0x58, 0x3d, 0x3a, 0x6f } }; |
| @@ -95,6 +86,17 @@ const wchar_t kChromeFramePrefix[] = L"chromeframe/"; |
| // See comments in DllGetClassObject. |
| LPFNGETCLASSOBJECT g_dll_get_class_object_redir_ptr = NULL; |
| +// This function has the side effect of initializing an unprotected |
| +// vector pointer inside GoogleUrl. If this is called during DLL loading, |
| +// it has the effect of avoiding an initialization race on that pointer. |
| +// TODO(siggi): fix GoogleUrl. |
| +void InitGoogleUrl() { |
| + static const char kDummyUrl[] = "http://www.google.com"; |
| + |
| + url_util::IsStandard(kDummyUrl, |
| + url_parse::MakeRange(0, arraysize(kDummyUrl))); |
| +} |
| + |
| class ChromeTabModule : public CAtlDllModuleT<ChromeTabModule> { |
| public: |
| typedef CAtlDllModuleT<ChromeTabModule> ParentClass; |
| @@ -189,6 +191,16 @@ class ChromeTabModule : public CAtlDllModuleT<ChromeTabModule> { |
| return hr; |
| } |
| + virtual LONG Unlock() throw() |
| + { |
|
robertshield
2013/03/12 03:16:49
nit: should the { not be on the previous line?
grt (UTC plus 2)
2013/03/12 14:45:51
Done.
|
| + // Stop crash reporting if the module is fully unlocked. Reporting is |
| + // started in DllGetClassObject. |
| + LONG result = ParentClass::Unlock(); |
| + if (!result) |
| + chrome_frame::ScopedCrashReporting().Decommit(); |
| + return result; |
| + } |
| + |
| // See comments in AddCommonRGSReplacements |
| bool do_system_registration_; |
| }; |
| @@ -829,7 +841,6 @@ extern "C" BOOL WINAPI DllMain(HINSTANCE instance, |
| g_exit_manager = new base::AtExitManager(); |
| CommandLine::Init(0, NULL); |
| - InitializeCrashReporting(); |
| logging::InitLogging( |
| NULL, |
| logging::LOG_ONLY_TO_SYSTEM_DEBUG_LOG, |
| @@ -874,8 +885,6 @@ extern "C" BOOL WINAPI DllMain(HINSTANCE instance, |
| delete g_exit_manager; |
| g_exit_manager = NULL; |
| - |
| - ShutdownCrashReporting(); |
| } |
| return _AtlModule.DllMain(reason, reserved); |
| } |
| @@ -887,6 +896,8 @@ STDAPI DllCanUnloadNow() { |
| // Returns a class factory to create an object of the requested type |
| STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv) { |
| + chrome_frame::ScopedCrashReporting crash_reporting; |
| + |
| // If we found another module present when we were loaded, then delegate to |
| // that: |
| if (g_dll_get_class_object_redir_ptr) { |
| @@ -895,15 +906,22 @@ STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv) { |
| // Enable sniffing and switching only if asked for BHO |
| // (we use BHO to get loaded in IE). |
| - if (rclsid == CLSID_ChromeFrameBHO) { |
| + if (rclsid == CLSID_ChromeFrameBHO) |
| g_patch_helper.InitializeAndPatchProtocolsIfNeeded(); |
| - } |
| - return _AtlModule.DllGetClassObject(rclsid, riid, ppv); |
| + HRESULT hr = _AtlModule.DllGetClassObject(rclsid, riid, ppv); |
| + |
| + // Keep crash reporting going if an instance is being returned. It will be |
| + // stopped in ChromeTabModule::Unlock when the last object is destroyed. |
| + if (SUCCEEDED(hr) && *ppv) |
| + crash_reporting.Commit(); |
| + |
| + return hr; |
| } |
| // DllRegisterServer - Adds entries to the system registry |
| STDAPI DllRegisterServer() { |
| + chrome_frame::ScopedCrashReporting crash_reporting; |
| uint16 flags = ACTIVEX | ACTIVEDOC | TYPELIB | GCF_PROTOCOL | |
| BHO_CLSID | BHO_REGISTRATION; |
| @@ -917,12 +935,14 @@ STDAPI DllRegisterServer() { |
| // DllUnregisterServer - Removes entries from the system registry |
| STDAPI DllUnregisterServer() { |
| + chrome_frame::ScopedCrashReporting crash_reporting; |
| HRESULT hr = CustomRegistration(ALL, false, true); |
| return hr; |
| } |
| // DllRegisterUserServer - Adds entries to the HKCU hive in the registry. |
| STDAPI DllRegisterUserServer() { |
| + chrome_frame::ScopedCrashReporting crash_reporting; |
| UINT flags = ACTIVEX | ACTIVEDOC | TYPELIB | GCF_PROTOCOL | |
| BHO_CLSID | BHO_REGISTRATION; |
| @@ -936,6 +956,7 @@ STDAPI DllRegisterUserServer() { |
| // DllUnregisterUserServer - Removes entries from the HKCU hive in the registry. |
| STDAPI DllUnregisterUserServer() { |
| + chrome_frame::ScopedCrashReporting crash_reporting; |
| HRESULT hr = CustomRegistration(ALL, FALSE, false); |
| return hr; |
| } |