summaryrefslogtreecommitdiffstats
path: root/webkit/tools/test_shell/simple_resource_loader_bridge.cc
diff options
context:
space:
mode:
authorfischman@chromium.org <fischman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-06 19:49:04 +0000
committerfischman@chromium.org <fischman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-06 19:49:04 +0000
commit4160ad6398451b786f9ee3207a780c0f9490c2b7 (patch)
treeb529cc0613250ff029d190e71539ff322779e803 /webkit/tools/test_shell/simple_resource_loader_bridge.cc
parent3bf580809456417a04f1de95df408acaad1d45d5 (diff)
downloadchromium_src-4160ad6398451b786f9ee3207a780c0f9490c2b7.zip
chromium_src-4160ad6398451b786f9ee3207a780c0f9490c2b7.tar.gz
chromium_src-4160ad6398451b786f9ee3207a780c0f9490c2b7.tar.bz2
Force deletion of test_shell's RequestProxy on the IO thread.
This is required by r129062. BUG=122182 Review URL: http://codereview.chromium.org/10012010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@131170 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/tools/test_shell/simple_resource_loader_bridge.cc')
-rw-r--r--webkit/tools/test_shell/simple_resource_loader_bridge.cc25
1 files changed, 20 insertions, 5 deletions
diff --git a/webkit/tools/test_shell/simple_resource_loader_bridge.cc b/webkit/tools/test_shell/simple_resource_loader_bridge.cc
index b604bab..374fb70 100644
--- a/webkit/tools/test_shell/simple_resource_loader_bridge.cc
+++ b/webkit/tools/test_shell/simple_resource_loader_bridge.cc
@@ -272,8 +272,10 @@ static const int kUpdateUploadProgressIntervalMsec = 100;
// The RequestProxy does most of its work on the IO thread. The Start and
// Cancel methods are proxied over to the IO thread, where an net::URLRequest
// object is instantiated.
-class RequestProxy : public net::URLRequest::Delegate,
- public base::RefCountedThreadSafe<RequestProxy> {
+struct DeleteOnIOThread; // See below.
+class RequestProxy
+ : public net::URLRequest::Delegate,
+ public base::RefCountedThreadSafe<RequestProxy, DeleteOnIOThread> {
public:
// Takes ownership of the params.
RequestProxy()
@@ -306,12 +308,14 @@ class RequestProxy : public net::URLRequest::Delegate,
}
protected:
+ friend class base::DeleteHelper<RequestProxy>;
friend class base::RefCountedThreadSafe<RequestProxy>;
+ friend struct DeleteOnIOThread;
virtual ~RequestProxy() {
- // If we have a request, then we'd better be on the io thread!
- DCHECK(!request_.get() ||
- MessageLoop::current() == g_io_thread->message_loop());
+ // Ensure we are deleted on the IO thread because base::Timer requires that.
+ // (guaranteed by the Traits class template parameter).
+ DCHECK(MessageLoop::current() == g_io_thread->message_loop());
}
// --------------------------------------------------------------------------
@@ -751,6 +755,17 @@ class RequestProxy : public net::URLRequest::Delegate,
scoped_ptr<net::URLRequestStatus> failed_file_request_status_;
};
+// Helper guaranteeing deletion on the IO thread (like
+// content::BrowserThread::DeleteOnIOThread, but without the dependency).
+struct DeleteOnIOThread {
+ static void Destruct(const RequestProxy* obj) {
+ if (MessageLoop::current() == g_io_thread->message_loop())
+ delete obj;
+ else
+ g_io_thread->message_loop()->DeleteSoon(FROM_HERE, obj);
+ }
+};
+
//-----------------------------------------------------------------------------
class SyncRequestProxy : public RequestProxy {