summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome_frame/bind_context_info.h4
-rw-r--r--chrome_frame/protocol_sink_wrap.cc39
-rw-r--r--chrome_frame/protocol_sink_wrap.h3
3 files changed, 39 insertions, 7 deletions
diff --git a/chrome_frame/bind_context_info.h b/chrome_frame/bind_context_info.h
index 1778604..4b08505 100644
--- a/chrome_frame/bind_context_info.h
+++ b/chrome_frame/bind_context_info.h
@@ -89,6 +89,10 @@ class __declspec(uuid("00000000-0000-0000-0000-000000000000")) BindContextInfo
return prot_data_;
}
+ bool has_prot_data() const {
+ return prot_data_.get() != NULL;
+ }
+
protected:
STDMETHOD(GetCppObject)(void** me) {
DCHECK(me);
diff --git a/chrome_frame/protocol_sink_wrap.cc b/chrome_frame/protocol_sink_wrap.cc
index 330e300..0c9a4ea 100644
--- a/chrome_frame/protocol_sink_wrap.cc
+++ b/chrome_frame/protocol_sink_wrap.cc
@@ -224,6 +224,15 @@ bool IsCFRequest(IBindCtx* pbc) {
return false;
}
+bool HasProtData(IBindCtx* pbc) {
+ ScopedComPtr<BindContextInfo> info;
+ BindContextInfo::FromBindContext(pbc, info.Receive());
+ bool result = false;
+ if (info)
+ result = info->has_prot_data();
+ return result;
+}
+
void PutProtData(IBindCtx* pbc, ProtData* data) {
// AddRef and Release to avoid a potential leak of a ProtData instance if
// FromBindContext fails.
@@ -317,11 +326,7 @@ ProtData::ProtData(IInternetProtocol* protocol,
ProtData::~ProtData() {
DLOG(INFO) << __FUNCTION__ << " " << this;
-
- // Remove from map.
- AutoLock lock(datamap_lock_);
- DCHECK(datamap_.end() != datamap_.find(protocol_));
- datamap_.erase(protocol_);
+ Invalidate();
}
HRESULT ProtData::Read(void* buffer, ULONG size, ULONG* size_read) {
@@ -541,6 +546,16 @@ scoped_refptr<ProtData> ProtData::DataFromProtocol(
return instance;
}
+void ProtData::Invalidate() {
+ if (protocol_) {
+ // Remove from map.
+ AutoLock lock(datamap_lock_);
+ DCHECK(datamap_.end() != datamap_.find(protocol_));
+ datamap_.erase(protocol_);
+ protocol_ = NULL;
+ }
+}
+
// This function looks for the url pattern indicating that this request needs
// to be forced into chrome frame.
// This hack is required because window.open requests from Chrome don't have
@@ -590,6 +605,12 @@ STDMETHODIMP Hook_Start(InternetProtocol_Start_Fn orig_start,
return orig_start(protocol, url, prot_sink, bind_info, flags, reserved);
}
+ scoped_refptr<ProtData> prot_data = ProtData::DataFromProtocol(protocol);
+ if (prot_data && !HasProtData(bind_ctx)) {
+ prot_data->Invalidate();
+ prot_data = NULL;
+ }
+
if (HandleAttachToExistingExternalTab(url, protocol, prot_sink, bind_ctx)) {
return S_OK;
}
@@ -598,7 +619,6 @@ STDMETHODIMP Hook_Start(InternetProtocol_Start_Fn orig_start,
return orig_start(protocol, url, prot_sink, bind_info, flags, reserved);
}
- scoped_refptr<ProtData> prot_data = ProtData::DataFromProtocol(protocol);
if (prot_data) {
DLOG(INFO) << "Found existing ProtData!";
prot_data->UpdateUrl(url);
@@ -641,6 +661,12 @@ STDMETHODIMP Hook_StartEx(InternetProtocol_StartEx_Fn orig_start_ex,
return orig_start_ex(protocol, uri, prot_sink, bind_info, flags, reserved);
}
+ scoped_refptr<ProtData> prot_data = ProtData::DataFromProtocol(protocol);
+ if (prot_data && !HasProtData(bind_ctx)) {
+ prot_data->Invalidate();
+ prot_data = NULL;
+ }
+
if (HandleAttachToExistingExternalTab(url, protocol, prot_sink, bind_ctx)) {
return S_OK;
}
@@ -649,7 +675,6 @@ STDMETHODIMP Hook_StartEx(InternetProtocol_StartEx_Fn orig_start_ex,
return orig_start_ex(protocol, uri, prot_sink, bind_info, flags, reserved);
}
- scoped_refptr<ProtData> prot_data = ProtData::DataFromProtocol(protocol);
if (prot_data) {
DLOG(INFO) << "Found existing ProtData!";
prot_data->UpdateUrl(url);
diff --git a/chrome_frame/protocol_sink_wrap.h b/chrome_frame/protocol_sink_wrap.h
index e0795e3..c10c4c5 100644
--- a/chrome_frame/protocol_sink_wrap.h
+++ b/chrome_frame/protocol_sink_wrap.h
@@ -136,6 +136,9 @@ class ProtData : public base::RefCounted<ProtData> {
return read_fun_ == NULL;
}
+ // Removes the mapping between the protocol and the ProtData.
+ void Invalidate();
+
private:
typedef std::map<IInternetProtocol*, ProtData*> ProtocolDataMap;
static ProtocolDataMap datamap_;