mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-02-03 04:27:43 +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),
|
||||
buf_(new net::IOBuffer(kDataSize)),
|
||||
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));
|
||||
}
|
||||
|
||||
void SetDefersLoading(bool defer) {
|
||||
CefThread::PostTask(CefThread::IO, FROM_HERE, base::Bind(
|
||||
&RequestProxy::AsyncSetDefersLoading, this, defer));
|
||||
}
|
||||
|
||||
protected:
|
||||
friend class base::RefCountedThreadSafe<RequestProxy>;
|
||||
|
||||
@ -572,7 +579,24 @@ class RequestProxy : public net::URLRequest::Delegate,
|
||||
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() {
|
||||
// Pause downloading if we're in deferred mode.
|
||||
if (defers_loading_) {
|
||||
defers_loading_want_read_ = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if(resource_stream_.get()) {
|
||||
// Read from the handler-provided resource stream
|
||||
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<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 {
|
||||
// TODO(darin): implement me
|
||||
DCHECK(proxy_);
|
||||
proxy_->SetDefersLoading(value);
|
||||
}
|
||||
|
||||
virtual void SyncLoad(SyncLoadResponse* response) OVERRIDE {
|
||||
|
Loading…
x
Reference in New Issue
Block a user