With the ChromeFrame moniker patch on, the data cache maintained to indicate whether we should switch to Chrome, was not being
drained correctly to the delegate, resulting in the delegate continuing to wait for more data when there was none. This caused
sites like go/wave to not redirect correctly to CF.
Fixes bug http://code.google.com/p/chromium/issues/detail?id=41365
Bug=41365
Review URL: http://codereview.chromium.org/1637017
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@44735 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome_frame/bind_context_info.h b/chrome_frame/bind_context_info.h
index e66d450..5e0186bf 100644
--- a/chrome_frame/bind_context_info.h
+++ b/chrome_frame/bind_context_info.h
@@ -51,8 +51,6 @@
return cache_;
}
- void set_cache(IStream* cache);
-
private:
ScopedComPtr<IStream> cache_;
bool no_cache_;
diff --git a/chrome_frame/test/urlmon_moniker_unittest.cc b/chrome_frame/test/urlmon_moniker_unittest.cc
index f50bd86..ba1b132 100644
--- a/chrome_frame/test/urlmon_moniker_unittest.cc
+++ b/chrome_frame/test/urlmon_moniker_unittest.cc
@@ -74,7 +74,7 @@
// Test 2: Read from initialized cache
CComObjectStackEx<CacheStream> cache_stream2;
- cache_stream2.Initialize(data, sizeof(data));
+ cache_stream2.Initialize(data, sizeof(data), false);
EXPECT_HRESULT_SUCCEEDED(cache_stream2.Read(ret, sizeof(ret), &read));
EXPECT_EQ(sizeof(data), read);
EXPECT_EQ(std::string(data), std::string(ret));
@@ -112,7 +112,7 @@
Return(S_OK)));
EXPECT_HRESULT_SUCCEEDED(CacheStream::BSCBFeedData(&mock, data, size, cf,
- flags));
+ flags, false));
EXPECT_HRESULT_SUCCEEDED(ret1);
EXPECT_STREQ(data, read_buffer1);
diff --git a/chrome_frame/urlmon_bind_status_callback.cc b/chrome_frame/urlmon_bind_status_callback.cc
index 6f85210..c870f7ad 100644
--- a/chrome_frame/urlmon_bind_status_callback.cc
+++ b/chrome_frame/urlmon_bind_status_callback.cc
@@ -20,7 +20,7 @@
// CacheStream instance.
HRESULT CacheStream::BSCBFeedData(IBindStatusCallback* bscb, const char* data,
size_t size, CLIPFORMAT clip_format,
- size_t flags) {
+ size_t flags, bool eof) {
if (!bscb) {
NOTREACHED() << "invalid IBindStatusCallback";
return E_INVALIDARG;
@@ -36,7 +36,7 @@
}
cache_stream->AddRef();
- cache_stream->Initialize(data, size);
+ cache_stream->Initialize(data, size, eof);
FORMATETC format_etc = { clip_format, NULL, DVASPECT_CONTENT, -1,
TYMED_ISTREAM };
@@ -50,10 +50,11 @@
return hr;
}
-void CacheStream::Initialize(const char* cache, size_t size) {
+void CacheStream::Initialize(const char* cache, size_t size, bool eof) {
cache_ = cache;
size_ = size;
position_ = 0;
+ eof_ = eof;
}
// Read is the only call that we expect. Return E_PENDING if there
@@ -64,7 +65,7 @@
return E_INVALIDARG;
// Default to E_PENDING to signal that this is a partial data.
- HRESULT hr = E_PENDING;
+ HRESULT hr = eof_ ? S_FALSE : E_PENDING;
if (position_ < size_) {
*read = std::min(size_ - position_, size_t(cb));
memcpy(pv, cache_ + position_, *read);
@@ -114,6 +115,7 @@
}
bool last_chance = force_determination || (size() >= kMaxSniffSize);
+ eof_ = force_determination;
DetermineRendererType(last_chance);
return hr;
}
@@ -131,7 +133,8 @@
HRESULT hr = GetHGlobalFromStream(cache_, &memory);
if (SUCCEEDED(hr) && memory) {
char* buffer = reinterpret_cast<char*>(GlobalLock(memory));
- hr = CacheStream::BSCBFeedData(bscb, buffer, size_, clip_format, bscf);
+ hr = CacheStream::BSCBFeedData(bscb, buffer, size_, clip_format, bscf,
+ eof_);
GlobalUnlock(memory);
}
diff --git a/chrome_frame/urlmon_bind_status_callback.h b/chrome_frame/urlmon_bind_status_callback.h
index 8f33252..0ecf51f1 100644
--- a/chrome_frame/urlmon_bind_status_callback.h
+++ b/chrome_frame/urlmon_bind_status_callback.h
@@ -21,12 +21,12 @@
COM_INTERFACE_ENTRY(ISequentialStream)
END_COM_MAP()
- CacheStream() : cache_(NULL), size_(0), position_(0) {
+ CacheStream() : cache_(NULL), size_(0), position_(0), eof_(false) {
}
- void Initialize(const char* cache, size_t size);
+ void Initialize(const char* cache, size_t size, bool eof);
static HRESULT BSCBFeedData(IBindStatusCallback* bscb, const char* data,
size_t size, CLIPFORMAT clip_format,
- size_t flags);
+ size_t flags, bool eof);
// IStream overrides
STDMETHOD(Read)(void* pv, ULONG cb, ULONG* read);
@@ -35,6 +35,7 @@
const char* cache_;
size_t size_;
size_t position_;
+ bool eof_;
private:
DISALLOW_COPY_AND_ASSIGN(CacheStream);
@@ -43,7 +44,7 @@
// Utility class for data sniffing
class SniffData {
public:
- SniffData() : renderer_type_(OTHER), size_(0) {}
+ SniffData() : renderer_type_(OTHER), size_(0), eof_(false) {}
enum RendererType {
UNDETERMINED,
@@ -82,6 +83,7 @@
size_t size_;
static const size_t kMaxSniffSize = 2 * 1024;
+ bool eof_;
private:
DISALLOW_COPY_AND_ASSIGN(SniffData);