summaryrefslogtreecommitdiffstats
path: root/chrome/browser/net
diff options
context:
space:
mode:
authoreroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-16 23:10:33 +0000
committereroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-16 23:10:33 +0000
commit869336177906f183c223f304c8455b424d64b54f (patch)
tree44afa6f07a120acc8c383a857b9e504df74c04ae /chrome/browser/net
parent93bd86a6b4678b9dfc5b263107a90131974ef529 (diff)
downloadchromium_src-869336177906f183c223f304c8455b424d64b54f.zip
chromium_src-869336177906f183c223f304c8455b424d64b54f.tar.gz
chromium_src-869336177906f183c223f304c8455b424d64b54f.tar.bz2
Cleanup: Move the ProxyScriptFetcher registry from being a global in net, to living in IOThread.
I had to make some other changes to make this fit well: moved ProxyScriptFetcherImpl to its own set of files, and added a IOThread::Get() accessor to avoid plumbing through several layers in connection_tester. I find the registry living in IOThread is preferable, as globals in net/ limit the ability to run on safely on multiple threads, and also leads to confusion on what needs to be called at shutdown. Review URL: http://codereview.chromium.org/3823001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@62876 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/net')
-rw-r--r--chrome/browser/net/chrome_url_request_context.cc10
-rw-r--r--chrome/browser/net/connection_tester.cc18
-rw-r--r--chrome/browser/net/connection_tester.h6
-rw-r--r--chrome/browser/net/connection_tester_unittest.cc7
4 files changed, 29 insertions, 12 deletions
diff --git a/chrome/browser/net/chrome_url_request_context.cc b/chrome/browser/net/chrome_url_request_context.cc
index 0134717..cc1fe93 100644
--- a/chrome/browser/net/chrome_url_request_context.cc
+++ b/chrome/browser/net/chrome_url_request_context.cc
@@ -95,7 +95,7 @@ net::ProxyService* CreateProxyService(
URLRequestContext* context,
net::ProxyConfigService* proxy_config_service,
const CommandLine& command_line,
- MessageLoop* io_loop) {
+ IOThread* io_thread) {
CheckCurrentlyOnIOThread();
bool use_v8 = !command_line.HasSwitch(switches::kWinHttpProxyResolver);
@@ -126,9 +126,9 @@ net::ProxyService* CreateProxyService(
return net::ProxyService::CreateUsingV8ProxyResolver(
proxy_config_service,
num_pac_threads,
- context,
- net_log,
- io_loop);
+ io_thread->CreateAndRegisterProxyScriptFetcher(context),
+ context->host_resolver(),
+ net_log);
}
return net::ProxyService::CreateUsingSystemProxyResolver(
@@ -271,7 +271,7 @@ ChromeURLRequestContext* FactoryForOriginal::Create() {
context,
proxy_config_service_.release(),
command_line,
- MessageLoop::current() /*io_loop*/));
+ io_thread()));
net::HttpCache::DefaultBackend* backend = new net::HttpCache::DefaultBackend(
net::DISK_CACHE, disk_cache_path_, cache_size_,
diff --git a/chrome/browser/net/connection_tester.cc b/chrome/browser/net/connection_tester.cc
index 8658240..f8c7911 100644
--- a/chrome/browser/net/connection_tester.cc
+++ b/chrome/browser/net/connection_tester.cc
@@ -10,6 +10,7 @@
#include "base/message_loop.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/importer/firefox_proxy_settings.h"
+#include "chrome/browser/io_thread.h"
#include "chrome/common/chrome_switches.h"
#include "net/base/cookie_monster.h"
#include "net/base/dnsrr_resolver.h"
@@ -37,6 +38,9 @@ namespace {
// to the specified "experiment".
class ExperimentURLRequestContext : public URLRequestContext {
public:
+ explicit ExperimentURLRequestContext(IOThread* io_thread)
+ : io_thread_(io_thread) {}
+
int Init(const ConnectionTester::Experiment& experiment) {
int rv;
@@ -161,7 +165,10 @@ class ExperimentURLRequestContext : public URLRequestContext {
*proxy_service = net::ProxyService::CreateUsingV8ProxyResolver(
config_service.release(),
- 0u, this, NULL, MessageLoop::current());
+ 0u,
+ io_thread_->CreateAndRegisterProxyScriptFetcher(this),
+ host_resolver(),
+ NULL);
return net::OK;
}
@@ -205,6 +212,8 @@ class ExperimentURLRequestContext : public URLRequestContext {
return net::ERR_FAILED;
}
+
+ IOThread* io_thread_;
};
} // namespace
@@ -291,7 +300,7 @@ void ConnectionTester::TestRunner::OnResponseCompleted(URLRequest* request) {
void ConnectionTester::TestRunner::Run(const Experiment& experiment) {
// Try to create a URLRequestContext for this experiment.
scoped_refptr<ExperimentURLRequestContext> context =
- new ExperimentURLRequestContext();
+ new ExperimentURLRequestContext(tester_->io_thread_);
int rv = context->Init(experiment);
if (rv != net::OK) {
// Complete the experiment with a failure.
@@ -307,9 +316,10 @@ void ConnectionTester::TestRunner::Run(const Experiment& experiment) {
// ConnectionTester ----------------------------------------------------------
-ConnectionTester::ConnectionTester(Delegate* delegate)
- : delegate_(delegate) {
+ConnectionTester::ConnectionTester(Delegate* delegate, IOThread* io_thread)
+ : delegate_(delegate), io_thread_(io_thread) {
DCHECK(delegate);
+ DCHECK(io_thread);
}
ConnectionTester::~ConnectionTester() {
diff --git a/chrome/browser/net/connection_tester.h b/chrome/browser/net/connection_tester.h
index 4118fbc..e0a7446 100644
--- a/chrome/browser/net/connection_tester.h
+++ b/chrome/browser/net/connection_tester.h
@@ -13,6 +13,8 @@
#include "googleurl/src/gurl.h"
#include "net/base/completion_callback.h"
+class IOThread;
+
// ConnectionTester runs a suite of tests (also called "experiments"),
// to try and discover why loading a particular URL is failing with an error
// code.
@@ -123,7 +125,7 @@ class ConnectionTester {
// Constructs a ConnectionTester that notifies test progress to |delegate|.
// |delegate| is owned by the caller, and must remain valid for the lifetime
// of ConnectionTester.
- explicit ConnectionTester(Delegate* delegate);
+ ConnectionTester(Delegate* delegate, IOThread* io_thread);
// Note that destruction cancels any in-progress tests.
~ConnectionTester();
@@ -169,6 +171,8 @@ class ConnectionTester {
// of the list is the one currently in progress.
ExperimentList remaining_experiments_;
+ IOThread* io_thread_;
+
DISALLOW_COPY_AND_ASSIGN(ConnectionTester);
};
diff --git a/chrome/browser/net/connection_tester_unittest.cc b/chrome/browser/net/connection_tester_unittest.cc
index 686c601..fe6e8cc 100644
--- a/chrome/browser/net/connection_tester_unittest.cc
+++ b/chrome/browser/net/connection_tester_unittest.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/net/connection_tester.h"
+#include "chrome/browser/io_thread.h"
#include "net/base/mock_host_resolver.h"
#include "net/test/test_server.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -88,12 +89,13 @@ class ConnectionTesterTest : public PlatformTest {
net::TestServer test_server_;
ConnectionTesterDelegate test_delegate_;
MessageLoop message_loop_;
+ IOThread io_thread_; // Needed for creating ProxyScriptFetchers.
};
TEST_F(ConnectionTesterTest, RunAllTests) {
ASSERT_TRUE(test_server_.Start());
- ConnectionTester tester(&test_delegate_);
+ ConnectionTester tester(&test_delegate_, &io_thread_);
// Start the test suite on URL "echoall".
// TODO(eroman): Is this URL right?
@@ -117,7 +119,8 @@ TEST_F(ConnectionTesterTest, RunAllTests) {
TEST_F(ConnectionTesterTest, DeleteWhileInProgress) {
ASSERT_TRUE(test_server_.Start());
- scoped_ptr<ConnectionTester> tester(new ConnectionTester(&test_delegate_));
+ scoped_ptr<ConnectionTester> tester(
+ new ConnectionTester(&test_delegate_, &io_thread_));
// Start the test suite on URL "echoall".
// TODO(eroman): Is this URL right?