summaryrefslogtreecommitdiffstats
path: root/chrome_frame/urlmon_bind_status_callback.cc
diff options
context:
space:
mode:
authoramit@chromium.org <amit@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-05 23:46:30 +0000
committeramit@chromium.org <amit@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-05 23:46:30 +0000
commit040b800f9a064e093255e1e5e2718b1cd51275a3 (patch)
treee45d8b11ebaf139529e521503fc3a08313d8f3cd /chrome_frame/urlmon_bind_status_callback.cc
parentec140301a87ecf1ba9e70e8031ee521c002b0f32 (diff)
downloadchromium_src-040b800f9a064e093255e1e5e2718b1cd51275a3.zip
chromium_src-040b800f9a064e093255e1e5e2718b1cd51275a3.tar.gz
chromium_src-040b800f9a064e093255e1e5e2718b1cd51275a3.tar.bz2
Do not wrap the original callback if we can;t initialize sniffing cache
CreateStreamOnHGlobal may fail if the underlying GlobalAlloc fails. It has a strange behavaior where if we pass in an HGlobal, it can create more streams per process. So the fix is to: 1. not register us as a bind status callback if we cannot create a stream for sniffing data and 2. When initializing the data sniffing stream pre-create a HGlobal BUG=To be filed TEST=none Review URL: http://codereview.chromium.org/1983002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@46525 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame/urlmon_bind_status_callback.cc')
-rw-r--r--chrome_frame/urlmon_bind_status_callback.cc26
1 files changed, 15 insertions, 11 deletions
diff --git a/chrome_frame/urlmon_bind_status_callback.cc b/chrome_frame/urlmon_bind_status_callback.cc
index 851edee..354ab3f 100644
--- a/chrome_frame/urlmon_bind_status_callback.cc
+++ b/chrome_frame/urlmon_bind_status_callback.cc
@@ -79,16 +79,17 @@ STDMETHODIMP CacheStream::Read(void* pv, ULONG cb, ULONG* read) {
/////////////////////////////////////////////////////////////////////
-bool SniffData::InitializeCache(const std::wstring& url) {
+HRESULT SniffData::InitializeCache(const std::wstring& url) {
url_ = url;
renderer_type_ = UNDETERMINED;
- HRESULT hr = CreateStreamOnHGlobal(NULL, TRUE, cache_.Receive());
- if (FAILED(hr)) {
- NOTREACHED();
- return false;
- }
- return true;
+ const int kInitialSize = 4 * 1024; // 4K
+ HGLOBAL mem = GlobalAlloc(0, kInitialSize);
+ DCHECK(mem) << "GlobalAlloc failed: " << GetLastError();
+
+ HRESULT hr = CreateStreamOnHGlobal(mem, TRUE, cache_.Receive());
+ DLOG_IF(ERROR, FAILED(hr)) << "CreateStreamOnHGlobal failed: " << hr;
+ return hr;
}
HRESULT SniffData::ReadIntoCache(IStream* stream, bool force_determination) {
@@ -185,7 +186,13 @@ HRESULT BSCBStorageBind::Initialize(IMoniker* moniker, IBindCtx* bind_ctx) {
DLOG(INFO) << __FUNCTION__ << me() << StringPrintf(" tid=%i",
PlatformThread::CurrentId());
- HRESULT hr = AttachToBind(bind_ctx);
+ std::wstring url = GetActualUrlFromMoniker(moniker, bind_ctx,
+ std::wstring());
+ HRESULT hr = data_sniffer_.InitializeCache(url);
+ if (FAILED(hr))
+ return hr;
+
+ hr = AttachToBind(bind_ctx);
if (FAILED(hr)) {
NOTREACHED() << __FUNCTION__ << me() << "AttachToBind error: " << hr;
return hr;
@@ -196,9 +203,6 @@ HRESULT BSCBStorageBind::Initialize(IMoniker* moniker, IBindCtx* bind_ctx) {
return E_FAIL;
}
- std::wstring url = GetActualUrlFromMoniker(moniker, bind_ctx,
- std::wstring());
- data_sniffer_.InitializeCache(url);
return hr;
}