diff options
author | tommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-13 20:05:21 +0000 |
---|---|---|
committer | tommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-13 20:05:21 +0000 |
commit | 87b1942db3bfe2dd9d3a07f15c7abd854ddd1785 (patch) | |
tree | 2f093b5e70f1928723938e185a6caa3f00630e80 | |
parent | 009557c3a5dabcdbf8dd55787611ddd651399f4d (diff) | |
download | chromium_src-87b1942db3bfe2dd9d3a07f15c7abd854ddd1785.zip chromium_src-87b1942db3bfe2dd9d3a07f15c7abd854ddd1785.tar.gz chromium_src-87b1942db3bfe2dd9d3a07f15c7abd854ddd1785.tar.bz2 |
Fix a race condition in InitializeAndPatchProtocolsIfNeeded as discovered by MAD.
TEST=Should fix the issue MAD saw when starting up and tearing down the host browser in quick succession. Please see bug description.
BUG=27641
Review URL: http://codereview.chromium.org/387049
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31935 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome_frame/bho.cc | 28 | ||||
-rw-r--r-- | chrome_frame/bho.h | 5 | ||||
-rw-r--r-- | chrome_frame/chrome_tab.cc | 4 |
3 files changed, 24 insertions, 13 deletions
diff --git a/chrome_frame/bho.cc b/chrome_frame/bho.cc index f18cc3e..9fff456 100644 --- a/chrome_frame/bho.cc +++ b/chrome_frame/bho.cc @@ -247,19 +247,27 @@ Bho* Bho::GetCurrentThreadBhoInstance() { return bho_current_thread_instance_.Pointer()->Get(); } -void PatchHelper::InitializeAndPatchProtocolsIfNeeded() { - if (state_ != UNKNOWN) - return; +bool PatchHelper::InitializeAndPatchProtocolsIfNeeded() { + bool ret = false; - HttpNegotiatePatch::Initialize(); + _pAtlModule->m_csStaticDataInitAndTypeInfo.Lock(); - bool patch_protocol = GetConfigBool(true, kPatchProtocols); - if (patch_protocol) { - ProtocolSinkWrap::PatchProtocolHandlers(); - state_ = PATCH_PROTOCOL; - } else { - state_ = PATCH_IBROWSER; + if (state_ == UNKNOWN) { + HttpNegotiatePatch::Initialize(); + + bool patch_protocol = GetConfigBool(true, kPatchProtocols); + if (patch_protocol) { + ProtocolSinkWrap::PatchProtocolHandlers(); + state_ = PATCH_PROTOCOL; + } else { + state_ = PATCH_IBROWSER; + } + ret = true; } + + _pAtlModule->m_csStaticDataInitAndTypeInfo.Unlock(); + + return ret; } void PatchHelper::PatchBrowserService(IBrowserService* browser_service) { diff --git a/chrome_frame/bho.h b/chrome_frame/bho.h index b5b6ec5..2838fec 100644 --- a/chrome_frame/bho.h +++ b/chrome_frame/bho.h @@ -30,7 +30,10 @@ class PatchHelper { return state_; } - void InitializeAndPatchProtocolsIfNeeded(); + // Returns true if protocols were patched, false if patching has already + // been done. + bool InitializeAndPatchProtocolsIfNeeded(); + void PatchBrowserService(IBrowserService* p); void UnpatchIfNeeded(); protected: diff --git a/chrome_frame/chrome_tab.cc b/chrome_frame/chrome_tab.cc index 01d862a..39436f4 100644 --- a/chrome_frame/chrome_tab.cc +++ b/chrome_frame/chrome_tab.cc @@ -259,8 +259,8 @@ STDAPI DllCanUnloadNow() { // Returns a class factory to create an object of the requested type STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv) { - if (g_patch_helper.state() == PatchHelper::UNKNOWN) { - g_patch_helper.InitializeAndPatchProtocolsIfNeeded(); + if (g_patch_helper.InitializeAndPatchProtocolsIfNeeded()) { + // We should only get here once. UrlMkSetSessionOption(URLMON_OPTION_USERAGENT_REFRESH, NULL, 0, 0); } |