Merge revision 1230 changes:

- Continue resource loading asynchronously to avoid issues during ResourceScheduler stack unwinding.

git-svn-id: https://chromiumembedded.googlecode.com/svn/branches/1453@1231 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt
2013-04-17 20:43:07 +00:00
parent 299fce6305
commit 755abf371c

View File

@@ -58,8 +58,32 @@ class CefResourceRequestJobCallback : public CefCallback {
dest_size_(0) {}
virtual void Continue() OVERRIDE {
if (CEF_CURRENTLY_ON_IOT()) {
// Currently on IO thread.
// Continue asynchronously.
CEF_POST_TASK(CEF_IOT,
base::Bind(&CefResourceRequestJobCallback::ContinueOnIOThread, this));
}
virtual void Cancel() OVERRIDE {
// Cancel asynchronously.
CEF_POST_TASK(CEF_IOT,
base::Bind(&CefResourceRequestJobCallback::CancelOnIOThread, this));
}
void Detach() {
CEF_REQUIRE_IOT();
job_ = NULL;
}
void SetDestination(net::IOBuffer* dest, int dest_size) {
CEF_REQUIRE_IOT();
dest_ = dest;
dest_size_ = dest_size;
}
private:
void ContinueOnIOThread() {
CEF_REQUIRE_IOT();
// Return early if the callback has already been detached.
if (!job_)
return;
@@ -103,37 +127,15 @@ class CefResourceRequestJobCallback : public CefCallback {
}
}
}
} else {
// Execute this method on the IO thread.
CEF_POST_TASK(CEF_IOT,
base::Bind(&CefResourceRequestJobCallback::Continue, this));
}
}
virtual void Cancel() OVERRIDE {
if (CEF_CURRENTLY_ON_IOT()) {
// Currently on IO thread.
void CancelOnIOThread() {
CEF_REQUIRE_IOT();
if (job_)
job_->Kill();
} else {
// Execute this method on the IO thread.
CEF_POST_TASK(CEF_IOT,
base::Bind(&CefResourceRequestJobCallback::Cancel, this));
}
}
void Detach() {
CEF_REQUIRE_IOT();
job_ = NULL;
}
void SetDestination(net::IOBuffer* dest, int dest_size) {
CEF_REQUIRE_IOT();
dest_ = dest;
dest_size_ = dest_size;
}
private:
CefResourceRequestJob* job_;
Type type_;