summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorearthdok@chromium.org <earthdok@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-19 13:14:29 +0000
committerearthdok@chromium.org <earthdok@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-19 13:14:29 +0000
commit255620da4ddf6f59947d9e77529f54ad02d9af12 (patch)
tree3259bcf1524fa26fd8099e409af35422d82f9871
parent6a1162f6cff7d33880f5e03fb9bb3909d84e7beb (diff)
downloadchromium_src-255620da4ddf6f59947d9e77529f54ad02d9af12.zip
chromium_src-255620da4ddf6f59947d9e77529f54ad02d9af12.tar.gz
chromium_src-255620da4ddf6f59947d9e77529f54ad02d9af12.tar.bz2
Remove WorkerPool dependency from URLRequestFileJob.
Make net::URLRequestFileJob pass a TaskRunner to FileStream, instead of using a deprecated FileStream constructor that depends on WorkerPool. This TaskRunner is obtained from the blocking pool where possible. Also, remove two explicit uses of WorkerPool in net/url_request/ and chrome/browser/. Removes dependency on deprecated code. Also fixes memory leaks in unit tests caused by FileStream destruction tasks not running to completion in WorkerPool. BUG=248513, 251774 Review URL: https://chromiumcodereview.appspot.com/22795006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@218273 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--android_webview/browser/net/aw_url_request_context_getter.cc7
-rw-r--r--chrome/browser/extensions/extension_protocols.cc19
-rw-r--r--chrome/browser/extensions/extension_resource_protocols.cc10
-rw-r--r--chrome/browser/io_thread.cc9
-rw-r--r--chrome/browser/net/load_timing_browsertest.cc10
-rw-r--r--chrome/browser/profiles/profile_io_data.cc7
-rw-r--r--content/shell/shell_url_request_context_getter.cc6
-rw-r--r--content/test/net/url_request_mock_http_job.cc11
-rw-r--r--content/test/net/url_request_prepackaged_interceptor.cc7
-rw-r--r--net/proxy/proxy_script_fetcher_impl_unittest.cc3
-rw-r--r--net/url_request/file_protocol_handler.cc10
-rw-r--r--net/url_request/file_protocol_handler.h10
-rw-r--r--net/url_request/url_request_context_builder.cc12
-rw-r--r--net/url_request/url_request_file_job.cc21
-rw-r--r--net/url_request/url_request_file_job.h6
-rw-r--r--net/url_request/url_request_unittest.cc337
16 files changed, 278 insertions, 207 deletions
diff --git a/android_webview/browser/net/aw_url_request_context_getter.cc b/android_webview/browser/net/aw_url_request_context_getter.cc
index eed948f..4017c18 100644
--- a/android_webview/browser/net/aw_url_request_context_getter.cc
+++ b/android_webview/browser/net/aw_url_request_context_getter.cc
@@ -14,6 +14,7 @@
#include "android_webview/browser/net/init_native_callback.h"
#include "android_webview/common/aw_switches.h"
#include "base/command_line.h"
+#include "base/threading/sequenced_worker_pool.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/cookie_store_factory.h"
@@ -123,7 +124,11 @@ net::URLRequestContext* AwURLRequestContextGetter::GetURLRequestContext() {
if (!job_factory_) {
scoped_ptr<AwURLRequestJobFactory> job_factory(new AwURLRequestJobFactory);
bool set_protocol = job_factory->SetProtocolHandler(
- chrome::kFileScheme, new net::FileProtocolHandler());
+ chrome::kFileScheme,
+ new net::FileProtocolHandler(
+ content::BrowserThread::GetBlockingPool()->
+ GetTaskRunnerWithShutdownBehavior(
+ base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)));
DCHECK(set_protocol);
set_protocol = job_factory->SetProtocolHandler(
chrome::kDataScheme, new net::DataProtocolHandler());
diff --git a/chrome/browser/extensions/extension_protocols.cc b/chrome/browser/extensions/extension_protocols.cc
index fdafe9f..25ef06b 100644
--- a/chrome/browser/extensions/extension_protocols.cc
+++ b/chrome/browser/extensions/extension_protocols.cc
@@ -19,8 +19,8 @@
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
+#include "base/threading/sequenced_worker_pool.h"
#include "base/threading/thread_restrictions.h"
-#include "base/threading/worker_pool.h"
#include "build/build_config.h"
#include "chrome/browser/extensions/extension_info_map.h"
#include "chrome/browser/extensions/image_loader.h"
@@ -35,6 +35,7 @@
#include "chrome/common/extensions/manifest_url_handler.h"
#include "chrome/common/extensions/web_accessible_resources_handler.h"
#include "chrome/common/url_constants.h"
+#include "content/public/browser/browser_thread.h"
#include "content/public/browser/resource_request_info.h"
#include "extensions/common/constants.h"
#include "extensions/common/extension_resource.h"
@@ -136,7 +137,7 @@ class URLRequestResourceBundleJob : public net::URLRequestSimpleJob {
std::string* read_mime_type = new std::string;
bool* read_result = new bool;
- bool posted = base::WorkerPool::PostTaskAndReply(
+ bool posted = content::BrowserThread::PostBlockingPoolTaskAndReply(
FROM_HERE,
base::Bind(&ReadMimeTypeFromFile, filename_,
base::Unretained(read_mime_type),
@@ -146,8 +147,7 @@ class URLRequestResourceBundleJob : public net::URLRequestSimpleJob {
mime_type, charset, data,
base::Owned(read_mime_type),
base::Owned(read_result),
- callback),
- true /* task is slow */);
+ callback));
DCHECK(posted);
return net::ERR_IO_PENDING;
@@ -251,7 +251,11 @@ class URLRequestExtensionJob : public net::URLRequestFileJob {
const base::FilePath& relative_path,
const std::string& content_security_policy,
bool send_cors_header)
- : net::URLRequestFileJob(request, network_delegate, base::FilePath()),
+ : net::URLRequestFileJob(
+ request, network_delegate, base::FilePath(),
+ content::BrowserThread::GetBlockingPool()->
+ GetTaskRunnerWithShutdownBehavior(
+ base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)),
// TODO(tc): Move all of these files into resources.pak so we don't break
// when updating on Linux.
resource_(extension_id, directory_path, relative_path),
@@ -267,7 +271,7 @@ class URLRequestExtensionJob : public net::URLRequestFileJob {
virtual void Start() OVERRIDE {
base::FilePath* read_file_path = new base::FilePath;
base::Time* last_modified_time = new base::Time();
- bool posted = base::WorkerPool::PostTaskAndReply(
+ bool posted = content::BrowserThread::PostBlockingPoolTaskAndReply(
FROM_HERE,
base::Bind(&ReadResourceFilePathAndLastModifiedTime, resource_,
base::Unretained(read_file_path),
@@ -275,8 +279,7 @@ class URLRequestExtensionJob : public net::URLRequestFileJob {
base::Bind(&URLRequestExtensionJob::OnFilePathAndLastModifiedTimeRead,
weak_factory_.GetWeakPtr(),
base::Owned(read_file_path),
- base::Owned(last_modified_time)),
- true /* task is slow */);
+ base::Owned(last_modified_time)));
DCHECK(posted);
}
diff --git a/chrome/browser/extensions/extension_resource_protocols.cc b/chrome/browser/extensions/extension_resource_protocols.cc
index 565b08b..eb75df9 100644
--- a/chrome/browser/extensions/extension_resource_protocols.cc
+++ b/chrome/browser/extensions/extension_resource_protocols.cc
@@ -7,6 +7,7 @@
#include "base/files/file_path.h"
#include "base/memory/weak_ptr.h"
#include "base/path_service.h"
+#include "base/threading/sequenced_worker_pool.h"
#include "base/threading/thread_checker.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/extensions/extension_file_util.h"
@@ -25,9 +26,12 @@ class ExtensionResourcesJob : public net::URLRequestFileJob {
public:
ExtensionResourcesJob(net::URLRequest* request,
net::NetworkDelegate* network_delegate)
- : net::URLRequestFileJob(request, network_delegate, base::FilePath()),
- weak_ptr_factory_(this) {
- }
+ : net::URLRequestFileJob(
+ request, network_delegate, base::FilePath(),
+ content::BrowserThread::GetBlockingPool()->
+ GetTaskRunnerWithShutdownBehavior(
+ base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)),
+ weak_ptr_factory_(this) {}
virtual void Start() OVERRIDE;
diff --git a/chrome/browser/io_thread.cc b/chrome/browser/io_thread.cc
index d096e43..d2745b3 100644
--- a/chrome/browser/io_thread.cc
+++ b/chrome/browser/io_thread.cc
@@ -20,6 +20,7 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
+#include "base/threading/sequenced_worker_pool.h"
#include "base/threading/thread.h"
#include "base/threading/worker_pool.h"
#include "base/time/default_tick_clock.h"
@@ -594,8 +595,12 @@ void IOThread::InitAsync() {
new net::URLRequestJobFactoryImpl());
job_factory->SetProtocolHandler(chrome::kDataScheme,
new net::DataProtocolHandler());
- job_factory->SetProtocolHandler(chrome::kFileScheme,
- new net::FileProtocolHandler());
+ job_factory->SetProtocolHandler(
+ chrome::kFileScheme,
+ new net::FileProtocolHandler(
+ content::BrowserThread::GetBlockingPool()->
+ GetTaskRunnerWithShutdownBehavior(
+ base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)));
#if !defined(DISABLE_FTP_SUPPORT)
globals_->proxy_script_fetcher_ftp_transaction_factory.reset(
new net::FtpNetworkLayer(globals_->host_resolver.get()));
diff --git a/chrome/browser/net/load_timing_browsertest.cc b/chrome/browser/net/load_timing_browsertest.cc
index 75da353..51963fe 100644
--- a/chrome/browser/net/load_timing_browsertest.cc
+++ b/chrome/browser/net/load_timing_browsertest.cc
@@ -13,6 +13,7 @@
#include "base/message_loop/message_loop.h"
#include "base/path_service.h"
#include "base/strings/stringprintf.h"
+#include "base/threading/sequenced_worker_pool.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/chrome_paths.h"
@@ -119,10 +120,13 @@ class MockUrlRequestJobWithTiming : public net::URLRequestFileJob {
net::NetworkDelegate* network_delegate,
const base::FilePath& path,
const TimingDeltas& load_timing_deltas)
- : net::URLRequestFileJob(request, network_delegate, path),
+ : net::URLRequestFileJob(
+ request, network_delegate, path,
+ content::BrowserThread::GetBlockingPool()->
+ GetTaskRunnerWithShutdownBehavior(
+ base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)),
load_timing_deltas_(load_timing_deltas),
- weak_factory_(this) {
- }
+ weak_factory_(this) {}
// net::URLRequestFileJob implementation:
virtual void Start() OVERRIDE {
diff --git a/chrome/browser/profiles/profile_io_data.cc b/chrome/browser/profiles/profile_io_data.cc
index 0776e53..84379e6 100644
--- a/chrome/browser/profiles/profile_io_data.cc
+++ b/chrome/browser/profiles/profile_io_data.cc
@@ -19,6 +19,7 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
+#include "base/threading/sequenced_worker_pool.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/content_settings/content_settings_provider.h"
@@ -835,7 +836,11 @@ scoped_ptr<net::URLRequestJobFactory> ProfileIOData::SetUpJobFactoryDefaults(
// NOTE(willchan): Keep these protocol handlers in sync with
// ProfileIOData::IsHandledProtocol().
bool set_protocol = job_factory->SetProtocolHandler(
- chrome::kFileScheme, new net::FileProtocolHandler());
+ chrome::kFileScheme,
+ new net::FileProtocolHandler(
+ content::BrowserThread::GetBlockingPool()->
+ GetTaskRunnerWithShutdownBehavior(
+ base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)));
DCHECK(set_protocol);
DCHECK(extension_info_map_.get());
diff --git a/content/shell/shell_url_request_context_getter.cc b/content/shell/shell_url_request_context_getter.cc
index dd74b9f..969ba3d 100644
--- a/content/shell/shell_url_request_context_getter.cc
+++ b/content/shell/shell_url_request_context_getter.cc
@@ -9,6 +9,7 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
+#include "base/threading/sequenced_worker_pool.h"
#include "base/threading/worker_pool.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/common/content_switches.h"
@@ -207,7 +208,10 @@ net::URLRequestContext* ShellURLRequestContextGetter::GetURLRequestContext() {
DCHECK(set_protocol);
set_protocol = job_factory->SetProtocolHandler(
chrome::kFileScheme,
- new net::FileProtocolHandler);
+ new net::FileProtocolHandler(
+ content::BrowserThread::GetBlockingPool()->
+ GetTaskRunnerWithShutdownBehavior(
+ base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)));
DCHECK(set_protocol);
storage_->set_job_factory(job_factory.release());
}
diff --git a/content/test/net/url_request_mock_http_job.cc b/content/test/net/url_request_mock_http_job.cc
index a864ed0..9927960 100644
--- a/content/test/net/url_request_mock_http_job.cc
+++ b/content/test/net/url_request_mock_http_job.cc
@@ -8,7 +8,9 @@
#include "base/message_loop/message_loop.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
+#include "base/threading/sequenced_worker_pool.h"
#include "base/threading/thread_restrictions.h"
+#include "content/public/browser/browser_thread.h"
#include "content/public/common/url_constants.h"
#include "net/base/net_util.h"
#include "net/http/http_response_headers.h"
@@ -109,10 +111,13 @@ URLRequestMockHTTPJob::CreateProtocolHandler(const base::FilePath& base_path) {
}
URLRequestMockHTTPJob::URLRequestMockHTTPJob(
- net::URLRequest* request,
- net::NetworkDelegate* network_delegate,
+ net::URLRequest* request, net::NetworkDelegate* network_delegate,
const base::FilePath& file_path)
- : net::URLRequestFileJob(request, network_delegate, file_path) { }
+ : net::URLRequestFileJob(
+ request, network_delegate, file_path,
+ content::BrowserThread::GetBlockingPool()->
+ GetTaskRunnerWithShutdownBehavior(
+ base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)) {}
URLRequestMockHTTPJob::~URLRequestMockHTTPJob() { }
diff --git a/content/test/net/url_request_prepackaged_interceptor.cc b/content/test/net/url_request_prepackaged_interceptor.cc
index 75d2ffc..484f260 100644
--- a/content/test/net/url_request_prepackaged_interceptor.cc
+++ b/content/test/net/url_request_prepackaged_interceptor.cc
@@ -5,6 +5,7 @@
#include "content/test/net/url_request_prepackaged_interceptor.h"
#include "base/file_util.h"
+#include "base/threading/sequenced_worker_pool.h"
#include "base/threading/thread_restrictions.h"
#include "content/public/browser/browser_thread.h"
#include "net/url_request/url_request.h"
@@ -23,7 +24,11 @@ class URLRequestPrepackagedJob : public net::URLRequestFileJob {
URLRequestPrepackagedJob(net::URLRequest* request,
net::NetworkDelegate* network_delegate,
const base::FilePath& file_path)
- : net::URLRequestFileJob(request, network_delegate, file_path) {}
+ : net::URLRequestFileJob(
+ request, network_delegate, file_path,
+ content::BrowserThread::GetBlockingPool()->
+ GetTaskRunnerWithShutdownBehavior(
+ base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)) {}
virtual int GetResponseCode() const OVERRIDE { return 200; }
diff --git a/net/proxy/proxy_script_fetcher_impl_unittest.cc b/net/proxy/proxy_script_fetcher_impl_unittest.cc
index 8d42514..9c1ca98 100644
--- a/net/proxy/proxy_script_fetcher_impl_unittest.cc
+++ b/net/proxy/proxy_script_fetcher_impl_unittest.cc
@@ -71,7 +71,8 @@ class RequestContext : public URLRequestContext {
storage_.set_http_transaction_factory(new HttpCache(
network_session.get(), HttpCache::DefaultBackend::InMemory(0)));
URLRequestJobFactoryImpl* job_factory = new URLRequestJobFactoryImpl();
- job_factory->SetProtocolHandler("file", new FileProtocolHandler());
+ job_factory->SetProtocolHandler(
+ "file", new FileProtocolHandler(base::MessageLoopProxy::current()));
storage_.set_job_factory(job_factory);
}
diff --git a/net/url_request/file_protocol_handler.cc b/net/url_request/file_protocol_handler.cc
index dc5b16f..ef8096f 100644
--- a/net/url_request/file_protocol_handler.cc
+++ b/net/url_request/file_protocol_handler.cc
@@ -5,6 +5,7 @@
#include "net/url_request/file_protocol_handler.h"
#include "base/logging.h"
+#include "base/task_runner.h"
#include "net/base/net_errors.h"
#include "net/base/net_util.h"
#include "net/url_request/url_request.h"
@@ -14,7 +15,11 @@
namespace net {
-FileProtocolHandler::FileProtocolHandler() { }
+FileProtocolHandler::FileProtocolHandler(
+ const scoped_refptr<base::TaskRunner>& file_task_runner)
+ : file_task_runner_(file_task_runner) {}
+
+FileProtocolHandler::~FileProtocolHandler() {}
URLRequestJob* FileProtocolHandler::MaybeCreateJob(
URLRequest* request, NetworkDelegate* network_delegate) const {
@@ -41,7 +46,8 @@ URLRequestJob* FileProtocolHandler::MaybeCreateJob(
// Use a regular file request job for all non-directories (including invalid
// file names).
- return new URLRequestFileJob(request, network_delegate, file_path);
+ return new URLRequestFileJob(request, network_delegate, file_path,
+ file_task_runner_);
}
bool FileProtocolHandler::IsSafeRedirectTarget(const GURL& location) const {
diff --git a/net/url_request/file_protocol_handler.h b/net/url_request/file_protocol_handler.h
index 8087a6e..78956a9 100644
--- a/net/url_request/file_protocol_handler.h
+++ b/net/url_request/file_protocol_handler.h
@@ -7,10 +7,15 @@
#include "base/basictypes.h"
#include "base/compiler_specific.h"
+#include "base/memory/ref_counted.h"
#include "net/url_request/url_request_job_factory.h"
class GURL;
+namespace base {
+class TaskRunner;
+}
+
namespace net {
class NetworkDelegate;
@@ -21,12 +26,15 @@ class URLRequestJob;
class NET_EXPORT FileProtocolHandler :
public URLRequestJobFactory::ProtocolHandler {
public:
- FileProtocolHandler();
+ explicit FileProtocolHandler(
+ const scoped_refptr<base::TaskRunner>& file_task_runner);
+ virtual ~FileProtocolHandler();
virtual URLRequestJob* MaybeCreateJob(
URLRequest* request, NetworkDelegate* network_delegate) const OVERRIDE;
virtual bool IsSafeRedirectTarget(const GURL& location) const OVERRIDE;
private:
+ const scoped_refptr<base::TaskRunner> file_task_runner_;
DISALLOW_COPY_AND_ASSIGN(FileProtocolHandler);
};
diff --git a/net/url_request/url_request_context_builder.cc b/net/url_request/url_request_context_builder.cc
index 540dfc1..dce8214 100644
--- a/net/url_request/url_request_context_builder.cc
+++ b/net/url_request/url_request_context_builder.cc
@@ -156,6 +156,11 @@ class BasicURLRequestContext : public URLRequestContext {
return file_thread_.message_loop();
}
+ scoped_refptr<base::MessageLoopProxy> file_message_loop_proxy() {
+ DCHECK(file_thread_.IsRunning());
+ return file_thread_.message_loop_proxy();
+ }
+
protected:
virtual ~BasicURLRequestContext() {}
@@ -190,7 +195,9 @@ URLRequestContextBuilder::URLRequestContextBuilder()
#if !defined(DISABLE_FTP_SUPPORT)
ftp_enabled_(false),
#endif
- http_cache_enabled_(true) {}
+ http_cache_enabled_(true) {
+}
+
URLRequestContextBuilder::~URLRequestContextBuilder() {}
#if defined(OS_LINUX) || defined(OS_ANDROID)
@@ -301,7 +308,8 @@ URLRequestContext* URLRequestContextBuilder::Build() {
if (data_enabled_)
job_factory->SetProtocolHandler("data", new DataProtocolHandler);
if (file_enabled_)
- job_factory->SetProtocolHandler("file", new FileProtocolHandler);
+ job_factory->SetProtocolHandler(
+ "file", new FileProtocolHandler(context->file_message_loop_proxy()));
#if !defined(DISABLE_FTP_SUPPORT)
if (ftp_enabled_) {
ftp_transaction_factory_.reset(
diff --git a/net/url_request/url_request_file_job.cc b/net/url_request/url_request_file_job.cc
index 437f962..053a22e 100644
--- a/net/url_request/url_request_file_job.cc
+++ b/net/url_request/url_request_file_job.cc
@@ -26,8 +26,8 @@
#include "base/platform_file.h"
#include "base/strings/string_util.h"
#include "base/synchronization/lock.h"
+#include "base/task_runner.h"
#include "base/threading/thread_restrictions.h"
-#include "base/threading/worker_pool.h"
#include "build/build_config.h"
#include "net/base/file_stream.h"
#include "net/base/io_buffer.h"
@@ -53,26 +53,27 @@ URLRequestFileJob::FileMetaInfo::FileMetaInfo()
is_directory(false) {
}
-URLRequestFileJob::URLRequestFileJob(URLRequest* request,
- NetworkDelegate* network_delegate,
- const base::FilePath& file_path)
+URLRequestFileJob::URLRequestFileJob(
+ URLRequest* request,
+ NetworkDelegate* network_delegate,
+ const base::FilePath& file_path,
+ const scoped_refptr<base::TaskRunner>& file_task_runner)
: URLRequestJob(request, network_delegate),
file_path_(file_path),
- stream_(new FileStream(NULL)),
+ stream_(new FileStream(NULL, file_task_runner)),
+ file_task_runner_(file_task_runner),
remaining_bytes_(0),
- weak_ptr_factory_(this) {
-}
+ weak_ptr_factory_(this) {}
void URLRequestFileJob::Start() {
FileMetaInfo* meta_info = new FileMetaInfo();
- base::WorkerPool::PostTaskAndReply(
+ file_task_runner_->PostTaskAndReply(
FROM_HERE,
base::Bind(&URLRequestFileJob::FetchMetaInfo, file_path_,
base::Unretained(meta_info)),
base::Bind(&URLRequestFileJob::DidFetchMetaInfo,
weak_ptr_factory_.GetWeakPtr(),
- base::Owned(meta_info)),
- true);
+ base::Owned(meta_info)));
}
void URLRequestFileJob::Kill() {
diff --git a/net/url_request/url_request_file_job.h b/net/url_request/url_request_file_job.h
index 6fc7fb9..7cd7df0 100644
--- a/net/url_request/url_request_file_job.h
+++ b/net/url_request/url_request_file_job.h
@@ -9,6 +9,7 @@
#include <vector>
#include "base/files/file_path.h"
+#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "net/base/net_export.h"
#include "net/http/http_byte_range.h"
@@ -17,6 +18,7 @@
namespace base{
struct PlatformFileInfo;
+class TaskRunner;
}
namespace file_util {
struct FileInfo;
@@ -31,7 +33,8 @@ class NET_EXPORT URLRequestFileJob : public URLRequestJob {
public:
URLRequestFileJob(URLRequest* request,
NetworkDelegate* network_delegate,
- const base::FilePath& file_path);
+ const base::FilePath& file_path,
+ const scoped_refptr<base::TaskRunner>& file_task_runner);
// URLRequestJob:
virtual void Start() OVERRIDE;
@@ -91,6 +94,7 @@ class NET_EXPORT URLRequestFileJob : public URLRequestJob {
scoped_ptr<FileStream> stream_;
FileMetaInfo meta_info_;
+ const scoped_refptr<base::TaskRunner> file_task_runner_;
HttpByteRange byte_range_;
int64 remaining_bytes_;
diff --git a/net/url_request/url_request_unittest.cc b/net/url_request/url_request_unittest.cc
index ac428ef..13462ff 100644
--- a/net/url_request/url_request_unittest.cc
+++ b/net/url_request/url_request_unittest.cc
@@ -19,7 +19,9 @@
#include "base/format_macros.h"
#include "base/memory/weak_ptr.h"
#include "base/message_loop/message_loop.h"
+#include "base/message_loop/message_loop_proxy.h"
#include "base/path_service.h"
+#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_piece.h"
#include "base/strings/string_split.h"
@@ -591,7 +593,8 @@ class URLRequestTest : public PlatformTest {
default_context_.set_network_delegate(&default_network_delegate_);
default_context_.set_net_log(&net_log_);
job_factory_.SetProtocolHandler("data", new DataProtocolHandler);
- job_factory_.SetProtocolHandler("file", new FileProtocolHandler);
+ job_factory_.SetProtocolHandler(
+ "file", new FileProtocolHandler(base::MessageLoopProxy::current()));
default_context_.set_job_factory(&job_factory_);
default_context_.Init();
}
@@ -620,7 +623,7 @@ TEST_F(URLRequestTest, AboutBlankTest) {
r.Start();
EXPECT_TRUE(r.is_pending());
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_TRUE(!r.is_pending());
EXPECT_FALSE(d.received_data_before_response());
@@ -663,7 +666,7 @@ TEST_F(URLRequestTest, DataURLImageTest) {
r.Start();
EXPECT_TRUE(r.is_pending());
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_TRUE(!r.is_pending());
EXPECT_FALSE(d.received_data_before_response());
@@ -688,7 +691,7 @@ TEST_F(URLRequestTest, FileTest) {
r.Start();
EXPECT_TRUE(r.is_pending());
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
int64 file_size = -1;
EXPECT_TRUE(file_util::GetFileSize(app_path, &file_size));
@@ -720,7 +723,7 @@ TEST_F(URLRequestTest, FileTestCancel) {
}
// Async cancellation should be safe even when URLRequest has been already
// destroyed.
- base::MessageLoop::current()->RunUntilIdle();
+ base::RunLoop().RunUntilIdle();
}
TEST_F(URLRequestTest, FileTestFullSpecifiedRange) {
@@ -755,7 +758,7 @@ TEST_F(URLRequestTest, FileTestFullSpecifiedRange) {
r.Start();
EXPECT_TRUE(r.is_pending());
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_TRUE(!r.is_pending());
EXPECT_EQ(1, d.response_started_count());
EXPECT_FALSE(d.received_data_before_response());
@@ -798,7 +801,7 @@ TEST_F(URLRequestTest, FileTestHalfSpecifiedRange) {
r.Start();
EXPECT_TRUE(r.is_pending());
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_TRUE(!r.is_pending());
EXPECT_EQ(1, d.response_started_count());
EXPECT_FALSE(d.received_data_before_response());
@@ -834,7 +837,7 @@ TEST_F(URLRequestTest, FileTestMultipleRanges) {
r.Start();
EXPECT_TRUE(r.is_pending());
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_TRUE(d.request_failed());
}
@@ -849,7 +852,7 @@ TEST_F(URLRequestTest, InvalidUrlTest) {
r.Start();
EXPECT_TRUE(r.is_pending());
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_TRUE(d.request_failed());
}
}
@@ -887,7 +890,7 @@ TEST_F(URLRequestTest, ResolveShortcutTest) {
r.Start();
EXPECT_TRUE(r.is_pending());
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
WIN32_FILE_ATTRIBUTE_DATA data;
GetFileAttributesEx(app_path.value().c_str(),
@@ -931,7 +934,7 @@ TEST_F(URLRequestTest, FileDirCancelTest) {
d.set_cancel_in_received_data_pending(true);
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
}
// Take out mock resource provider.
@@ -952,7 +955,7 @@ TEST_F(URLRequestTest, FileDirRedirectNoCrash) {
TestDelegate d;
URLRequest req(FilePathToFileURL(path), &d, &default_context_);
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
ASSERT_EQ(1, d.received_redirect_count());
ASSERT_LT(0, d.bytes_received());
@@ -966,7 +969,7 @@ TEST_F(URLRequestTest, FileDirRedirectSingleSlash) {
TestDelegate d;
URLRequest req(GURL("file:///"), &d, &default_context_);
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
ASSERT_EQ(1, d.received_redirect_count());
ASSERT_FALSE(req.status().is_success());
@@ -1194,7 +1197,7 @@ TEST_F(URLRequestTest, Intercept) {
req.SetUserData(&user_data2, user_data2);
req.set_method("GET");
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
// Make sure we can retrieve our specific user data
EXPECT_EQ(user_data0, req.GetUserData(NULL));
@@ -1229,7 +1232,7 @@ TEST_F(URLRequestTest, InterceptRedirect) {
URLRequest req(GURL("http://test_intercept/foo"), &d, &default_context_);
req.set_method("GET");
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
// Check the interceptor got called as expected
EXPECT_TRUE(interceptor.did_intercept_main_);
@@ -1262,7 +1265,7 @@ TEST_F(URLRequestTest, InterceptServerError) {
URLRequest req(GURL("http://test_intercept/foo"), &d, &default_context_);
req.set_method("GET");
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
// Check the interceptor got called as expected
EXPECT_TRUE(interceptor.did_intercept_main_);
@@ -1291,7 +1294,7 @@ TEST_F(URLRequestTest, InterceptNetworkError) {
URLRequest req(GURL("http://test_intercept/foo"), &d, &default_context_);
req.set_method("GET");
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
// Check the interceptor got called as expected
EXPECT_TRUE(interceptor.did_simulate_error_main_);
@@ -1320,7 +1323,7 @@ TEST_F(URLRequestTest, InterceptRestartRequired) {
URLRequest req(GURL("http://test_intercept/foo"), &d, &default_context_);
req.set_method("GET");
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
// Check the interceptor got called as expected
EXPECT_TRUE(interceptor.did_restart_main_);
@@ -1351,7 +1354,7 @@ TEST_F(URLRequestTest, InterceptRespectsCancelMain) {
URLRequest req(GURL("http://test_intercept/foo"), &d, &default_context_);
req.set_method("GET");
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
// Check the interceptor got called as expected
EXPECT_TRUE(interceptor.did_cancel_main_);
@@ -1382,7 +1385,7 @@ TEST_F(URLRequestTest, InterceptRespectsCancelRedirect) {
URLRequest req(GURL("http://test_intercept/foo"), &d, &default_context_);
req.set_method("GET");
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
// Check the interceptor got called as expected
EXPECT_TRUE(interceptor.did_intercept_main_);
@@ -1407,7 +1410,7 @@ TEST_F(URLRequestTest, InterceptRespectsCancelFinal) {
URLRequest req(GURL("http://test_intercept/foo"), &d, &default_context_);
req.set_method("GET");
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
// Check the interceptor got called as expected
EXPECT_TRUE(interceptor.did_simulate_error_main_);
@@ -1433,7 +1436,7 @@ TEST_F(URLRequestTest, InterceptRespectsCancelInRestart) {
URLRequest req(GURL("http://test_intercept/foo"), &d, &default_context_);
req.set_method("GET");
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
// Check the interceptor got called as expected
EXPECT_TRUE(interceptor.did_cancel_then_restart_main_);
@@ -1452,7 +1455,7 @@ LoadTimingInfo RunLoadTimingTest(const LoadTimingInfo& job_load_timing,
TestDelegate d;
URLRequest req(GURL("http://test_intercept/foo"), &d, context);
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
LoadTimingInfo resulting_load_timing;
req.GetLoadTimingInfo(&resulting_load_timing);
@@ -1729,7 +1732,7 @@ TEST_F(URLRequestTest, NetworkDelegateProxyError) {
req.set_method("GET");
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
// Check we see a failed request.
EXPECT_FALSE(req.status().is_success());
@@ -1747,7 +1750,7 @@ TEST_F(URLRequestTest, RequestCompletionForEmptyResponse) {
TestDelegate d;
URLRequest req(GURL("data:,"), &d, &default_context_);
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ("", d.data_received());
EXPECT_EQ(1, default_network_delegate_.completed_requests());
}
@@ -1841,7 +1844,7 @@ TEST_F(URLRequestTest, DelayedCookieCallback) {
URLRequest req(
test_server.GetURL("set-cookie?CookieToNotSend=1"), &d, &context);
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(0, network_delegate.blocked_get_cookies_count());
EXPECT_EQ(0, network_delegate.blocked_set_cookie_count());
EXPECT_EQ(1, network_delegate.set_cookie_count());
@@ -1854,7 +1857,7 @@ TEST_F(URLRequestTest, DelayedCookieCallback) {
TestDelegate d;
URLRequest req(test_server.GetURL("echoheader?Cookie"), &d, &context);
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_TRUE(d.data_received().find("CookieToNotSend=1")
!= std::string::npos);
@@ -1876,7 +1879,7 @@ TEST_F(URLRequestTest, DoNotSendCookies) {
&d,
&default_context_);
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(0, network_delegate.blocked_get_cookies_count());
EXPECT_EQ(0, network_delegate.blocked_set_cookie_count());
}
@@ -1889,7 +1892,7 @@ TEST_F(URLRequestTest, DoNotSendCookies) {
URLRequest req(
test_server.GetURL("echoheader?Cookie"), &d, &default_context_);
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_TRUE(d.data_received().find("CookieToNotSend=1")
!= std::string::npos);
@@ -1906,7 +1909,7 @@ TEST_F(URLRequestTest, DoNotSendCookies) {
test_server.GetURL("echoheader?Cookie"), &d, &default_context_);
req.set_load_flags(LOAD_DO_NOT_SEND_COOKIES);
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_TRUE(d.data_received().find("Cookie: CookieToNotSend=1")
== std::string::npos);
@@ -1930,7 +1933,7 @@ TEST_F(URLRequestTest, DoNotSaveCookies) {
&d,
&default_context_);
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(0, network_delegate.blocked_get_cookies_count());
EXPECT_EQ(0, network_delegate.blocked_set_cookie_count());
@@ -1949,7 +1952,7 @@ TEST_F(URLRequestTest, DoNotSaveCookies) {
req.set_load_flags(LOAD_DO_NOT_SAVE_COOKIES);
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
// LOAD_DO_NOT_SAVE_COOKIES does not trigger OnSetCookie.
EXPECT_EQ(0, network_delegate.blocked_get_cookies_count());
@@ -1965,7 +1968,7 @@ TEST_F(URLRequestTest, DoNotSaveCookies) {
URLRequest req(
test_server.GetURL("echoheader?Cookie"), &d, &default_context_);
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_TRUE(d.data_received().find("CookieToNotSave=1")
== std::string::npos);
@@ -1991,7 +1994,7 @@ TEST_F(URLRequestTest, DoNotSendCookies_ViaPolicy) {
&d,
&default_context_);
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(0, network_delegate.blocked_get_cookies_count());
EXPECT_EQ(0, network_delegate.blocked_set_cookie_count());
@@ -2005,7 +2008,7 @@ TEST_F(URLRequestTest, DoNotSendCookies_ViaPolicy) {
URLRequest req(
test_server.GetURL("echoheader?Cookie"), &d, &default_context_);
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_TRUE(d.data_received().find("CookieToNotSend=1")
!= std::string::npos);
@@ -2023,7 +2026,7 @@ TEST_F(URLRequestTest, DoNotSendCookies_ViaPolicy) {
URLRequest req(
test_server.GetURL("echoheader?Cookie"), &d, &default_context_);
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_TRUE(d.data_received().find("Cookie: CookieToNotSend=1")
== std::string::npos);
@@ -2046,7 +2049,7 @@ TEST_F(URLRequestTest, DoNotSaveCookies_ViaPolicy) {
&d,
&default_context_);
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(0, network_delegate.blocked_get_cookies_count());
EXPECT_EQ(0, network_delegate.blocked_set_cookie_count());
@@ -2064,7 +2067,7 @@ TEST_F(URLRequestTest, DoNotSaveCookies_ViaPolicy) {
&default_context_);
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(0, network_delegate.blocked_get_cookies_count());
EXPECT_EQ(2, network_delegate.blocked_set_cookie_count());
@@ -2078,7 +2081,7 @@ TEST_F(URLRequestTest, DoNotSaveCookies_ViaPolicy) {
URLRequest req(
test_server.GetURL("echoheader?Cookie"), &d, &default_context_);
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_TRUE(d.data_received().find("CookieToNotSave=1")
== std::string::npos);
@@ -2101,7 +2104,7 @@ TEST_F(URLRequestTest, DoNotSaveEmptyCookies) {
TestDelegate d;
URLRequest req(test_server.GetURL("set-cookie"), &d, &default_context_);
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(0, network_delegate.blocked_get_cookies_count());
EXPECT_EQ(0, network_delegate.blocked_set_cookie_count());
@@ -2122,7 +2125,7 @@ TEST_F(URLRequestTest, DoNotSendCookies_ViaPolicy_Async) {
&d,
&default_context_);
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(0, network_delegate.blocked_get_cookies_count());
EXPECT_EQ(0, network_delegate.blocked_set_cookie_count());
@@ -2136,7 +2139,7 @@ TEST_F(URLRequestTest, DoNotSendCookies_ViaPolicy_Async) {
URLRequest req(
test_server.GetURL("echoheader?Cookie"), &d, &default_context_);
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_TRUE(d.data_received().find("CookieToNotSend=1")
!= std::string::npos);
@@ -2154,7 +2157,7 @@ TEST_F(URLRequestTest, DoNotSendCookies_ViaPolicy_Async) {
URLRequest req(
test_server.GetURL("echoheader?Cookie"), &d, &default_context_);
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_TRUE(d.data_received().find("Cookie: CookieToNotSend=1")
== std::string::npos);
@@ -2177,7 +2180,7 @@ TEST_F(URLRequestTest, DoNotSaveCookies_ViaPolicy_Async) {
&d,
&default_context_);
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(0, network_delegate.blocked_get_cookies_count());
EXPECT_EQ(0, network_delegate.blocked_set_cookie_count());
@@ -2195,7 +2198,7 @@ TEST_F(URLRequestTest, DoNotSaveCookies_ViaPolicy_Async) {
&default_context_);
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(0, network_delegate.blocked_get_cookies_count());
EXPECT_EQ(2, network_delegate.blocked_set_cookie_count());
@@ -2209,7 +2212,7 @@ TEST_F(URLRequestTest, DoNotSaveCookies_ViaPolicy_Async) {
URLRequest req(
test_server.GetURL("echoheader?Cookie"), &d, &default_context_);
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_TRUE(d.data_received().find("CookieToNotSave=1")
== std::string::npos);
@@ -2278,7 +2281,7 @@ TEST_F(URLRequestTest, AcceptClockSkewCookieWithWrongDateTimezone) {
&d,
&default_context_);
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
}
// Verify that the cookie is not set.
{
@@ -2288,7 +2291,7 @@ TEST_F(URLRequestTest, AcceptClockSkewCookieWithWrongDateTimezone) {
URLRequest req(
test_server.GetURL("echoheader?Cookie"), &d, &default_context_);
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_TRUE(d.data_received().find("StillGood=1") == std::string::npos);
}
@@ -2302,7 +2305,7 @@ TEST_F(URLRequestTest, AcceptClockSkewCookieWithWrongDateTimezone) {
&d,
&default_context_);
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
}
// Verify that the cookie is set.
{
@@ -2312,7 +2315,7 @@ TEST_F(URLRequestTest, AcceptClockSkewCookieWithWrongDateTimezone) {
URLRequest req(
test_server.GetURL("echoheader?Cookie"), &d, &default_context_);
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_TRUE(d.data_received().find("StillGood=1") != std::string::npos);
}
@@ -2338,7 +2341,7 @@ TEST_F(URLRequestTest, DoNotOverrideReferrer) {
req.SetExtraRequestHeaders(headers);
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ("http://foo.com/", d.data_received());
}
@@ -2356,7 +2359,7 @@ TEST_F(URLRequestTest, DoNotOverrideReferrer) {
req.set_load_flags(LOAD_VALIDATE_CACHE);
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ("None", d.data_received());
}
@@ -2393,7 +2396,7 @@ class URLRequestTestHTTP : public URLRequestTest {
req.SetExtraRequestHeaders(headers);
}
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(redirect_method, req.method());
EXPECT_EQ(URLRequestStatus::SUCCESS, req.status().status());
EXPECT_EQ(OK, req.status().error());
@@ -2436,7 +2439,7 @@ class URLRequestTestHTTP : public URLRequestTest {
r.Start();
EXPECT_TRUE(r.is_pending());
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
ASSERT_EQ(1, d.response_started_count())
<< "request failed: " << r.status().status()
@@ -2482,7 +2485,7 @@ class URLRequestTestHTTP : public URLRequestTest {
r.Start();
EXPECT_TRUE(r.is_pending());
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
bool is_success = r.status().is_success();
@@ -2521,7 +2524,7 @@ TEST_F(URLRequestTestHTTP, ProxyTunnelRedirectTest) {
r.Start();
EXPECT_TRUE(r.is_pending());
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(URLRequestStatus::FAILED, r.status().status());
EXPECT_EQ(ERR_TUNNEL_CONNECTION_FAILED, r.status().error());
@@ -2547,7 +2550,7 @@ TEST_F(URLRequestTestHTTP, NetworkDelegateTunnelConnectionFailed) {
r.Start();
EXPECT_TRUE(r.is_pending());
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(URLRequestStatus::FAILED, r.status().status());
EXPECT_EQ(ERR_TUNNEL_CONNECTION_FAILED, r.status().error());
@@ -2588,12 +2591,12 @@ TEST_F(URLRequestTestHTTP, NetworkDelegateBlockAsynchronously) {
r.Start();
for (size_t i = 0; i < blocking_stages_length; ++i) {
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(blocking_stages[i],
network_delegate.stage_blocked_for_callback());
network_delegate.DoCallback(OK);
}
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(200, r.GetResponseCode());
EXPECT_EQ(URLRequestStatus::SUCCESS, r.status().status());
EXPECT_EQ(1, network_delegate.created_requests());
@@ -2620,7 +2623,7 @@ TEST_F(URLRequestTestHTTP, NetworkDelegateCancelRequest) {
URLRequest r(test_server_.GetURL(std::string()), &d, &context);
r.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(URLRequestStatus::FAILED, r.status().status());
EXPECT_EQ(ERR_EMPTY_RESPONSE, r.status().error());
@@ -2650,7 +2653,7 @@ void NetworkDelegateCancelRequest(BlockingNetworkDelegate::BlockMode block_mode,
URLRequest r(url, &d, &context);
r.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(URLRequestStatus::FAILED, r.status().status());
EXPECT_EQ(ERR_BLOCKED_BY_CLIENT, r.status().error());
@@ -2727,7 +2730,7 @@ TEST_F(URLRequestTestHTTP, NetworkDelegateRedirectRequest) {
URLRequest r(original_url, &d, &context);
r.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(URLRequestStatus::SUCCESS, r.status().status());
EXPECT_EQ(0, r.status().error());
@@ -2760,7 +2763,7 @@ TEST_F(URLRequestTestHTTP, NetworkDelegateRedirectRequestSynchronously) {
URLRequest r(original_url, &d, &context);
r.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(URLRequestStatus::SUCCESS, r.status().status());
EXPECT_EQ(0, r.status().error());
@@ -2800,7 +2803,7 @@ TEST_F(URLRequestTestHTTP, NetworkDelegateRedirectRequestPost) {
base::UintToString(arraysize(kData) - 1));
r.SetExtraRequestHeaders(headers);
r.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(URLRequestStatus::SUCCESS, r.status().status());
EXPECT_EQ(0, r.status().error());
@@ -2837,7 +2840,7 @@ TEST_F(URLRequestTestHTTP, NetworkDelegateOnAuthRequiredSyncNoAction) {
URLRequest r(url, &d, &context);
r.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(URLRequestStatus::SUCCESS, r.status().status());
EXPECT_EQ(0, r.status().error());
@@ -2874,7 +2877,7 @@ TEST_F(URLRequestTestHTTP,
EXPECT_FALSE(headers.HasHeader("Authorization"));
}
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(URLRequestStatus::SUCCESS, r.status().status());
EXPECT_EQ(0, r.status().error());
@@ -2908,7 +2911,7 @@ TEST_F(URLRequestTestHTTP, NetworkDelegateOnAuthRequiredSyncSetAuth) {
GURL url(test_server_.GetURL("auth-basic"));
URLRequest r(url, &d, &context);
r.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(URLRequestStatus::SUCCESS, r.status().status());
EXPECT_EQ(0, r.status().error());
@@ -2943,7 +2946,7 @@ TEST_F(URLRequestTestHTTP,
GURL url(test_server_.GetURL("auth-basic"));
URLRequest r(url, &d, &context);
r.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(URLRequestStatus::SUCCESS, r.status().status());
EXPECT_EQ(0, r.status().error());
@@ -2981,7 +2984,7 @@ TEST_F(URLRequestTestHTTP, NetworkDelegateOnAuthRequiredSyncCancel) {
GURL url(test_server_.GetURL("auth-basic"));
URLRequest r(url, &d, &context);
r.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(URLRequestStatus::SUCCESS, r.status().status());
EXPECT_EQ(OK, r.status().error());
@@ -3015,7 +3018,7 @@ TEST_F(URLRequestTestHTTP, NetworkDelegateOnAuthRequiredAsyncNoAction) {
GURL url(test_server_.GetURL("auth-basic"));
URLRequest r(url, &d, &context);
r.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(URLRequestStatus::SUCCESS, r.status().status());
EXPECT_EQ(0, r.status().error());
@@ -3050,7 +3053,7 @@ TEST_F(URLRequestTestHTTP, NetworkDelegateOnAuthRequiredAsyncSetAuth) {
GURL url(test_server_.GetURL("auth-basic"));
URLRequest r(url, &d, &context);
r.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(URLRequestStatus::SUCCESS, r.status().status());
EXPECT_EQ(0, r.status().error());
@@ -3083,7 +3086,7 @@ TEST_F(URLRequestTestHTTP, NetworkDelegateOnAuthRequiredAsyncCancel) {
GURL url(test_server_.GetURL("auth-basic"));
URLRequest r(url, &d, &context);
r.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(URLRequestStatus::SUCCESS, r.status().status());
EXPECT_EQ(OK, r.status().error());
@@ -3114,7 +3117,7 @@ TEST_F(URLRequestTestHTTP, NetworkDelegateCancelWhileWaiting1) {
URLRequest r(test_server_.GetURL(std::string()), &d, &context);
r.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(BlockingNetworkDelegate::ON_BEFORE_URL_REQUEST,
network_delegate.stage_blocked_for_callback());
EXPECT_EQ(0, network_delegate.completed_requests());
@@ -3150,7 +3153,7 @@ TEST_F(URLRequestTestHTTP, NetworkDelegateCancelWhileWaiting2) {
URLRequest r(test_server_.GetURL(std::string()), &d, &context);
r.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(BlockingNetworkDelegate::ON_BEFORE_SEND_HEADERS,
network_delegate.stage_blocked_for_callback());
EXPECT_EQ(0, network_delegate.completed_requests());
@@ -3185,7 +3188,7 @@ TEST_F(URLRequestTestHTTP, NetworkDelegateCancelWhileWaiting3) {
URLRequest r(test_server_.GetURL(std::string()), &d, &context);
r.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(BlockingNetworkDelegate::ON_HEADERS_RECEIVED,
network_delegate.stage_blocked_for_callback());
EXPECT_EQ(0, network_delegate.completed_requests());
@@ -3220,7 +3223,7 @@ TEST_F(URLRequestTestHTTP, NetworkDelegateCancelWhileWaiting4) {
URLRequest r(test_server_.GetURL("auth-basic"), &d, &context);
r.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(BlockingNetworkDelegate::ON_AUTH_REQUIRED,
network_delegate.stage_blocked_for_callback());
EXPECT_EQ(0, network_delegate.completed_requests());
@@ -3254,7 +3257,7 @@ TEST_F(URLRequestTestHTTP, UnexpectedServerAuthTest) {
r.Start();
EXPECT_TRUE(r.is_pending());
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(URLRequestStatus::FAILED, r.status().status());
EXPECT_EQ(ERR_TUNNEL_CONNECTION_FAILED, r.status().error());
@@ -3271,7 +3274,7 @@ TEST_F(URLRequestTestHTTP, GetTest_NoCache) {
r.Start();
EXPECT_TRUE(r.is_pending());
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(1, d.response_started_count());
EXPECT_FALSE(d.received_data_before_response());
@@ -3337,7 +3340,7 @@ TEST_F(URLRequestTestHTTP, GetTest) {
r.Start();
EXPECT_TRUE(r.is_pending());
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(1, d.response_started_count());
EXPECT_FALSE(d.received_data_before_response());
@@ -3363,7 +3366,7 @@ TEST_F(URLRequestTestHTTP, GetTest_GetFullRequestHeaders) {
r.Start();
EXPECT_TRUE(r.is_pending());
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(1, d.response_started_count());
EXPECT_FALSE(d.received_data_before_response());
@@ -3388,7 +3391,7 @@ TEST_F(URLRequestTestHTTP, GetTestLoadTiming) {
r.Start();
EXPECT_TRUE(r.is_pending());
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
LoadTimingInfo load_timing_info;
r.GetLoadTimingInfo(&load_timing_info);
@@ -3437,7 +3440,7 @@ TEST_F(URLRequestTestHTTP, GetZippedTest) {
r.Start();
EXPECT_TRUE(r.is_pending());
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(1, d.response_started_count());
EXPECT_FALSE(d.received_data_before_response());
@@ -3473,7 +3476,7 @@ TEST_F(URLRequestTestHTTP, HTTPSToHTTPRedirectNoRefererTest) {
"server-redirect?" + http_destination.spec()), &d, &default_context_);
req.SetReferrer("https://www.referrer.com/");
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(1, d.response_started_count());
EXPECT_EQ(1, d.received_redirect_count());
@@ -3490,7 +3493,7 @@ TEST_F(URLRequestTestHTTP, RedirectLoadTiming) {
TestDelegate d;
URLRequest req(original_url, &d, &default_context_);
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(1, d.response_started_count());
EXPECT_EQ(1, d.received_redirect_count());
@@ -3530,7 +3533,7 @@ TEST_F(URLRequestTestHTTP, MultipleRedirectTest) {
TestDelegate d;
URLRequest req(original_url, &d, &default_context_);
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(1, d.response_started_count());
EXPECT_EQ(2, d.received_redirect_count());
@@ -3568,7 +3571,7 @@ TEST_F(URLRequestTestHTTP, RedirectWithAdditionalHeadersTest) {
RedirectWithAdditionalHeadersDelegate d;
URLRequest req(original_url, &d, &default_context_);
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
std::string value;
const HttpRequestHeaders& headers = req.extra_request_headers();
@@ -3605,7 +3608,7 @@ TEST_F(URLRequestTestHTTP, RedirectWithHeaderRemovalTest) {
URLRequest req(original_url, &d, &default_context_);
req.SetExtraRequestHeaderByName(kExtraHeaderToRemove, "dummy", false);
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
std::string value;
const HttpRequestHeaders& headers = req.extra_request_headers();
@@ -3625,7 +3628,7 @@ TEST_F(URLRequestTestHTTP, CancelTest) {
r.Cancel();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
// We expect to receive OnResponseStarted even though the request has been
// cancelled.
@@ -3647,7 +3650,7 @@ TEST_F(URLRequestTestHTTP, CancelTest2) {
r.Start();
EXPECT_TRUE(r.is_pending());
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(1, d.response_started_count());
EXPECT_EQ(0, d.bytes_received());
@@ -3668,7 +3671,7 @@ TEST_F(URLRequestTestHTTP, CancelTest3) {
r.Start();
EXPECT_TRUE(r.is_pending());
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(1, d.response_started_count());
// There is no guarantee about how much data was received
@@ -3713,7 +3716,7 @@ TEST_F(URLRequestTestHTTP, CancelTest5) {
TestDelegate d;
URLRequest r(test_server_.GetURL("cachetime"), &d, &default_context_);
r.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(URLRequestStatus::SUCCESS, r.status().status());
}
@@ -3723,7 +3726,7 @@ TEST_F(URLRequestTestHTTP, CancelTest5) {
URLRequest r(test_server_.GetURL("cachetime"), &d, &default_context_);
r.Start();
r.Cancel();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(URLRequestStatus::CANCELED, r.status().status());
EXPECT_EQ(1, d.response_started_count());
@@ -3753,7 +3756,7 @@ TEST_F(URLRequestTestHTTP, PostEmptyTest) {
r.Start();
EXPECT_TRUE(r.is_pending());
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
ASSERT_EQ(1, d.response_started_count())
<< "request failed: " << r.status().status()
@@ -3804,7 +3807,7 @@ TEST_F(URLRequestTestHTTP, PostFileTest) {
r.Start();
EXPECT_TRUE(r.is_pending());
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
int64 size = 0;
ASSERT_EQ(true, file_util::GetFileSize(path, &size));
@@ -3835,7 +3838,7 @@ TEST_F(URLRequestTestHTTP, TestPostChunkedDataBeforeStart) {
r.Start();
EXPECT_TRUE(r.is_pending());
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
VerifyReceivedDataMatchesChunks(&r, &d);
}
@@ -3852,7 +3855,7 @@ TEST_F(URLRequestTestHTTP, TestPostChunkedDataJustAfterStart) {
r.Start();
EXPECT_TRUE(r.is_pending());
AddChunksToUpload(&r);
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
VerifyReceivedDataMatchesChunks(&r, &d);
}
@@ -3869,9 +3872,9 @@ TEST_F(URLRequestTestHTTP, TestPostChunkedDataAfterStart) {
r.Start();
EXPECT_TRUE(r.is_pending());
- base::MessageLoop::current()->RunUntilIdle();
+ base::RunLoop().RunUntilIdle();
AddChunksToUpload(&r);
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
VerifyReceivedDataMatchesChunks(&r, &d);
}
@@ -3884,7 +3887,7 @@ TEST_F(URLRequestTestHTTP, ResponseHeadersTest) {
URLRequest req(
test_server_.GetURL("files/with-headers.html"), &d, &default_context_);
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
const HttpResponseHeaders* headers = req.response_headers();
@@ -3920,7 +3923,7 @@ TEST_F(URLRequestTestHTTP, ProcessSTS) {
&d,
&default_context_);
request.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
TransportSecurityState* security_state =
default_context_.transport_security_state();
@@ -3964,7 +3967,7 @@ TEST_F(URLRequestTestHTTP, MAYBE_ProcessPKP) {
&d,
&default_context_);
request.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
TransportSecurityState* security_state =
default_context_.transport_security_state();
@@ -3995,7 +3998,7 @@ TEST_F(URLRequestTestHTTP, ProcessSTSOnce) {
&d,
&default_context_);
request.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
// We should have set parameters from the first header, not the second.
TransportSecurityState* security_state =
@@ -4024,7 +4027,7 @@ TEST_F(URLRequestTestHTTP, ProcessSTSAndPKP) {
&d,
&default_context_);
request.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
// We should have set parameters from the first header, not the second.
TransportSecurityState* security_state =
@@ -4066,7 +4069,7 @@ TEST_F(URLRequestTestHTTP, ProcessSTSAndPKP2) {
&d,
&default_context_);
request.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
TransportSecurityState* security_state =
default_context_.transport_security_state();
@@ -4095,7 +4098,7 @@ TEST_F(URLRequestTestHTTP, ContentTypeNormalizationTest) {
URLRequest req(test_server_.GetURL(
"files/content-type-normalization.html"), &d, &default_context_);
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
std::string mime_type;
req.GetMimeType(&mime_type);
@@ -4111,7 +4114,7 @@ TEST_F(URLRequestTestHTTP, ProtocolHandlerAndFactoryRestrictRedirects) {
// Test URLRequestJobFactory::ProtocolHandler::IsSafeRedirectTarget().
GURL file_url("file:///foo.txt");
GURL data_url("data:,foo");
- FileProtocolHandler file_protocol_handler;
+ FileProtocolHandler file_protocol_handler(base::MessageLoopProxy::current());
EXPECT_FALSE(file_protocol_handler.IsSafeRedirectTarget(file_url));
DataProtocolHandler data_protocol_handler;
EXPECT_FALSE(data_protocol_handler.IsSafeRedirectTarget(data_url));
@@ -4128,7 +4131,7 @@ TEST_F(URLRequestTestHTTP, RestrictFileRedirects) {
URLRequest req(test_server_.GetURL(
"files/redirect-to-file.html"), &d, &default_context_);
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(URLRequestStatus::FAILED, req.status().status());
EXPECT_EQ(ERR_UNSAFE_REDIRECT, req.status().error());
@@ -4154,7 +4157,7 @@ TEST_F(URLRequestTestHTTP, RedirectToInvalidURL) {
URLRequest req(test_server_.GetURL(
"files/redirect-to-invalid-url.html"), &d, &default_context_);
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(URLRequestStatus::FAILED, req.status().status());
EXPECT_EQ(ERR_INVALID_URL, req.status().error());
@@ -4168,7 +4171,7 @@ TEST_F(URLRequestTestHTTP, NoUserPassInReferrer) {
test_server_.GetURL("echoheader?Referer"), &d, &default_context_);
req.SetReferrer("http://user:pass@foo.com/");
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(std::string("http://foo.com/"), d.data_received());
}
@@ -4181,7 +4184,7 @@ TEST_F(URLRequestTestHTTP, NoFragmentInReferrer) {
test_server_.GetURL("echoheader?Referer"), &d, &default_context_);
req.SetReferrer("http://foo.com/test#fragment");
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(std::string("http://foo.com/test"), d.data_received());
}
@@ -4195,7 +4198,7 @@ TEST_F(URLRequestTestHTTP, EmptyReferrerAfterValidReferrer) {
req.SetReferrer("http://foo.com/test#fragment");
req.SetReferrer("");
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(std::string("None"), d.data_received());
}
@@ -4209,7 +4212,7 @@ TEST_F(URLRequestTestHTTP, CancelRedirect) {
URLRequest req(
test_server_.GetURL("files/redirect-test.html"), &d, &default_context_);
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(1, d.response_started_count());
EXPECT_EQ(0, d.bytes_received());
@@ -4228,12 +4231,12 @@ TEST_F(URLRequestTestHTTP, DeferredRedirect) {
URLRequest req(test_url, &d, &default_context_);
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(1, d.received_redirect_count());
req.FollowDeferredRedirect();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(1, d.response_started_count());
EXPECT_FALSE(d.received_data_before_response());
@@ -4264,7 +4267,7 @@ TEST_F(URLRequestTestHTTP, DeferredRedirect_GetFullRequestHeaders) {
EXPECT_FALSE(d.have_full_request_headers());
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(1, d.received_redirect_count());
EXPECT_TRUE(d.have_full_request_headers());
@@ -4272,7 +4275,7 @@ TEST_F(URLRequestTestHTTP, DeferredRedirect_GetFullRequestHeaders) {
d.ClearFullRequestHeaders();
req.FollowDeferredRedirect();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
GURL target_url(test_server_.GetURL("files/with-headers.html"));
EXPECT_EQ(1, d.response_started_count());
@@ -4303,12 +4306,12 @@ TEST_F(URLRequestTestHTTP, CancelDeferredRedirect) {
URLRequest req(
test_server_.GetURL("files/redirect-test.html"), &d, &default_context_);
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(1, d.received_redirect_count());
req.Cancel();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(1, d.response_started_count());
EXPECT_EQ(0, d.bytes_received());
@@ -4329,7 +4332,7 @@ TEST_F(URLRequestTestHTTP, VaryHeader) {
headers.SetHeader("foo", "1");
req.SetExtraRequestHeaders(headers);
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
LoadTimingInfo load_timing_info;
req.GetLoadTimingInfo(&load_timing_info);
@@ -4345,7 +4348,7 @@ TEST_F(URLRequestTestHTTP, VaryHeader) {
headers.SetHeader("foo", "1");
req.SetExtraRequestHeaders(headers);
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_TRUE(req.was_cached());
@@ -4363,7 +4366,7 @@ TEST_F(URLRequestTestHTTP, VaryHeader) {
headers.SetHeader("foo", "2");
req.SetExtraRequestHeaders(headers);
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_FALSE(req.was_cached());
@@ -4384,7 +4387,7 @@ TEST_F(URLRequestTestHTTP, BasicAuth) {
URLRequest r(test_server_.GetURL("auth-basic"), &d, &default_context_);
r.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_TRUE(d.data_received().find("user/secret") != std::string::npos);
}
@@ -4400,7 +4403,7 @@ TEST_F(URLRequestTestHTTP, BasicAuth) {
r.set_load_flags(LOAD_VALIDATE_CACHE);
r.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_TRUE(d.data_received().find("user/secret") != std::string::npos);
@@ -4431,7 +4434,7 @@ TEST_F(URLRequestTestHTTP, BasicAuthWithCookies) {
URLRequest r(url_requiring_auth, &d, &context);
r.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_TRUE(d.data_received().find("user/secret") != std::string::npos);
@@ -4460,7 +4463,7 @@ TEST_F(URLRequestTestHTTP, BasicAuthWithCookies) {
URLRequest r(url_with_identity, &d, &context);
r.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_TRUE(d.data_received().find("user2/secret") != std::string::npos);
@@ -4482,7 +4485,7 @@ TEST_F(URLRequestTestHTTP, BasicAuthLoadTiming) {
URLRequest r(test_server_.GetURL("auth-basic"), &d, &default_context_);
r.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_TRUE(d.data_received().find("user/secret") != std::string::npos);
@@ -4514,7 +4517,7 @@ TEST_F(URLRequestTestHTTP, BasicAuthLoadTiming) {
r.set_load_flags(LOAD_VALIDATE_CACHE);
r.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_TRUE(d.data_received().find("user/secret") != std::string::npos);
@@ -4557,7 +4560,7 @@ TEST_F(URLRequestTestHTTP, Post302RedirectGet) {
"Origin: http://localhost:1337/");
req.SetExtraRequestHeaders(headers);
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
std::string mime_type;
req.GetMimeType(&mime_type);
@@ -4640,7 +4643,7 @@ TEST_F(URLRequestTestHTTP, InterceptPost302RedirectGet) {
AddTestInterceptor()->set_main_intercept_job(job);
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ("GET", req.method());
}
@@ -4664,7 +4667,7 @@ TEST_F(URLRequestTestHTTP, InterceptPost307RedirectPost) {
AddTestInterceptor()->set_main_intercept_job(job);
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ("POST", req.method());
EXPECT_EQ(kData, d.data_received());
}
@@ -4684,7 +4687,7 @@ TEST_F(URLRequestTestHTTP, DefaultAcceptLanguage) {
URLRequest req(
test_server_.GetURL("echoheader?Accept-Language"), &d, &context);
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ("en", d.data_received());
}
@@ -4705,7 +4708,7 @@ TEST_F(URLRequestTestHTTP, EmptyAcceptLanguage) {
URLRequest req(
test_server_.GetURL("echoheader?Accept-Language"), &d, &context);
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ("None", d.data_received());
}
@@ -4722,7 +4725,7 @@ TEST_F(URLRequestTestHTTP, OverrideAcceptLanguage) {
headers.SetHeader(HttpRequestHeaders::kAcceptLanguage, "ru");
req.SetExtraRequestHeaders(headers);
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(std::string("ru"), d.data_received());
}
@@ -4737,7 +4740,7 @@ TEST_F(URLRequestTestHTTP, DefaultAcceptEncoding) {
HttpRequestHeaders headers;
req.SetExtraRequestHeaders(headers);
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_TRUE(ContainsString(d.data_received(), "gzip"));
}
@@ -4754,7 +4757,7 @@ TEST_F(URLRequestTestHTTP, OverrideAcceptEncoding) {
headers.SetHeader(HttpRequestHeaders::kAcceptEncoding, "identity");
req.SetExtraRequestHeaders(headers);
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_FALSE(ContainsString(d.data_received(), "gzip"));
EXPECT_TRUE(ContainsString(d.data_received(), "identity"));
}
@@ -4771,7 +4774,7 @@ TEST_F(URLRequestTestHTTP, SetAcceptCharset) {
headers.SetHeader(HttpRequestHeaders::kAcceptCharset, "koi-8r");
req.SetExtraRequestHeaders(headers);
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(std::string("koi-8r"), d.data_received());
}
@@ -4784,7 +4787,7 @@ TEST_F(URLRequestTestHTTP, DefaultUserAgent) {
&d,
&default_context_);
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(req.context()->GetUserAgent(req.url()), d.data_received());
}
@@ -4801,7 +4804,7 @@ TEST_F(URLRequestTestHTTP, OverrideUserAgent) {
headers.SetHeader(HttpRequestHeaders::kUserAgent, "Lynx (textmode)");
req.SetExtraRequestHeaders(headers);
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
// If the net tests are being run with ChromeFrame then we need to allow for
// the 'chromeframe' suffix which is added to the user agent before the
// closing parentheses.
@@ -4833,7 +4836,7 @@ TEST_F(URLRequestTestHTTP, EmptyHttpUserAgentSettings) {
TestDelegate d;
URLRequest req(test_server_.GetURL(tests[i].request), &d, &context);
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(tests[i].expected_response, d.data_received())
<< " Request = \"" << tests[i].request << "\"";
}
@@ -4863,7 +4866,7 @@ TEST_F(URLRequestTestHTTP, SetSubsequentJobPriority) {
AddTestInterceptor()->set_main_intercept_job(job.get());
// Should trigger |job| to be started.
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(LOW, job->priority());
}
@@ -4893,7 +4896,7 @@ TEST_F(HTTPSRequestTest, HTTPSGetTest) {
r.Start();
EXPECT_TRUE(r.is_pending());
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(1, d.response_started_count());
EXPECT_FALSE(d.received_data_before_response());
@@ -4925,7 +4928,7 @@ TEST_F(HTTPSRequestTest, HTTPSMismatchedTest) {
r.Start();
EXPECT_TRUE(r.is_pending());
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(1, d.response_started_count());
EXPECT_FALSE(d.received_data_before_response());
@@ -4961,7 +4964,7 @@ TEST_F(HTTPSRequestTest, HTTPSExpiredTest) {
r.Start();
EXPECT_TRUE(r.is_pending());
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(1, d.response_started_count());
EXPECT_FALSE(d.received_data_before_response());
@@ -5004,7 +5007,7 @@ TEST_F(HTTPSRequestTest, TLSv1Fallback) {
URLRequest r(test_server.GetURL(std::string()), &d, &context);
r.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(1, d.response_started_count());
EXPECT_NE(0, d.bytes_received());
@@ -5048,7 +5051,7 @@ TEST_F(HTTPSRequestTest, HTTPSPreloadedHSTSTest) {
r.Start();
EXPECT_TRUE(r.is_pending());
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(1, d.response_started_count());
EXPECT_FALSE(d.received_data_before_response());
@@ -5096,7 +5099,7 @@ TEST_F(HTTPSRequestTest, HTTPSErrorsNoClobberTSSTest) {
r.Start();
EXPECT_TRUE(r.is_pending());
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(1, d.response_started_count());
EXPECT_FALSE(d.received_data_before_response());
@@ -5167,7 +5170,7 @@ TEST_F(HTTPSRequestTest, HSTSPreservesPosts) {
req.set_upload(make_scoped_ptr(CreateSimpleUploadData(kData)));
req.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ("https", req.url().scheme());
EXPECT_EQ("POST", req.method());
@@ -5197,7 +5200,7 @@ TEST_F(HTTPSRequestTest, SSLv3Fallback) {
URLRequest r(test_server.GetURL(std::string()), &d, &context);
r.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(1, d.response_started_count());
EXPECT_NE(0, d.bytes_received());
@@ -5248,7 +5251,7 @@ TEST_F(HTTPSRequestTest, ClientAuthTest) {
r.Start();
EXPECT_TRUE(r.is_pending());
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(1, d.on_certificate_requested_count());
EXPECT_FALSE(d.received_data_before_response());
@@ -5259,7 +5262,7 @@ TEST_F(HTTPSRequestTest, ClientAuthTest) {
// all platforms so we can test sending a cert as well.
r.ContinueWithCertificate(NULL);
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(1, d.response_started_count());
EXPECT_FALSE(d.received_data_before_response());
@@ -5288,7 +5291,7 @@ TEST_F(HTTPSRequestTest, ResumeTest) {
r.Start();
EXPECT_TRUE(r.is_pending());
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(1, d.response_started_count());
}
@@ -5304,7 +5307,7 @@ TEST_F(HTTPSRequestTest, ResumeTest) {
r.Start();
EXPECT_TRUE(r.is_pending());
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
// The response will look like;
// insert abc
@@ -5357,7 +5360,7 @@ TEST_F(HTTPSRequestTest, SSLSessionCacheShardTest) {
r.Start();
EXPECT_TRUE(r.is_pending());
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(1, d.response_started_count());
}
@@ -5389,7 +5392,7 @@ TEST_F(HTTPSRequestTest, SSLSessionCacheShardTest) {
r.Start();
EXPECT_TRUE(r.is_pending());
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
// The response will look like;
// insert abc
@@ -5505,7 +5508,7 @@ class HTTPSOCSPTest : public HTTPSRequestTest {
URLRequest r(test_server.GetURL(std::string()), &d, &context_);
r.Start();
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_EQ(1, d.response_started_count());
*out_cert_status = r.ssl_info().cert_status;
@@ -5933,7 +5936,7 @@ TEST_F(URLRequestTestFTP, UnsafePort) {
r.Start();
EXPECT_TRUE(r.is_pending());
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_FALSE(r.is_pending());
EXPECT_EQ(URLRequestStatus::FAILED, r.status().status());
@@ -5951,7 +5954,7 @@ TEST_F(URLRequestTestFTP, DISABLED_FTPDirectoryListing) {
r.Start();
EXPECT_TRUE(r.is_pending());
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
EXPECT_FALSE(r.is_pending());
EXPECT_EQ(1, d.response_started_count());
@@ -5977,7 +5980,7 @@ TEST_F(URLRequestTestFTP, DISABLED_FTPGetTestAnonymous) {
r.Start();
EXPECT_TRUE(r.is_pending());
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
int64 file_size = 0;
file_util::GetFileSize(app_path, &file_size);
@@ -6009,7 +6012,7 @@ TEST_F(URLRequestTestFTP, DISABLED_FTPGetTest) {
r.Start();
EXPECT_TRUE(r.is_pending());
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
int64 file_size = 0;
file_util::GetFileSize(app_path, &file_size);
@@ -6047,7 +6050,7 @@ TEST_F(URLRequestTestFTP, DISABLED_FTPCheckWrongPassword) {
r.Start();
EXPECT_TRUE(r.is_pending());
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
int64 file_size = 0;
file_util::GetFileSize(app_path, &file_size);
@@ -6080,7 +6083,7 @@ TEST_F(URLRequestTestFTP, DISABLED_FTPCheckWrongPasswordRestart) {
r.Start();
EXPECT_TRUE(r.is_pending());
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
int64 file_size = 0;
file_util::GetFileSize(app_path, &file_size);
@@ -6110,7 +6113,7 @@ TEST_F(URLRequestTestFTP, DISABLED_FTPCheckWrongUser) {
r.Start();
EXPECT_TRUE(r.is_pending());
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
int64 file_size = 0;
file_util::GetFileSize(app_path, &file_size);
@@ -6143,7 +6146,7 @@ TEST_F(URLRequestTestFTP, DISABLED_FTPCheckWrongUserRestart) {
r.Start();
EXPECT_TRUE(r.is_pending());
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
int64 file_size = 0;
file_util::GetFileSize(app_path, &file_size);
@@ -6175,7 +6178,7 @@ TEST_F(URLRequestTestFTP, DISABLED_FTPCacheURLCredentials) {
r.Start();
EXPECT_TRUE(r.is_pending());
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
int64 file_size = 0;
file_util::GetFileSize(app_path, &file_size);
@@ -6193,7 +6196,7 @@ TEST_F(URLRequestTestFTP, DISABLED_FTPCacheURLCredentials) {
r.Start();
EXPECT_TRUE(r.is_pending());
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
int64 file_size = 0;
file_util::GetFileSize(app_path, &file_size);
@@ -6227,7 +6230,7 @@ TEST_F(URLRequestTestFTP, DISABLED_FTPCacheLoginBoxCredentials) {
r.Start();
EXPECT_TRUE(r.is_pending());
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
int64 file_size = 0;
file_util::GetFileSize(app_path, &file_size);
@@ -6248,7 +6251,7 @@ TEST_F(URLRequestTestFTP, DISABLED_FTPCacheLoginBoxCredentials) {
r.Start();
EXPECT_TRUE(r.is_pending());
- base::MessageLoop::current()->Run();
+ base::RunLoop().Run();
int64 file_size = 0;
file_util::GetFileSize(app_path, &file_size);