mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-02-09 08:38:41 +01:00
Implement ResourceLoaderBridge::SetDefersLoading (issue #448).
git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@405 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
parent
a254639d2b
commit
8433529a00
@ -144,7 +144,9 @@ class RequestProxy : public net::URLRequest::Delegate,
|
|||||||
: download_to_file_(false),
|
: download_to_file_(false),
|
||||||
buf_(new net::IOBuffer(kDataSize)),
|
buf_(new net::IOBuffer(kDataSize)),
|
||||||
browser_(browser),
|
browser_(browser),
|
||||||
last_upload_position_(0)
|
last_upload_position_(0),
|
||||||
|
defers_loading_(false),
|
||||||
|
defers_loading_want_read_(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,6 +176,11 @@ class RequestProxy : public net::URLRequest::Delegate,
|
|||||||
&RequestProxy::AsyncCancel, this));
|
&RequestProxy::AsyncCancel, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetDefersLoading(bool defer) {
|
||||||
|
CefThread::PostTask(CefThread::IO, FROM_HERE, base::Bind(
|
||||||
|
&RequestProxy::AsyncSetDefersLoading, this, defer));
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
friend class base::RefCountedThreadSafe<RequestProxy>;
|
friend class base::RefCountedThreadSafe<RequestProxy>;
|
||||||
|
|
||||||
@ -572,7 +579,24 @@ class RequestProxy : public net::URLRequest::Delegate,
|
|||||||
request_->FollowDeferredRedirect();
|
request_->FollowDeferredRedirect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AsyncSetDefersLoading(bool defer) {
|
||||||
|
if (defers_loading_ != defer) {
|
||||||
|
defers_loading_ = defer;
|
||||||
|
if (!defers_loading_ && defers_loading_want_read_) {
|
||||||
|
// Perform the pending AsyncReadData now.
|
||||||
|
defers_loading_want_read_ = false;
|
||||||
|
AsyncReadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void AsyncReadData() {
|
void AsyncReadData() {
|
||||||
|
// Pause downloading if we're in deferred mode.
|
||||||
|
if (defers_loading_) {
|
||||||
|
defers_loading_want_read_ = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(resource_stream_.get()) {
|
if(resource_stream_.get()) {
|
||||||
// Read from the handler-provided resource stream
|
// Read from the handler-provided resource stream
|
||||||
int bytes_read = resource_stream_->Read(buf_->data(), 1, kDataSize);
|
int bytes_read = resource_stream_->Read(buf_->data(), 1, kDataSize);
|
||||||
@ -854,6 +878,12 @@ class RequestProxy : public net::URLRequest::Delegate,
|
|||||||
|
|
||||||
CefRefPtr<CefDownloadHandler> download_handler_;
|
CefRefPtr<CefDownloadHandler> download_handler_;
|
||||||
CefRefPtr<CefContentFilter> content_filter_;
|
CefRefPtr<CefContentFilter> content_filter_;
|
||||||
|
|
||||||
|
// True if loading of data is currently deferred.
|
||||||
|
bool defers_loading_;
|
||||||
|
|
||||||
|
// True if an AsyncReadData was scheduled while we were deferred.
|
||||||
|
bool defers_loading_want_read_;
|
||||||
};
|
};
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -1004,7 +1034,8 @@ class ResourceLoaderBridgeImpl : public ResourceLoaderBridge {
|
|||||||
}
|
}
|
||||||
|
|
||||||
virtual void SetDefersLoading(bool value) OVERRIDE {
|
virtual void SetDefersLoading(bool value) OVERRIDE {
|
||||||
// TODO(darin): implement me
|
DCHECK(proxy_);
|
||||||
|
proxy_->SetDefersLoading(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void SyncLoad(SyncLoadResponse* response) OVERRIDE {
|
virtual void SyncLoad(SyncLoadResponse* response) OVERRIDE {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user