From 37a3a4bf36aa3a07ed4982c815d427141b2aa9f8 Mon Sep 17 00:00:00 2001 From: "amit@chromium.org" Date: Wed, 14 Apr 2010 22:37:40 +0000 Subject: Sniff data for the chrome meta tag as in comes in. Doing this allows us to make an determination of the renderer type at the right time in case of the server breaking connection unexpectedly without proper end of data notification. TEST=automated tests using sub_frame1.html BUG=none Review URL: http://codereview.chromium.org/1594031 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@44567 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome_frame/urlmon_bind_status_callback.cc | 15 +++++++-------- chrome_frame/urlmon_bind_status_callback.h | 2 +- 2 files changed, 8 insertions(+), 9 deletions(-) (limited to 'chrome_frame') diff --git a/chrome_frame/urlmon_bind_status_callback.cc b/chrome_frame/urlmon_bind_status_callback.cc index cf920c2..68cf175 100644 --- a/chrome_frame/urlmon_bind_status_callback.cc +++ b/chrome_frame/urlmon_bind_status_callback.cc @@ -112,10 +112,8 @@ HRESULT SniffData::ReadIntoCache(IStream* stream, bool force_determination) { break; } - if (force_determination || (size() >= kMaxSniffSize)) { - DetermineRendererType(); - } - + bool last_chance = force_determination || (size() >= kMaxSniffSize); + DetermineRendererType(last_chance); return hr; } @@ -142,13 +140,14 @@ HRESULT SniffData::DrainCache(IBindStatusCallback* bscb, DWORD bscf, } // Scan the buffer or OptIn URL list and decide if the renderer is -// to be switched -void SniffData::DetermineRendererType() { +// to be switched. Last chance means there's no more data. +void SniffData::DetermineRendererType(bool last_chance) { if (is_undetermined()) { + if (last_chance) + renderer_type_ = OTHER; if (IsOptInUrl(url_.c_str())) { renderer_type_ = CHROME; } else { - renderer_type_ = OTHER; if (is_cache_valid() && cache_) { HGLOBAL memory = NULL; GetHGlobalFromStream(cache_, &memory); @@ -284,7 +283,7 @@ STDMETHODIMP BSCBStorageBind::OnStopBinding(HRESULT hresult, LPCWSTR error) { HRESULT BSCBStorageBind::MayPlayBack(DWORD flags) { // Force renderer type determination if not already done since // we want to play back data now. - data_sniffer_.DetermineRendererType(); + data_sniffer_.DetermineRendererType(true); DCHECK(!data_sniffer_.is_undetermined()); HRESULT hr = S_OK; diff --git a/chrome_frame/urlmon_bind_status_callback.h b/chrome_frame/urlmon_bind_status_callback.h index c6b4ba7..2475ba1 100644 --- a/chrome_frame/urlmon_bind_status_callback.h +++ b/chrome_frame/urlmon_bind_status_callback.h @@ -55,7 +55,7 @@ class SniffData { HRESULT ReadIntoCache(IStream* stream, bool force_determination); HRESULT DrainCache(IBindStatusCallback* bscb, DWORD bscf, CLIPFORMAT clip_format); - void DetermineRendererType(); + void DetermineRendererType(bool last_chance); bool is_undetermined() const { return (UNDETERMINED == renderer_type_); -- cgit v1.1