Index: content/browser/loader/cross_site_resource_handler_browsertest.cc |
diff --git a/content/browser/loader/cross_site_resource_handler_browsertest.cc b/content/browser/loader/cross_site_resource_handler_browsertest.cc |
index 4f4bdccc2540583cb8c09b93f8b863fd761a0ed3..b3a434f14e3dc7ac394d4310feaf3d7f14ea607c 100644 |
--- a/content/browser/loader/cross_site_resource_handler_browsertest.cc |
+++ b/content/browser/loader/cross_site_resource_handler_browsertest.cc |
@@ -10,6 +10,7 @@ |
#include "base/single_thread_task_runner.h" |
#include "base/threading/thread_task_runner_handle.h" |
#include "content/browser/frame_host/render_frame_host_impl.h" |
+#include "content/browser/loader/loader_globals.h" |
#include "content/browser/loader/resource_dispatcher_host_impl.h" |
#include "content/browser/web_contents/web_contents_impl.h" |
#include "content/common/frame_messages.h" |
@@ -46,7 +47,9 @@ class TestResourceDispatcherHostDelegate |
AppCacheService* appcache_service, |
ResourceType resource_type, |
std::vector<std::unique_ptr<ResourceThrottle>>* throttles) override { |
- CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
jam
2017/03/29 15:44:32
this file isn't going to moveee (browser tests nee
ananta
2017/03/29 19:41:04
ok. thanks. done
|
+ CHECK(LoaderGlobals::Get() |
+ ->io_thread_task_runner() |
+ ->BelongsToCurrentThread()); |
ShellResourceDispatcherHostDelegate::RequestBeginning( |
request, resource_context, appcache_service, resource_type, throttles); |
@@ -65,7 +68,9 @@ class TestResourceDispatcherHostDelegate |
// must have been made and deleted before calling this function. |
void SetTrackedURL(const GURL& tracked_url, |
const RequestDeferredHook& run_on_start) { |
- CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
+ CHECK(LoaderGlobals::Get() |
+ ->main_thread_task_runner() |
+ ->BelongsToCurrentThread()); |
// Should not currently be tracking any URL. |
ASSERT_FALSE(run_loop_); |
@@ -74,8 +79,8 @@ class TestResourceDispatcherHostDelegate |
// other events. |
run_loop_.reset(new base::RunLoop()); |
- BrowserThread::PostTask( |
- BrowserThread::IO, FROM_HERE, |
+ LoaderGlobals::Get()->io_thread_task_runner()->PostTask( |
+ FROM_HERE, |
base::Bind(&TestResourceDispatcherHostDelegate::SetTrackedURLOnIOThread, |
base::Unretained(this), tracked_url, run_on_start, |
run_loop_->QuitClosure())); |
@@ -84,7 +89,9 @@ class TestResourceDispatcherHostDelegate |
// Waits until the tracked URL has been requested, and the request for it has |
// been destroyed. |
bool WaitForTrackedURLAndGetCompleted() { |
- CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
+ CHECK(LoaderGlobals::Get() |
+ ->main_thread_task_runner() |
+ ->BelongsToCurrentThread()); |
run_loop_->Run(); |
run_loop_.reset(); |
return tracked_request_completed_; |
@@ -108,12 +115,12 @@ class TestResourceDispatcherHostDelegate |
void WillStartRequest(bool* defer) override { |
*defer = true; |
base::Closure resume_request_on_io_thread = base::Bind( |
- base::IgnoreResult(&BrowserThread::PostTask), BrowserThread::IO, |
- FROM_HERE, base::Bind(&CallbackRunningResourceThrottle::MarkAndResume, |
- weak_factory_.GetWeakPtr())); |
- BrowserThread::PostTask( |
- BrowserThread::UI, FROM_HERE, |
- base::Bind(run_on_start_, resume_request_on_io_thread)); |
+ base::IgnoreResult(&base::SingleThreadTaskRunner::PostTask), |
+ LoaderGlobals::Get()->io_thread_task_runner().get(), FROM_HERE, |
+ base::Bind(&CallbackRunningResourceThrottle::MarkAndResume, |
+ weak_factory_.GetWeakPtr())); |
+ LoaderGlobals::Get()->main_thread_task_runner()->PostTask( |
+ FROM_HERE, base::Bind(run_on_start_, resume_request_on_io_thread)); |
} |
~CallbackRunningResourceThrottle() override { |
@@ -150,7 +157,9 @@ class TestResourceDispatcherHostDelegate |
void SetTrackedURLOnIOThread(const GURL& tracked_url, |
const RequestDeferredHook& run_on_start, |
const base::Closure& run_loop_quit_closure) { |
- CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
+ CHECK(LoaderGlobals::Get() |
+ ->io_thread_task_runner() |
+ ->BelongsToCurrentThread()); |
throttle_created_ = false; |
tracked_url_ = tracked_url; |
run_on_start_ = run_on_start; |
@@ -158,13 +167,15 @@ class TestResourceDispatcherHostDelegate |
} |
void OnTrackedRequestDestroyed(bool completed) { |
- CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
+ CHECK(LoaderGlobals::Get() |
+ ->io_thread_task_runner() |
+ ->BelongsToCurrentThread()); |
tracked_request_completed_ = completed; |
tracked_url_ = GURL(); |
run_on_start_ = RequestDeferredHook(); |
- BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
- run_loop_quit_closure_); |
+ LoaderGlobals::Get()->main_thread_task_runner()->PostTask( |
+ FROM_HERE, run_loop_quit_closure_); |
} |
// These live on the IO thread. |
@@ -189,8 +200,8 @@ class CrossSiteResourceHandlerTest : public ContentBrowserTest { |
// ContentBrowserTest implementation: |
void SetUpOnMainThread() override { |
- BrowserThread::PostTask( |
- BrowserThread::IO, FROM_HERE, |
+ LoaderGlobals::Get()->io_thread_task_runner()->PostTask( |
+ FROM_HERE, |
base::Bind( |
&CrossSiteResourceHandlerTest::InjectResourceDispatcherHostDelegate, |
base::Unretained(this))); |
@@ -200,11 +211,10 @@ class CrossSiteResourceHandlerTest : public ContentBrowserTest { |
} |
void TearDownOnMainThread() override { |
- BrowserThread::PostTask( |
- BrowserThread::IO, FROM_HERE, |
- base::Bind(&CrossSiteResourceHandlerTest:: |
- RestoreResourceDispatcherHostDelegate, |
- base::Unretained(this))); |
+ LoaderGlobals::Get()->io_thread_task_runner()->PostTask( |
+ FROM_HERE, base::Bind(&CrossSiteResourceHandlerTest:: |
+ RestoreResourceDispatcherHostDelegate, |
+ base::Unretained(this))); |
} |
protected: |
@@ -213,13 +223,17 @@ class CrossSiteResourceHandlerTest : public ContentBrowserTest { |
} |
void InjectResourceDispatcherHostDelegate() { |
- DCHECK_CURRENTLY_ON(BrowserThread::IO); |
+ DCHECK(LoaderGlobals::Get() |
+ ->io_thread_task_runner() |
+ ->BelongsToCurrentThread()); |
old_delegate_ = ResourceDispatcherHostImpl::Get()->delegate(); |
ResourceDispatcherHostImpl::Get()->SetDelegate(&tracking_delegate_); |
} |
void RestoreResourceDispatcherHostDelegate() { |
- DCHECK_CURRENTLY_ON(BrowserThread::IO); |
+ DCHECK(LoaderGlobals::Get() |
+ ->io_thread_task_runner() |
+ ->BelongsToCurrentThread()); |
ResourceDispatcherHostImpl::Get()->SetDelegate(old_delegate_); |
old_delegate_ = nullptr; |
} |