Commit 20579950 authored by Clark DuVall's avatar Clark DuVall Committed by Commit Bot

Followup fixes for OfflinePageRequestHandlerTest

These are from comments in http://crrev.com/c/1716098

Bug: 824840
Change-Id: Id7375a24d84af8a06c0bea6a19e82bed2acfb95e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1719573Reviewed-by: default avatarJian Li <jianli@chromium.org>
Commit-Queue: Clark DuVall <cduvall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#681087}
parent 68c182b9
...@@ -100,7 +100,7 @@ const int64_t kDownloadId = 42LL; ...@@ -100,7 +100,7 @@ const int64_t kDownloadId = 42LL;
// Returns the thread the navigation URL loader will run on. This determines // Returns the thread the navigation URL loader will run on. This determines
// where the OfflinePageURLLoader should be created. // where the OfflinePageURLLoader should be created.
content::BrowserThread::ID GetNavigationLoaderThread() { content::BrowserThread::ID GetNavigationLoaderThreadID() {
return base::FeatureList::IsEnabled(features::kNavigationLoaderOnUI) return base::FeatureList::IsEnabled(features::kNavigationLoaderOnUI)
? content::BrowserThread::UI ? content::BrowserThread::UI
: content::BrowserThread::IO; : content::BrowserThread::IO;
...@@ -981,7 +981,7 @@ void OfflinePageURLLoaderBuilder::InterceptRequestOnLoaderThread( ...@@ -981,7 +981,7 @@ void OfflinePageURLLoaderBuilder::InterceptRequestOnLoaderThread(
const std::string& method, const std::string& method,
const net::HttpRequestHeaders& extra_headers, const net::HttpRequestHeaders& extra_headers,
bool is_main_frame) { bool is_main_frame) {
DCHECK_CURRENTLY_ON(GetNavigationLoaderThread()); DCHECK_CURRENTLY_ON(GetNavigationLoaderThreadID());
client_ = std::make_unique<TestURLLoaderClient>(this); client_ = std::make_unique<TestURLLoaderClient>(this);
...@@ -1011,7 +1011,7 @@ void OfflinePageURLLoaderBuilder::InterceptRequest( ...@@ -1011,7 +1011,7 @@ void OfflinePageURLLoaderBuilder::InterceptRequest(
bool is_main_frame) { bool is_main_frame) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI); DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
if (base::FeatureList::IsEnabled(features::kNavigationLoaderOnUI)) { if (GetNavigationLoaderThreadID() == content::BrowserThread::UI) {
InterceptRequestOnLoaderThread(url, method, extra_headers, is_main_frame); InterceptRequestOnLoaderThread(url, method, extra_headers, is_main_frame);
} else { } else {
base::PostTaskWithTraits( base::PostTaskWithTraits(
...@@ -1026,7 +1026,7 @@ void OfflinePageURLLoaderBuilder::InterceptRequest( ...@@ -1026,7 +1026,7 @@ void OfflinePageURLLoaderBuilder::InterceptRequest(
void OfflinePageURLLoaderBuilder::MaybeStartLoader( void OfflinePageURLLoaderBuilder::MaybeStartLoader(
const network::ResourceRequest& request, const network::ResourceRequest& request,
content::URLLoaderRequestInterceptor::RequestHandler request_handler) { content::URLLoaderRequestInterceptor::RequestHandler request_handler) {
DCHECK_CURRENTLY_ON(GetNavigationLoaderThread()); DCHECK_CURRENTLY_ON(GetNavigationLoaderThreadID());
if (!request_handler) { if (!request_handler) {
ReadCompletedOnLoaderThread(ResponseInfo(net::ERR_FAILED)); ReadCompletedOnLoaderThread(ResponseInfo(net::ERR_FAILED));
...@@ -1087,7 +1087,7 @@ void OfflinePageURLLoaderBuilder::OnHandleReady( ...@@ -1087,7 +1087,7 @@ void OfflinePageURLLoaderBuilder::OnHandleReady(
void OfflinePageURLLoaderBuilder::ReadCompletedOnLoaderThread( void OfflinePageURLLoaderBuilder::ReadCompletedOnLoaderThread(
const ResponseInfo& response) { const ResponseInfo& response) {
DCHECK_CURRENTLY_ON(GetNavigationLoaderThread()); DCHECK_CURRENTLY_ON(GetNavigationLoaderThreadID());
handle_watcher_.reset(); handle_watcher_.reset();
client_.reset(); client_.reset();
...@@ -1100,7 +1100,7 @@ void OfflinePageURLLoaderBuilder::ReadCompletedOnLoaderThread( ...@@ -1100,7 +1100,7 @@ void OfflinePageURLLoaderBuilder::ReadCompletedOnLoaderThread(
if (offline_page_data && offline_page_data->is_offline_page()) if (offline_page_data && offline_page_data->is_offline_page())
is_offline_page_set_in_navigation_data = true; is_offline_page_set_in_navigation_data = true;
if (base::FeatureList::IsEnabled(features::kNavigationLoaderOnUI)) { if (GetNavigationLoaderThreadID() == content::BrowserThread::UI) {
test()->ReadCompleted(response, is_offline_page_set_in_navigation_data); test()->ReadCompleted(response, is_offline_page_set_in_navigation_data);
} else { } else {
base::PostTaskWithTraits( base::PostTaskWithTraits(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment