0

make ProxyService::CreateSystemProxyConfigService return scoped_ptrs

This change is fairly straightforward. I ended up refactoring ProxyServiceFactory too because it makes the resulting code much easier to reason about, so we are only making scoped pointers out of raw pointers in as few places as possible

new CL to reflect Randy and Pauls changes in master

BUG=523075
TBR=brettw@chromium.org

Review URL: https://codereview.chromium.org/1356933002

Cr-Commit-Position: refs/heads/master@{#350207}
This commit is contained in:
csharrison
2015-09-22 12:13:04 -07:00
committed by Commit bot
parent f8db20ed28
commit b7e3a08f4c
28 changed files with 240 additions and 192 deletions

@ -63,14 +63,18 @@ void DeleteDirRecursively(const base::FilePath& path) {
AwBrowserContext* g_browser_context = NULL;
net::ProxyConfigService* CreateProxyConfigService() {
net::ProxyConfigServiceAndroid* config_service =
static_cast<net::ProxyConfigServiceAndroid*>(
net::ProxyService::CreateSystemProxyConfigService(
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO),
nullptr /* Ignored on Android */ ));
config_service->set_exclude_pac_url(true);
return config_service;
scoped_ptr<net::ProxyConfigService> CreateProxyConfigService() {
scoped_ptr<net::ProxyConfigService> config_service =
net::ProxyService::CreateSystemProxyConfigService(
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO),
nullptr /* Ignored on Android */);
// TODO(csharrison) Architect the wrapper better so we don't need a cast for
// android ProxyConfigServices.
net::ProxyConfigServiceAndroid* android_config_service =
static_cast<net::ProxyConfigServiceAndroid*>(config_service.get());
android_config_service->set_exclude_pac_url(true);
return config_service.Pass();
}
bool OverrideBlacklistForURL(const GURL& url, bool* block, int* reason) {
@ -177,10 +181,8 @@ void AwBrowserContext::PreMainMessageLoopRun() {
LOG(WARNING) << "Failed to get cache directory for Android WebView. "
<< "Using app data directory as a fallback.";
}
url_request_context_getter_ =
new AwURLRequestContextGetter(
cache_path, cookie_store_.get(),
make_scoped_ptr(CreateProxyConfigService()).Pass());
url_request_context_getter_ = new AwURLRequestContextGetter(
cache_path, cookie_store_.get(), CreateProxyConfigService());
data_reduction_proxy_io_data_.reset(
new data_reduction_proxy::DataReductionProxyIOData(

@ -218,7 +218,7 @@ void AwURLRequestContextGetter::InitializeURLRequestContext() {
// Create the proxy without a resolver since we rely on this local HTTP proxy.
// TODO(sgurun) is this behavior guaranteed through SDK?
builder.set_proxy_service(net::ProxyService::CreateWithoutProxyResolver(
proxy_config_service_.release(), net_log_.get()));
proxy_config_service_.Pass(), net_log_.get()));
builder.set_net_log(net_log_.get());
builder.SetCookieAndChannelIdStores(cookie_store_, NULL);
ApplyCmdlineOverridesToURLRequestContextBuilder(&builder);

@ -1070,9 +1070,8 @@ void IOThread::InitSystemRequestContext() {
// If we're in unit_tests, IOThread may not be run.
if (!BrowserThread::IsMessageLoopValid(BrowserThread::IO))
return;
system_proxy_config_service_.reset(
ProxyServiceFactory::CreateProxyConfigService(
pref_proxy_config_tracker_.get()));
system_proxy_config_service_ = ProxyServiceFactory::CreateProxyConfigService(
pref_proxy_config_tracker_.get());
system_url_request_context_getter_ =
new SystemURLRequestContextGetter(this);
// Safe to post an unretained this pointer, since IOThread is
@ -1094,7 +1093,7 @@ void IOThread::InitSystemRequestContextOnIOThread() {
globals_->system_proxy_service = ProxyServiceFactory::CreateProxyService(
net_log_, globals_->proxy_script_fetcher_context.get(),
globals_->system_network_delegate.get(),
system_proxy_config_service_.release(), command_line,
system_proxy_config_service_.Pass(), command_line,
quick_check_enabled_.GetValue());
globals_->system_request_context.reset(

@ -57,8 +57,8 @@ bool EnableOutOfProcessV8Pac(const base::CommandLine& command_line) {
} // namespace
// static
net::ProxyConfigService* ProxyServiceFactory::CreateProxyConfigService(
PrefProxyConfigTracker* tracker) {
scoped_ptr<net::ProxyConfigService>
ProxyServiceFactory::CreateProxyConfigService(PrefProxyConfigTracker* tracker) {
// The linux gconf-based proxy settings getter relies on being initialized
// from the UI thread.
DCHECK_CURRENTLY_ON(BrowserThread::UI);
@ -77,13 +77,12 @@ net::ProxyConfigService* ProxyServiceFactory::CreateProxyConfigService(
// TODO(port): the IO and FILE message loops are only used by Linux. Can
// that code be moved to chrome/browser instead of being in net, so that it
// can use BrowserThread instead of raw MessageLoop pointers? See bug 25354.
base_service.reset(net::ProxyService::CreateSystemProxyConfigService(
base_service = net::ProxyService::CreateSystemProxyConfigService(
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO),
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE)));
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE));
#endif // !defined(OS_CHROMEOS)
return tracker->CreateTrackingProxyConfigService(base_service.Pass())
.release();
return tracker->CreateTrackingProxyConfigService(base_service.Pass());
}
// static
@ -118,7 +117,7 @@ scoped_ptr<net::ProxyService> ProxyServiceFactory::CreateProxyService(
net::NetLog* net_log,
net::URLRequestContext* context,
net::NetworkDelegate* network_delegate,
net::ProxyConfigService* proxy_config_service,
scoped_ptr<net::ProxyConfigService> proxy_config_service,
const base::CommandLine& command_line,
bool quick_check_enabled) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
@ -170,13 +169,13 @@ scoped_ptr<net::ProxyService> ProxyServiceFactory::CreateProxyService(
// should override other options.
if (command_line.HasSwitch(switches::kV8PacMojoInProcess)) {
proxy_service = net::CreateProxyServiceUsingMojoInProcess(
proxy_config_service, new net::ProxyScriptFetcherImpl(context),
proxy_config_service.Pass(), new net::ProxyScriptFetcherImpl(context),
dhcp_proxy_script_fetcher.Pass(), context->host_resolver(), net_log,
network_delegate);
} else if (EnableOutOfProcessV8Pac(command_line)) {
proxy_service = net::CreateProxyServiceUsingMojoFactory(
UtilityProcessMojoProxyResolverFactory::GetInstance(),
proxy_config_service, new net::ProxyScriptFetcherImpl(context),
proxy_config_service.Pass(), new net::ProxyScriptFetcherImpl(context),
dhcp_proxy_script_fetcher.Pass(), context->host_resolver(), net_log,
network_delegate);
}
@ -184,16 +183,14 @@ scoped_ptr<net::ProxyService> ProxyServiceFactory::CreateProxyService(
if (!proxy_service) {
proxy_service = net::CreateProxyServiceUsingV8ProxyResolver(
proxy_config_service, new net::ProxyScriptFetcherImpl(context),
proxy_config_service.Pass(), new net::ProxyScriptFetcherImpl(context),
dhcp_proxy_script_fetcher.Pass(), context->host_resolver(), net_log,
network_delegate);
}
#endif // defined(OS_IOS)
} else {
proxy_service = net::ProxyService::CreateUsingSystemProxyResolver(
proxy_config_service,
num_pac_threads,
net_log);
proxy_config_service.Pass(), num_pac_threads, net_log);
}
proxy_service->set_quick_check_enabled(quick_check_enabled);

@ -27,7 +27,7 @@ class ProxyServiceFactory {
public:
// Creates a ProxyConfigService that delivers the system preferences
// (or the respective ChromeOS equivalent).
static net::ProxyConfigService* CreateProxyConfigService(
static scoped_ptr<net::ProxyConfigService> CreateProxyConfigService(
PrefProxyConfigTracker* tracker);
// Creates a PrefProxyConfigTracker that tracks preferences of a
@ -49,7 +49,7 @@ class ProxyServiceFactory {
net::NetLog* net_log,
net::URLRequestContext* context,
net::NetworkDelegate* network_delegate,
net::ProxyConfigService* proxy_config_service,
scoped_ptr<net::ProxyConfigService> proxy_config_service,
const base::CommandLine& command_line,
bool quick_check_enabled);

@ -419,9 +419,8 @@ void ProfileIOData::InitializeOnUIThread(Profile* profile) {
new_tab_interceptor_service->CreateInterceptor();
}
params->proxy_config_service
.reset(ProxyServiceFactory::CreateProxyConfigService(
profile->GetProxyConfigTracker()));
params->proxy_config_service = ProxyServiceFactory::CreateProxyConfigService(
profile->GetProxyConfigTracker());
#if defined(ENABLE_SUPERVISED_USERS)
SupervisedUserService* supervised_user_service =
SupervisedUserServiceFactory::GetForProfile(profile);
@ -1074,7 +1073,7 @@ void ProfileIOData::Init(
io_thread->net_log(),
io_thread_globals->proxy_script_fetcher_context.get(),
io_thread_globals->system_network_delegate.get(),
profile_params_->proxy_config_service.release(), command_line,
profile_params_->proxy_config_service.Pass(), command_line,
quick_check_enabled_.GetValue());
transport_security_state_.reset(new net::TransportSecurityState());
base::SequencedWorkerPool* pool = BrowserThread::GetBlockingPool();

@ -97,9 +97,9 @@ ServiceURLRequestContextGetter::ServiceURLRequestContextGetter()
: user_agent_(MakeUserAgentForServiceProcess()),
network_task_runner_(g_service_process->io_task_runner()) {
DCHECK(g_service_process);
proxy_config_service_.reset(net::ProxyService::CreateSystemProxyConfigService(
proxy_config_service_ = net::ProxyService::CreateSystemProxyConfigService(
g_service_process->io_task_runner(),
g_service_process->file_task_runner()));
g_service_process->file_task_runner());
}
net::URLRequestContext*

@ -152,11 +152,11 @@ void URLRequestContextFactory::InitializeOnUIThread(net::NetLog* net_log) {
// Proxy config service should be initialized in UI thread, since
// ProxyConfigServiceDelegate on Android expects UI thread.
proxy_config_service_.reset(net::ProxyService::CreateSystemProxyConfigService(
proxy_config_service_ = net::ProxyService::CreateSystemProxyConfigService(
content::BrowserThread::GetMessageLoopProxyForThread(
content::BrowserThread::IO),
content::BrowserThread::GetMessageLoopProxyForThread(
content::BrowserThread::FILE)));
content::BrowserThread::FILE));
net_log_ = net_log;
}
@ -217,7 +217,7 @@ void URLRequestContextFactory::InitializeSystemContextDependencies() {
http_server_properties_.reset(new net::HttpServerPropertiesImpl);
proxy_service_ = net::ProxyService::CreateUsingSystemProxyResolver(
proxy_config_service_.release(), 0, NULL);
proxy_config_service_.Pass(), 0, NULL);
system_dependencies_initialized_ = true;
}

@ -148,14 +148,15 @@ void CronetURLRequestContextAdapter::InitRequestContextOnMainThread(
jobject jcaller) {
base::android::ScopedJavaGlobalRef<jobject> jcaller_ref;
jcaller_ref.Reset(env, jcaller);
proxy_config_service_ = net::ProxyService::CreateSystemProxyConfigService(
GetNetworkTaskRunner(), nullptr /* Ignored on Android */);
net::ProxyConfigServiceAndroid* android_proxy_config_service =
static_cast<net::ProxyConfigServiceAndroid*>(
net::ProxyService::CreateSystemProxyConfigService(
GetNetworkTaskRunner(), nullptr /* Ignored on Android */));
static_cast<net::ProxyConfigServiceAndroid*>(proxy_config_service_.get());
// If a PAC URL is present, ignore it and use the address and port of
// Android system's local HTTP proxy server. See: crbug.com/432539.
// TODO(csharrison) Architect the wrapper better so we don't need to cast for
// android ProxyConfigServices.
android_proxy_config_service->set_exclude_pac_url(true);
proxy_config_service_.reset(android_proxy_config_service);
GetNetworkTaskRunner()->PostTask(
FROM_HERE,
base::Bind(&CronetURLRequestContextAdapter::InitializeOnNetworkThread,
@ -200,7 +201,7 @@ void CronetURLRequestContextAdapter::InitializeOnNetworkThread(
// local HTTP proxy. See: crbug.com/432539.
context_builder.set_proxy_service(
net::ProxyService::CreateWithoutProxyResolver(
proxy_config_service_.release(), net_log_.get()));
proxy_config_service_.Pass(), net_log_.get()));
config->ConfigureURLRequestContextBuilder(&context_builder);
// Set up pref file if storage path is specified.

@ -126,8 +126,8 @@ void URLRequestContextAdapter::Initialize(
}
void URLRequestContextAdapter::InitRequestContextOnMainThread() {
proxy_config_service_.reset(net::ProxyService::CreateSystemProxyConfigService(
GetNetworkTaskRunner(), NULL));
proxy_config_service_ = net::ProxyService::CreateSystemProxyConfigService(
GetNetworkTaskRunner(), NULL);
GetNetworkTaskRunner()->PostTask(
FROM_HERE,
base::Bind(&URLRequestContextAdapter::InitRequestContextOnNetworkThread,

@ -59,9 +59,10 @@ class ResolveProxyMsgHelperTest : public testing::Test, public IPC::Listener {
ResolveProxyMsgHelperTest()
: resolver_factory_(new net::MockAsyncProxyResolverFactory(false)),
service_(new net::ProxyService(new MockProxyConfigService,
make_scoped_ptr(resolver_factory_),
NULL)),
service_(
new net::ProxyService(make_scoped_ptr(new MockProxyConfigService),
make_scoped_ptr(resolver_factory_),
NULL)),
helper_(new TestResolveProxyMsgHelper(service_.get(), this)),
io_thread_(BrowserThread::IO, &message_loop_) {
test_sink_.AddFilter(this);

@ -96,14 +96,14 @@ ShellURLRequestContextGetter::CreateNetworkDelegate() {
scoped_ptr<net::ProxyConfigService>
ShellURLRequestContextGetter::GetProxyConfigService() {
return make_scoped_ptr(net::ProxyService::CreateSystemProxyConfigService(
io_loop_->task_runner(), file_loop_->task_runner()));
return net::ProxyService::CreateSystemProxyConfigService(
io_loop_->task_runner(), file_loop_->task_runner());
}
scoped_ptr<net::ProxyService> ShellURLRequestContextGetter::GetProxyService() {
// TODO(jam): use v8 if possible, look at chrome code.
return net::ProxyService::CreateUsingSystemProxyResolver(
proxy_config_service_.release(), 0, url_request_context_->net_log());
proxy_config_service_.Pass(), 0, url_request_context_->net_log());
}
net::URLRequestContext* ShellURLRequestContextGetter::GetURLRequestContext() {

@ -45,12 +45,12 @@ scoped_ptr<net::ProxyService> ProxyServiceFactory::CreateProxyService(
net::NetLog* net_log,
net::URLRequestContext* context,
net::NetworkDelegate* network_delegate,
net::ProxyConfigService* proxy_config_service,
scoped_ptr<net::ProxyConfigService> proxy_config_service,
bool quick_check_enabled) {
DCHECK_CURRENTLY_ON_WEB_THREAD(web::WebThread::IO);
scoped_ptr<net::ProxyService> proxy_service(
net::ProxyService::CreateUsingSystemProxyResolver(proxy_config_service, 0,
net_log));
net::ProxyService::CreateUsingSystemProxyResolver(
proxy_config_service.Pass(), 0, net_log));
proxy_service->set_quick_check_enabled(quick_check_enabled);
return proxy_service.Pass();
}

@ -43,7 +43,7 @@ class ProxyServiceFactory {
net::NetLog* net_log,
net::URLRequestContext* context,
net::NetworkDelegate* network_delegate,
net::ProxyConfigService* proxy_config_service,
scoped_ptr<net::ProxyConfigService> proxy_config_service,
bool quick_check_enabled);
private:

@ -280,8 +280,8 @@ void CrNetEnvironment::Install() {
// The network change notifier must be initialized so that registered
// delegates will receive callbacks.
network_change_notifier_.reset(net::NetworkChangeNotifier::Create());
proxy_config_service_.reset(net::ProxyService::CreateSystemProxyConfigService(
network_io_thread_->task_runner(), nullptr));
proxy_config_service_ = net::ProxyService::CreateSystemProxyConfigService(
network_io_thread_->task_runner(), nullptr);
PostToNetworkThread(FROM_HERE,
base::Bind(&CrNetEnvironment::InitializeOnNetworkThread,
@ -406,7 +406,7 @@ void CrNetEnvironment::InitializeOnNetworkThread() {
.release());
main_context_->set_proxy_service(
net::ProxyService::CreateUsingSystemProxyResolver(
proxy_config_service_.get(), 0, nullptr)
proxy_config_service_.Pass(), 0, nullptr)
.release());
// Cache

@ -89,8 +89,7 @@ net::URLRequestContext* ShellURLRequestContextGetter::GetURLRequestContext() {
.Pass());
storage_->set_proxy_service(
net::ProxyService::CreateUsingSystemProxyResolver(
proxy_config_service_.release(), 0,
url_request_context_->net_log()));
proxy_config_service_.Pass(), 0, url_request_context_->net_log()));
storage_->set_ssl_config_service(new net::SSLConfigServiceDefaults);
storage_->set_cert_verifier(net::CertVerifier::CreateDefault());

@ -9955,7 +9955,7 @@ TEST_P(HttpNetworkTransactionTest,
CapturingProxyResolver capturing_proxy_resolver;
session_deps_.proxy_service.reset(new ProxyService(
new ProxyConfigServiceFixed(proxy_config),
make_scoped_ptr(new ProxyConfigServiceFixed(proxy_config)),
make_scoped_ptr(
new CapturingProxyResolverFactory(&capturing_proxy_resolver)),
NULL));
@ -12764,7 +12764,8 @@ TEST_P(HttpNetworkTransactionTest, DoNotUseSpdySessionIfCertDoesNotMatch) {
ProxyConfig proxy_config;
proxy_config.proxy_rules().ParseFromString("http=https://proxy:443");
session_deps_.proxy_service.reset(new ProxyService(
new ProxyConfigServiceFixed(proxy_config), nullptr, NULL));
make_scoped_ptr(new ProxyConfigServiceFixed(proxy_config)), nullptr,
NULL));
SSLSocketDataProvider ssl1(ASYNC, OK); // to the proxy
ssl1.SetNextProto(GetParam());

@ -919,7 +919,7 @@ class ProxyService::PacRequest
// ProxyService ---------------------------------------------------------------
ProxyService::ProxyService(ProxyConfigService* config_service,
ProxyService::ProxyService(scoped_ptr<ProxyConfigService> config_service,
scoped_ptr<ProxyResolverFactory> resolver_factory,
NetLog* net_log)
: resolver_factory_(resolver_factory.Pass()),
@ -931,36 +931,36 @@ ProxyService::ProxyService(ProxyConfigService* config_service,
quick_check_enabled_(true) {
NetworkChangeNotifier::AddIPAddressObserver(this);
NetworkChangeNotifier::AddDNSObserver(this);
ResetConfigService(config_service);
ResetConfigService(config_service.Pass());
}
// static
scoped_ptr<ProxyService> ProxyService::CreateUsingSystemProxyResolver(
ProxyConfigService* proxy_config_service,
scoped_ptr<ProxyConfigService> proxy_config_service,
size_t num_pac_threads,
NetLog* net_log) {
DCHECK(proxy_config_service);
if (!ProxyResolverFactoryForSystem::IsSupported()) {
VLOG(1) << "PAC support disabled because there is no system implementation";
return CreateWithoutProxyResolver(proxy_config_service, net_log);
return CreateWithoutProxyResolver(proxy_config_service.Pass(), net_log);
}
if (num_pac_threads == 0)
num_pac_threads = kDefaultNumPacThreads;
return make_scoped_ptr(new ProxyService(
proxy_config_service,
proxy_config_service.Pass(),
make_scoped_ptr(new ProxyResolverFactoryForSystem(num_pac_threads)),
net_log));
}
// static
scoped_ptr<ProxyService> ProxyService::CreateWithoutProxyResolver(
ProxyConfigService* proxy_config_service,
scoped_ptr<ProxyConfigService> proxy_config_service,
NetLog* net_log) {
return make_scoped_ptr(new ProxyService(
proxy_config_service,
proxy_config_service.Pass(),
make_scoped_ptr(new ProxyResolverFactoryForNullResolver), net_log));
}
@ -968,8 +968,8 @@ scoped_ptr<ProxyService> ProxyService::CreateWithoutProxyResolver(
scoped_ptr<ProxyService> ProxyService::CreateFixed(const ProxyConfig& pc) {
// TODO(eroman): This isn't quite right, won't work if |pc| specifies
// a PAC script.
return CreateUsingSystemProxyResolver(new ProxyConfigServiceFixed(pc),
0, NULL);
return CreateUsingSystemProxyResolver(
make_scoped_ptr(new ProxyConfigServiceFixed(pc)), 0, NULL);
}
// static
@ -987,7 +987,7 @@ scoped_ptr<ProxyService> ProxyService::CreateDirect() {
scoped_ptr<ProxyService> ProxyService::CreateDirectWithNetLog(NetLog* net_log) {
// Use direct connections.
return make_scoped_ptr(new ProxyService(
new ProxyConfigServiceDirect,
make_scoped_ptr(new ProxyConfigServiceDirect),
make_scoped_ptr(new ProxyResolverFactoryForNullResolver), net_log));
}
@ -1000,7 +1000,7 @@ scoped_ptr<ProxyService> ProxyService::CreateFixedFromPacResult(
new ProxyConfigServiceFixed(ProxyConfig::CreateAutoDetect()));
return make_scoped_ptr(new ProxyService(
proxy_config_service.release(),
proxy_config_service.Pass(),
make_scoped_ptr(new ProxyResolverFactoryForPacResult(pac_string)), NULL));
}
@ -1470,7 +1470,7 @@ ProxyService::State ProxyService::ResetProxyConfig(bool reset_fetched_config) {
}
void ProxyService::ResetConfigService(
ProxyConfigService* new_proxy_config_service) {
scoped_ptr<ProxyConfigService> new_proxy_config_service) {
DCHECK(CalledOnValidThread());
State previous_state = ResetProxyConfig(true);
@ -1479,7 +1479,7 @@ void ProxyService::ResetConfigService(
config_service_->RemoveObserver(this);
// Set the new configuration service.
config_service_.reset(new_proxy_config_service);
config_service_ = new_proxy_config_service.Pass();
config_service_->AddObserver(this);
if (previous_state != STATE_NONE)
@ -1493,23 +1493,23 @@ void ProxyService::ForceReloadProxyConfig() {
}
// static
ProxyConfigService* ProxyService::CreateSystemProxyConfigService(
scoped_ptr<ProxyConfigService> ProxyService::CreateSystemProxyConfigService(
const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner,
const scoped_refptr<base::SingleThreadTaskRunner>& file_task_runner) {
#if defined(OS_WIN)
return new ProxyConfigServiceWin();
return make_scoped_ptr(new ProxyConfigServiceWin());
#elif defined(OS_IOS)
return new ProxyConfigServiceIOS();
return make_scoped_ptr(new ProxyConfigServiceIOS());
#elif defined(OS_MACOSX)
return new ProxyConfigServiceMac(io_task_runner);
return make_scoped_ptr(new ProxyConfigServiceMac(io_task_runner));
#elif defined(OS_CHROMEOS)
LOG(ERROR) << "ProxyConfigService for ChromeOS should be created in "
<< "profile_io_data.cc::CreateProxyConfigService and this should "
<< "be used only for examples.";
return new UnsetProxyConfigService;
return make_scoped_ptr(new UnsetProxyConfigService);
#elif defined(OS_LINUX)
ProxyConfigServiceLinux* linux_config_service =
new ProxyConfigServiceLinux();
scoped_ptr<ProxyConfigServiceLinux> linux_config_service(
new ProxyConfigServiceLinux());
// Assume we got called on the thread that runs the default glib
// main loop, so the current thread is where we should be running
@ -1524,14 +1524,14 @@ ProxyConfigService* ProxyService::CreateSystemProxyConfigService(
linux_config_service->SetupAndFetchInitialConfig(
glib_thread_task_runner, io_task_runner, file_task_runner);
return linux_config_service;
return linux_config_service.Pass();
#elif defined(OS_ANDROID)
return new ProxyConfigServiceAndroid(io_task_runner,
base::ThreadTaskRunnerHandle::Get());
return make_scoped_ptr(new ProxyConfigServiceAndroid(
io_task_runner, base::ThreadTaskRunnerHandle::Get()));
#else
LOG(WARNING) << "Failed to choose a system proxy settings fetcher "
"for this platform.";
return new ProxyConfigServiceDirect();
return make_scoped_ptr(new ProxyConfigServiceDirect());
#endif
}

@ -92,10 +92,9 @@ class NET_EXPORT ProxyService : public NetworkChangeNotifier::IPAddressObserver,
base::TimeDelta* next_delay) const = 0;
};
// The instance takes ownership of |config_service| and |resolver_factory|.
// |net_log| is a possibly NULL destination to send log events to. It must
// remain alive for the lifetime of this ProxyService.
ProxyService(ProxyConfigService* config_service,
ProxyService(scoped_ptr<ProxyConfigService> config_service,
scoped_ptr<ProxyResolverFactory> resolver_factory,
NetLog* net_log);
@ -203,9 +202,9 @@ class NET_EXPORT ProxyService : public NetworkChangeNotifier::IPAddressObserver,
// Tells this ProxyService to start using a new ProxyConfigService to
// retrieve its ProxyConfig from. The new ProxyConfigService will immediately
// be queried for new config info which will be used for all subsequent
// ResolveProxy calls. ProxyService takes ownership of
// |new_proxy_config_service|.
void ResetConfigService(ProxyConfigService* new_proxy_config_service);
// ResolveProxy calls.
void ResetConfigService(
scoped_ptr<ProxyConfigService> new_proxy_config_service);
// Returns the last configuration fetched from ProxyConfigService.
const ProxyConfig& fetched_config() {
@ -236,13 +235,13 @@ class NET_EXPORT ProxyService : public NetworkChangeNotifier::IPAddressObserver,
// libraries for evaluating the PAC script if available, otherwise skips
// proxy autoconfig.
static scoped_ptr<ProxyService> CreateUsingSystemProxyResolver(
ProxyConfigService* proxy_config_service,
scoped_ptr<ProxyConfigService> proxy_config_service,
size_t num_pac_threads,
NetLog* net_log);
// Creates a ProxyService without support for proxy autoconfig.
static scoped_ptr<ProxyService> CreateWithoutProxyResolver(
ProxyConfigService* proxy_config_service,
scoped_ptr<ProxyConfigService> proxy_config_service,
NetLog* net_log);
// Convenience methods that creates a proxy service using the
@ -265,7 +264,7 @@ class NET_EXPORT ProxyService : public NetworkChangeNotifier::IPAddressObserver,
// Creates a config service appropriate for this platform that fetches the
// system proxy settings.
static ProxyConfigService* CreateSystemProxyConfigService(
static scoped_ptr<ProxyConfigService> CreateSystemProxyConfigService(
const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner,
const scoped_refptr<base::SingleThreadTaskRunner>& file_task_runner);

@ -22,7 +22,7 @@ namespace net {
scoped_ptr<ProxyService> CreateProxyServiceUsingMojoFactory(
MojoProxyResolverFactory* mojo_proxy_factory,
ProxyConfigService* proxy_config_service,
scoped_ptr<ProxyConfigService> proxy_config_service,
ProxyScriptFetcher* proxy_script_fetcher,
scoped_ptr<DhcpProxyScriptFetcher> dhcp_proxy_script_fetcher,
HostResolver* host_resolver,
@ -34,7 +34,7 @@ scoped_ptr<ProxyService> CreateProxyServiceUsingMojoFactory(
DCHECK(host_resolver);
scoped_ptr<ProxyService> proxy_service(new ProxyService(
proxy_config_service,
proxy_config_service.Pass(),
make_scoped_ptr(new ProxyResolverFactoryMojo(
mojo_proxy_factory, host_resolver,
base::Bind(&NetworkDelegateErrorObserver::Create, network_delegate,
@ -50,16 +50,17 @@ scoped_ptr<ProxyService> CreateProxyServiceUsingMojoFactory(
}
scoped_ptr<ProxyService> CreateProxyServiceUsingMojoInProcess(
ProxyConfigService* proxy_config_service,
scoped_ptr<ProxyConfigService> proxy_config_service,
ProxyScriptFetcher* proxy_script_fetcher,
scoped_ptr<DhcpProxyScriptFetcher> dhcp_proxy_script_fetcher,
HostResolver* host_resolver,
NetLog* net_log,
NetworkDelegate* network_delegate) {
return CreateProxyServiceUsingMojoFactory(
InProcessMojoProxyResolverFactory::GetInstance(), proxy_config_service,
proxy_script_fetcher, dhcp_proxy_script_fetcher.Pass(), host_resolver,
net_log, network_delegate);
InProcessMojoProxyResolverFactory::GetInstance(),
proxy_config_service.Pass(), proxy_script_fetcher,
dhcp_proxy_script_fetcher.Pass(), host_resolver, net_log,
network_delegate);
}
} // namespace net

@ -24,8 +24,7 @@ class ProxyService;
// Creates a proxy service that uses |mojo_proxy_factory| to create and connect
// to a Mojo proxy resolver service. This proxy service polls
// |proxy_config_service| to notice when the proxy settings change. We take
// ownership of |proxy_config_service|.
// |proxy_config_service| to notice when the proxy settings change.
//
// |proxy_script_fetcher| specifies the dependency to use for downloading
// any PAC scripts. The resulting ProxyService will take ownership of it.
@ -38,7 +37,7 @@ class ProxyService;
// lifetime of the ProxyService.
scoped_ptr<ProxyService> CreateProxyServiceUsingMojoFactory(
MojoProxyResolverFactory* mojo_proxy_factory,
ProxyConfigService* proxy_config_service,
scoped_ptr<ProxyConfigService> proxy_config_service,
ProxyScriptFetcher* proxy_script_fetcher,
scoped_ptr<DhcpProxyScriptFetcher> dhcp_proxy_script_fetcher,
HostResolver* host_resolver,
@ -54,7 +53,7 @@ scoped_ptr<ProxyService> CreateProxyServiceUsingMojoFactory(
// # other V8's running in the process must use v8::Locker.
// ##########################################################################
scoped_ptr<ProxyService> CreateProxyServiceUsingMojoInProcess(
ProxyConfigService* proxy_config_service,
scoped_ptr<ProxyConfigService> proxy_config_service,
ProxyScriptFetcher* proxy_script_fetcher,
scoped_ptr<DhcpProxyScriptFetcher> dhcp_proxy_script_fetcher,
HostResolver* host_resolver,

@ -127,8 +127,8 @@ class ProxyServiceMojoTest : public testing::Test,
fetcher_ = new MockProxyScriptFetcher;
proxy_service_ = CreateProxyServiceUsingMojoFactory(
this, new ProxyConfigServiceFixed(
ProxyConfig::CreateFromCustomPacURL(GURL(kPacUrl))),
this, make_scoped_ptr(new ProxyConfigServiceFixed(
ProxyConfig::CreateFromCustomPacURL(GURL(kPacUrl)))),
fetcher_, make_scoped_ptr(new DoNothingDhcpProxyScriptFetcher()),
&mock_host_resolver_, &net_log_, &network_delegate_);
}

@ -311,8 +311,9 @@ RequestMap GetCancelledRequestsForURLs(const MockAsyncProxyResolver& resolver,
TEST_F(ProxyServiceTest, Direct) {
MockAsyncProxyResolverFactory* factory =
new MockAsyncProxyResolverFactory(false);
ProxyService service(new MockProxyConfigService(ProxyConfig::CreateDirect()),
make_scoped_ptr(factory), NULL);
ProxyService service(
make_scoped_ptr(new MockProxyConfigService(ProxyConfig::CreateDirect())),
make_scoped_ptr(factory), NULL);
GURL url("http://www.google.com/");
@ -348,7 +349,8 @@ TEST_F(ProxyServiceTest, OnResolveProxyCallbackAddProxy) {
config.set_auto_detect(false);
config.proxy_rules().bypass_rules.ParseFromString("*.org");
ProxyService service(new MockProxyConfigService(config), nullptr, NULL);
ProxyService service(make_scoped_ptr(new MockProxyConfigService(config)),
nullptr, NULL);
GURL url("http://www.google.com/");
GURL bypass_url("http://internet.org");
@ -402,7 +404,8 @@ TEST_F(ProxyServiceTest, OnResolveProxyCallbackRemoveProxy) {
config.set_auto_detect(false);
config.proxy_rules().bypass_rules.ParseFromString("*.org");
ProxyService service(new MockProxyConfigService(config), nullptr, NULL);
ProxyService service(make_scoped_ptr(new MockProxyConfigService(config)),
nullptr, NULL);
GURL url("http://www.google.com/");
GURL bypass_url("http://internet.org");
@ -445,7 +448,8 @@ TEST_F(ProxyServiceTest, PAC) {
MockAsyncProxyResolverFactory* factory =
new MockAsyncProxyResolverFactory(false);
ProxyService service(config_service, make_scoped_ptr(factory), NULL);
ProxyService service(make_scoped_ptr(config_service),
make_scoped_ptr(factory), NULL);
GURL url("http://www.google.com/");
@ -506,7 +510,8 @@ TEST_F(ProxyServiceTest, PAC_NoIdentityOrHash) {
MockAsyncProxyResolverFactory* factory =
new MockAsyncProxyResolverFactory(false);
ProxyService service(config_service, make_scoped_ptr(factory), NULL);
ProxyService service(make_scoped_ptr(config_service),
make_scoped_ptr(factory), NULL);
GURL url("http://username:password@www.google.com/?ref#hash#hash");
@ -536,7 +541,8 @@ TEST_F(ProxyServiceTest, PAC_FailoverWithoutDirect) {
MockAsyncProxyResolverFactory* factory =
new MockAsyncProxyResolverFactory(false);
ProxyService service(config_service, make_scoped_ptr(factory), NULL);
ProxyService service(make_scoped_ptr(config_service),
make_scoped_ptr(factory), NULL);
GURL url("http://www.google.com/");
@ -589,7 +595,8 @@ TEST_F(ProxyServiceTest, PAC_RuntimeError) {
MockAsyncProxyResolverFactory* factory =
new MockAsyncProxyResolverFactory(false);
ProxyService service(config_service, make_scoped_ptr(factory), NULL);
ProxyService service(make_scoped_ptr(config_service),
make_scoped_ptr(factory), NULL);
GURL url("http://this-causes-js-error/");
@ -646,7 +653,8 @@ TEST_F(ProxyServiceTest, PAC_FailoverAfterDirect) {
MockAsyncProxyResolverFactory* factory =
new MockAsyncProxyResolverFactory(false);
ProxyService service(config_service, make_scoped_ptr(factory), NULL);
ProxyService service(make_scoped_ptr(config_service),
make_scoped_ptr(factory), NULL);
GURL url("http://www.google.com/");
@ -721,7 +729,8 @@ TEST_F(ProxyServiceTest, PAC_ConfigSourcePropagates) {
MockAsyncProxyResolver resolver;
MockAsyncProxyResolverFactory* factory =
new MockAsyncProxyResolverFactory(false);
ProxyService service(config_service, make_scoped_ptr(factory), NULL);
ProxyService service(make_scoped_ptr(config_service),
make_scoped_ptr(factory), NULL);
// Resolve something.
GURL url("http://www.google.com/");
@ -758,7 +767,8 @@ TEST_F(ProxyServiceTest, ProxyResolverFails) {
MockAsyncProxyResolverFactory* factory =
new MockAsyncProxyResolverFactory(false);
ProxyService service(config_service, make_scoped_ptr(factory), NULL);
ProxyService service(make_scoped_ptr(config_service),
make_scoped_ptr(factory), NULL);
// Start first resolve request.
GURL url("http://www.google.com/");
@ -819,7 +829,8 @@ TEST_F(ProxyServiceTest, ProxyResolverTerminatedDuringRequest) {
MockAsyncProxyResolverFactory* factory =
new MockAsyncProxyResolverFactory(false);
ProxyService service(config_service, make_scoped_ptr(factory), nullptr);
ProxyService service(make_scoped_ptr(config_service),
make_scoped_ptr(factory), nullptr);
// Start first resolve request.
GURL url("http://www.google.com/");
@ -889,7 +900,8 @@ TEST_F(ProxyServiceTest,
MockAsyncProxyResolverFactory* factory =
new MockAsyncProxyResolverFactory(false);
ProxyService service(config_service, make_scoped_ptr(factory), nullptr);
ProxyService service(make_scoped_ptr(config_service),
make_scoped_ptr(factory), nullptr);
// Start two resolve requests.
GURL url1("http://www.google.com/");
@ -959,7 +971,8 @@ TEST_F(ProxyServiceTest, ProxyScriptFetcherFailsDownloadingMandatoryPac) {
MockAsyncProxyResolverFactory* factory =
new MockAsyncProxyResolverFactory(false);
ProxyService service(config_service, make_scoped_ptr(factory), NULL);
ProxyService service(make_scoped_ptr(config_service),
make_scoped_ptr(factory), NULL);
// Start first resolve request.
GURL url("http://www.google.com/");
@ -1003,7 +1016,8 @@ TEST_F(ProxyServiceTest, ProxyResolverFailsParsingJavaScriptMandatoryPac) {
MockAsyncProxyResolverFactory* factory =
new MockAsyncProxyResolverFactory(true);
ProxyService service(config_service, make_scoped_ptr(factory), NULL);
ProxyService service(make_scoped_ptr(config_service),
make_scoped_ptr(factory), NULL);
MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher;
service.SetProxyScriptFetchers(
@ -1052,7 +1066,8 @@ TEST_F(ProxyServiceTest, ProxyResolverFailsInJavaScriptMandatoryPac) {
MockAsyncProxyResolverFactory* factory =
new MockAsyncProxyResolverFactory(false);
ProxyService service(config_service, make_scoped_ptr(factory), NULL);
ProxyService service(make_scoped_ptr(config_service),
make_scoped_ptr(factory), NULL);
// Start first resolve request.
GURL url("http://www.google.com/");
@ -1109,7 +1124,8 @@ TEST_F(ProxyServiceTest, ProxyFallback) {
MockAsyncProxyResolverFactory* factory =
new MockAsyncProxyResolverFactory(false);
ProxyService service(config_service, make_scoped_ptr(factory), NULL);
ProxyService service(make_scoped_ptr(config_service),
make_scoped_ptr(factory), NULL);
GURL url("http://www.google.com/");
@ -1258,7 +1274,8 @@ TEST_F(ProxyServiceTest, ProxyFallbackToDirect) {
MockAsyncProxyResolverFactory* factory =
new MockAsyncProxyResolverFactory(false);
ProxyService service(config_service, make_scoped_ptr(factory), NULL);
ProxyService service(make_scoped_ptr(config_service),
make_scoped_ptr(factory), NULL);
GURL url("http://www.google.com/");
@ -1330,7 +1347,8 @@ TEST_F(ProxyServiceTest, ProxyFallback_NewSettings) {
MockAsyncProxyResolverFactory* factory =
new MockAsyncProxyResolverFactory(false);
ProxyService service(config_service, make_scoped_ptr(factory), NULL);
ProxyService service(make_scoped_ptr(config_service),
make_scoped_ptr(factory), NULL);
GURL url("http://www.google.com/");
@ -1432,7 +1450,8 @@ TEST_F(ProxyServiceTest, ProxyFallback_BadConfig) {
MockAsyncProxyResolverFactory* factory =
new MockAsyncProxyResolverFactory(false);
ProxyService service(config_service, make_scoped_ptr(factory), NULL);
ProxyService service(make_scoped_ptr(config_service),
make_scoped_ptr(factory), NULL);
GURL url("http://www.google.com/");
@ -1529,7 +1548,8 @@ TEST_F(ProxyServiceTest, ProxyFallback_BadConfigMandatory) {
MockAsyncProxyResolverFactory* factory =
new MockAsyncProxyResolverFactory(false);
ProxyService service(config_service, make_scoped_ptr(factory), NULL);
ProxyService service(make_scoped_ptr(config_service),
make_scoped_ptr(factory), NULL);
GURL url("http://www.google.com/");
@ -1620,7 +1640,8 @@ TEST_F(ProxyServiceTest, ProxyBypassList) {
config.set_auto_detect(false);
config.proxy_rules().bypass_rules.ParseFromString("*.org");
ProxyService service(new MockProxyConfigService(config), nullptr, NULL);
ProxyService service(make_scoped_ptr(new MockProxyConfigService(config)),
nullptr, NULL);
int rv;
GURL url1("http://www.webkit.org");
@ -1658,7 +1679,8 @@ TEST_F(ProxyServiceTest, MarkProxiesAsBadTests) {
EXPECT_EQ(3u, additional_bad_proxies.size());
ProxyService service(new MockProxyConfigService(config), nullptr, NULL);
ProxyService service(make_scoped_ptr(new MockProxyConfigService(config)),
nullptr, NULL);
ProxyInfo proxy_info;
proxy_info.UseProxyList(proxy_list);
const ProxyRetryInfoMap& retry_info = service.proxy_retry_info();
@ -1678,7 +1700,8 @@ TEST_F(ProxyServiceTest, PerProtocolProxyTests) {
config.proxy_rules().ParseFromString("http=foopy1:8080;https=foopy2:8080");
config.set_auto_detect(false);
{
ProxyService service(new MockProxyConfigService(config), nullptr, NULL);
ProxyService service(make_scoped_ptr(new MockProxyConfigService(config)),
nullptr, NULL);
GURL test_url("http://www.msn.com");
ProxyInfo info;
TestCompletionCallback callback;
@ -1690,7 +1713,8 @@ TEST_F(ProxyServiceTest, PerProtocolProxyTests) {
EXPECT_EQ("foopy1:8080", info.proxy_server().ToURI());
}
{
ProxyService service(new MockProxyConfigService(config), nullptr, NULL);
ProxyService service(make_scoped_ptr(new MockProxyConfigService(config)),
nullptr, NULL);
GURL test_url("ftp://ftp.google.com");
ProxyInfo info;
TestCompletionCallback callback;
@ -1702,7 +1726,8 @@ TEST_F(ProxyServiceTest, PerProtocolProxyTests) {
EXPECT_EQ("direct://", info.proxy_server().ToURI());
}
{
ProxyService service(new MockProxyConfigService(config), nullptr, NULL);
ProxyService service(make_scoped_ptr(new MockProxyConfigService(config)),
nullptr, NULL);
GURL test_url("https://webbranch.techcu.com");
ProxyInfo info;
TestCompletionCallback callback;
@ -1715,7 +1740,8 @@ TEST_F(ProxyServiceTest, PerProtocolProxyTests) {
}
{
config.proxy_rules().ParseFromString("foopy1:8080");
ProxyService service(new MockProxyConfigService(config), nullptr, NULL);
ProxyService service(make_scoped_ptr(new MockProxyConfigService(config)),
nullptr, NULL);
GURL test_url("http://www.microsoft.com");
ProxyInfo info;
TestCompletionCallback callback;
@ -1736,7 +1762,8 @@ TEST_F(ProxyServiceTest, ProxyConfigSourcePropagates) {
ProxyConfig config;
config.set_source(PROXY_CONFIG_SOURCE_TEST);
config.proxy_rules().ParseFromString("https=foopy2:8080");
ProxyService service(new MockProxyConfigService(config), nullptr, NULL);
ProxyService service(make_scoped_ptr(new MockProxyConfigService(config)),
nullptr, NULL);
GURL test_url("http://www.google.com");
ProxyInfo info;
TestCompletionCallback callback;
@ -1751,7 +1778,8 @@ TEST_F(ProxyServiceTest, ProxyConfigSourcePropagates) {
ProxyConfig config;
config.set_source(PROXY_CONFIG_SOURCE_TEST);
config.proxy_rules().ParseFromString("https=foopy2:8080");
ProxyService service(new MockProxyConfigService(config), nullptr, NULL);
ProxyService service(make_scoped_ptr(new MockProxyConfigService(config)),
nullptr, NULL);
GURL test_url("https://www.google.com");
ProxyInfo info;
TestCompletionCallback callback;
@ -1765,7 +1793,8 @@ TEST_F(ProxyServiceTest, ProxyConfigSourcePropagates) {
{
ProxyConfig config;
config.set_source(PROXY_CONFIG_SOURCE_TEST);
ProxyService service(new MockProxyConfigService(config), nullptr, NULL);
ProxyService service(make_scoped_ptr(new MockProxyConfigService(config)),
nullptr, NULL);
GURL test_url("http://www.google.com");
ProxyInfo info;
TestCompletionCallback callback;
@ -1788,7 +1817,8 @@ TEST_F(ProxyServiceTest, DefaultProxyFallbackToSOCKS) {
config.proxy_rules().type);
{
ProxyService service(new MockProxyConfigService(config), nullptr, NULL);
ProxyService service(make_scoped_ptr(new MockProxyConfigService(config)),
nullptr, NULL);
GURL test_url("http://www.msn.com");
ProxyInfo info;
TestCompletionCallback callback;
@ -1800,7 +1830,8 @@ TEST_F(ProxyServiceTest, DefaultProxyFallbackToSOCKS) {
EXPECT_EQ("foopy1:8080", info.proxy_server().ToURI());
}
{
ProxyService service(new MockProxyConfigService(config), nullptr, NULL);
ProxyService service(make_scoped_ptr(new MockProxyConfigService(config)),
nullptr, NULL);
GURL test_url("ftp://ftp.google.com");
ProxyInfo info;
TestCompletionCallback callback;
@ -1812,7 +1843,8 @@ TEST_F(ProxyServiceTest, DefaultProxyFallbackToSOCKS) {
EXPECT_EQ("socks4://foopy2:1080", info.proxy_server().ToURI());
}
{
ProxyService service(new MockProxyConfigService(config), nullptr, NULL);
ProxyService service(make_scoped_ptr(new MockProxyConfigService(config)),
nullptr, NULL);
GURL test_url("https://webbranch.techcu.com");
ProxyInfo info;
TestCompletionCallback callback;
@ -1824,7 +1856,8 @@ TEST_F(ProxyServiceTest, DefaultProxyFallbackToSOCKS) {
EXPECT_EQ("socks4://foopy2:1080", info.proxy_server().ToURI());
}
{
ProxyService service(new MockProxyConfigService(config), nullptr, NULL);
ProxyService service(make_scoped_ptr(new MockProxyConfigService(config)),
nullptr, NULL);
GURL test_url("unknown://www.microsoft.com");
ProxyInfo info;
TestCompletionCallback callback;
@ -1849,7 +1882,8 @@ TEST_F(ProxyServiceTest, CancelInProgressRequest) {
MockAsyncProxyResolverFactory* factory =
new MockAsyncProxyResolverFactory(false);
ProxyService service(config_service, make_scoped_ptr(factory), NULL);
ProxyService service(make_scoped_ptr(config_service),
make_scoped_ptr(factory), NULL);
// Start 3 requests.
@ -1911,7 +1945,6 @@ TEST_F(ProxyServiceTest, InitialPACScriptDownload) {
const GURL url1("http://request1");
const GURL url2("http://request2");
const GURL url3("http://request3");
MockProxyConfigService* config_service =
new MockProxyConfigService("http://foopy/proxy.pac");
@ -1919,7 +1952,8 @@ TEST_F(ProxyServiceTest, InitialPACScriptDownload) {
MockAsyncProxyResolverFactory* factory =
new MockAsyncProxyResolverFactory(true);
ProxyService service(config_service, make_scoped_ptr(factory), NULL);
ProxyService service(make_scoped_ptr(config_service),
make_scoped_ptr(factory), NULL);
MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher;
service.SetProxyScriptFetchers(
@ -2021,7 +2055,8 @@ TEST_F(ProxyServiceTest, ChangeScriptFetcherWhilePACDownloadInProgress) {
MockAsyncProxyResolverFactory* factory =
new MockAsyncProxyResolverFactory(true);
ProxyService service(config_service, make_scoped_ptr(factory), NULL);
ProxyService service(make_scoped_ptr(config_service),
make_scoped_ptr(factory), NULL);
MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher;
service.SetProxyScriptFetchers(
@ -2079,7 +2114,8 @@ TEST_F(ProxyServiceTest, CancelWhilePACFetching) {
MockAsyncProxyResolverFactory* factory =
new MockAsyncProxyResolverFactory(true);
ProxyService service(config_service, make_scoped_ptr(factory), NULL);
ProxyService service(make_scoped_ptr(config_service),
make_scoped_ptr(factory), NULL);
MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher;
service.SetProxyScriptFetchers(
@ -2176,7 +2212,8 @@ TEST_F(ProxyServiceTest, FallbackFromAutodetectToCustomPac) {
MockAsyncProxyResolver resolver;
MockAsyncProxyResolverFactory* factory =
new MockAsyncProxyResolverFactory(true);
ProxyService service(config_service, make_scoped_ptr(factory), NULL);
ProxyService service(make_scoped_ptr(config_service),
make_scoped_ptr(factory), NULL);
MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher;
service.SetProxyScriptFetchers(
@ -2254,7 +2291,8 @@ TEST_F(ProxyServiceTest, FallbackFromAutodetectToCustomPac2) {
MockAsyncProxyResolver resolver;
MockAsyncProxyResolverFactory* factory =
new MockAsyncProxyResolverFactory(true);
ProxyService service(config_service, make_scoped_ptr(factory), NULL);
ProxyService service(make_scoped_ptr(config_service),
make_scoped_ptr(factory), NULL);
MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher;
service.SetProxyScriptFetchers(
@ -2325,7 +2363,8 @@ TEST_F(ProxyServiceTest, FallbackFromAutodetectToCustomToManual) {
MockProxyConfigService* config_service = new MockProxyConfigService(config);
MockAsyncProxyResolverFactory* factory =
new MockAsyncProxyResolverFactory(true);
ProxyService service(config_service, make_scoped_ptr(factory), NULL);
ProxyService service(make_scoped_ptr(config_service),
make_scoped_ptr(factory), NULL);
MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher;
service.SetProxyScriptFetchers(
@ -2386,7 +2425,8 @@ TEST_F(ProxyServiceTest, BypassDoesntApplyToPac) {
MockAsyncProxyResolver resolver;
MockAsyncProxyResolverFactory* factory =
new MockAsyncProxyResolverFactory(true);
ProxyService service(config_service, make_scoped_ptr(factory), NULL);
ProxyService service(make_scoped_ptr(config_service),
make_scoped_ptr(factory), NULL);
MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher;
service.SetProxyScriptFetchers(
@ -2455,7 +2495,8 @@ TEST_F(ProxyServiceTest, DeleteWhileInitProxyResolverHasOutstandingFetch) {
MockProxyConfigService* config_service = new MockProxyConfigService(config);
MockAsyncProxyResolverFactory* factory =
new MockAsyncProxyResolverFactory(true);
ProxyService service(config_service, make_scoped_ptr(factory), NULL);
ProxyService service(make_scoped_ptr(config_service),
make_scoped_ptr(factory), NULL);
MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher;
service.SetProxyScriptFetchers(
@ -2490,7 +2531,8 @@ TEST_F(ProxyServiceTest, DeleteWhileInitProxyResolverHasOutstandingSet) {
MockAsyncProxyResolverFactory* factory =
new MockAsyncProxyResolverFactory(false);
ProxyService service(config_service, make_scoped_ptr(factory), NULL);
ProxyService service(make_scoped_ptr(config_service),
make_scoped_ptr(factory), NULL);
GURL url("http://www.google.com/");
@ -2508,7 +2550,8 @@ TEST_F(ProxyServiceTest, ResetProxyConfigService) {
ProxyConfig config1;
config1.proxy_rules().ParseFromString("foopy1:8080");
config1.set_auto_detect(false);
ProxyService service(new MockProxyConfigService(config1), nullptr, NULL);
ProxyService service(make_scoped_ptr(new MockProxyConfigService(config1)),
nullptr, NULL);
ProxyInfo info;
TestCompletionCallback callback1;
@ -2521,7 +2564,8 @@ TEST_F(ProxyServiceTest, ResetProxyConfigService) {
ProxyConfig config2;
config2.proxy_rules().ParseFromString("foopy2:8080");
config2.set_auto_detect(false);
service.ResetConfigService(new MockProxyConfigService(config2));
service.ResetConfigService(
make_scoped_ptr(new MockProxyConfigService(config2)));
TestCompletionCallback callback2;
rv = service.ResolveProxy(GURL("http://request2"), LOAD_NORMAL, &info,
callback2.callback(), NULL, NULL, BoundNetLog());
@ -2538,7 +2582,8 @@ TEST_F(ProxyServiceTest, UpdateConfigFromPACToDirect) {
MockAsyncProxyResolver resolver;
MockAsyncProxyResolverFactory* factory =
new MockAsyncProxyResolverFactory(false);
ProxyService service(config_service, make_scoped_ptr(factory), NULL);
ProxyService service(make_scoped_ptr(config_service),
make_scoped_ptr(factory), NULL);
// Start 1 request.
@ -2590,7 +2635,8 @@ TEST_F(ProxyServiceTest, NetworkChangeTriggersPacRefetch) {
TestNetLog log;
ProxyService service(config_service, make_scoped_ptr(factory), &log);
ProxyService service(make_scoped_ptr(config_service),
make_scoped_ptr(factory), &log);
MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher;
service.SetProxyScriptFetchers(
@ -2710,7 +2756,8 @@ TEST_F(ProxyServiceTest, PACScriptRefetchAfterFailure) {
MockAsyncProxyResolverFactory* factory =
new MockAsyncProxyResolverFactory(true);
ProxyService service(config_service, make_scoped_ptr(factory), NULL);
ProxyService service(make_scoped_ptr(config_service),
make_scoped_ptr(factory), NULL);
MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher;
service.SetProxyScriptFetchers(
@ -2815,7 +2862,8 @@ TEST_F(ProxyServiceTest, PACScriptRefetchAfterContentChange) {
MockAsyncProxyResolverFactory* factory =
new MockAsyncProxyResolverFactory(true);
ProxyService service(config_service, make_scoped_ptr(factory), NULL);
ProxyService service(make_scoped_ptr(config_service),
make_scoped_ptr(factory), NULL);
MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher;
service.SetProxyScriptFetchers(
@ -2926,7 +2974,8 @@ TEST_F(ProxyServiceTest, PACScriptRefetchAfterContentUnchanged) {
MockAsyncProxyResolverFactory* factory =
new MockAsyncProxyResolverFactory(true);
ProxyService service(config_service, make_scoped_ptr(factory), NULL);
ProxyService service(make_scoped_ptr(config_service),
make_scoped_ptr(factory), NULL);
MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher;
service.SetProxyScriptFetchers(
@ -3034,7 +3083,8 @@ TEST_F(ProxyServiceTest, PACScriptRefetchAfterSuccess) {
MockAsyncProxyResolverFactory* factory =
new MockAsyncProxyResolverFactory(true);
ProxyService service(config_service, make_scoped_ptr(factory), NULL);
ProxyService service(make_scoped_ptr(config_service),
make_scoped_ptr(factory), NULL);
MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher;
service.SetProxyScriptFetchers(
@ -3187,7 +3237,8 @@ TEST_F(ProxyServiceTest, PACScriptRefetchAfterActivity) {
MockAsyncProxyResolverFactory* factory =
new MockAsyncProxyResolverFactory(true);
ProxyService service(config_service, make_scoped_ptr(factory), NULL);
ProxyService service(make_scoped_ptr(config_service),
make_scoped_ptr(factory), NULL);
MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher;
service.SetProxyScriptFetchers(
@ -3286,7 +3337,8 @@ TEST_F(ProxyServiceTest, SynchronousWithPAC) {
MockAsyncProxyResolverFactory* factory =
new MockAsyncProxyResolverFactory(false);
ProxyService service(config_service, make_scoped_ptr(factory), NULL);
ProxyService service(make_scoped_ptr(config_service),
make_scoped_ptr(factory), NULL);
GURL url("http://www.google.com/");
@ -3312,7 +3364,7 @@ TEST_F(ProxyServiceTest, SynchronousWithFixedConfiguration) {
MockAsyncProxyResolverFactory* factory =
new MockAsyncProxyResolverFactory(false);
ProxyService service(new MockProxyConfigService(config),
ProxyService service(make_scoped_ptr(new MockProxyConfigService(config)),
make_scoped_ptr(factory), NULL);
GURL url("http://www.google.com/");

@ -18,7 +18,7 @@ namespace net {
// static
scoped_ptr<ProxyService> CreateProxyServiceUsingV8ProxyResolver(
ProxyConfigService* proxy_config_service,
scoped_ptr<ProxyConfigService> proxy_config_service,
ProxyScriptFetcher* proxy_script_fetcher,
scoped_ptr<DhcpProxyScriptFetcher> dhcp_proxy_script_fetcher,
HostResolver* host_resolver,
@ -30,7 +30,7 @@ scoped_ptr<ProxyService> CreateProxyServiceUsingV8ProxyResolver(
DCHECK(host_resolver);
scoped_ptr<ProxyService> proxy_service(new ProxyService(
proxy_config_service,
proxy_config_service.Pass(),
make_scoped_ptr(new ProxyResolverFactoryV8TracingWrapper(
host_resolver, net_log,
base::Bind(&NetworkDelegateErrorObserver::Create, network_delegate,

@ -20,7 +20,7 @@ class ProxyScriptFetcher;
class ProxyService;
// Creates a proxy service that polls |proxy_config_service| to notice when
// the proxy settings change. We take ownership of |proxy_config_service|.
// the proxy settings change.
//
// |proxy_script_fetcher| specifies the dependency to use for downloading
// any PAC scripts. The resulting ProxyService will take ownership of it.
@ -38,7 +38,7 @@ class ProxyService;
// # other V8's running in the process must use v8::Locker.
// ##########################################################################
NET_EXPORT scoped_ptr<ProxyService> CreateProxyServiceUsingV8ProxyResolver(
ProxyConfigService* proxy_config_service,
scoped_ptr<ProxyConfigService> proxy_config_service,
ProxyScriptFetcher* proxy_script_fetcher,
scoped_ptr<DhcpProxyScriptFetcher> dhcp_proxy_script_fetcher,
HostResolver* host_resolver,

@ -295,20 +295,15 @@ scoped_ptr<URLRequestContext> URLRequestContextBuilder::Build() {
if (!proxy_service_) {
// TODO(willchan): Switch to using this code when
// ProxyService::CreateSystemProxyConfigService()'s signature doesn't suck.
#if defined(OS_LINUX) || defined(OS_ANDROID)
ProxyConfigService* proxy_config_service = proxy_config_service_.release();
#else
ProxyConfigService* proxy_config_service = NULL;
if (proxy_config_service_) {
proxy_config_service = proxy_config_service_.release();
} else {
proxy_config_service = ProxyService::CreateSystemProxyConfigService(
#if !defined(OS_LINUX) && !defined(OS_ANDROID)
if (!proxy_config_service_) {
proxy_config_service_ = ProxyService::CreateSystemProxyConfigService(
base::ThreadTaskRunnerHandle::Get().get(),
context->GetFileTaskRunner());
}
#endif // defined(OS_LINUX) || defined(OS_ANDROID)
#endif // !defined(OS_LINUX) && !defined(OS_ANDROID)
proxy_service_ = ProxyService::CreateUsingSystemProxyResolver(
proxy_config_service,
proxy_config_service_.Pass(),
0, // This results in using the default value.
context->net_log());
}

@ -138,7 +138,9 @@ class MockFtpTransactionFactory : public FtpTransactionFactory {
class URLRequestFtpJobPriorityTest : public testing::Test {
protected:
URLRequestFtpJobPriorityTest()
: proxy_service_(new SimpleProxyConfigService, NULL, NULL),
: proxy_service_(make_scoped_ptr(new SimpleProxyConfigService),
NULL,
NULL),
req_(context_.CreateRequest(GURL("ftp://ftp.example.com"),
DEFAULT_PRIORITY,
&delegate_)) {
@ -227,12 +229,13 @@ TEST_F(URLRequestFtpJobPriorityTest, SetSubsequentTransactionPriority) {
class URLRequestFtpJobTest : public testing::Test {
public:
URLRequestFtpJobTest()
: request_context_(
&socket_factory_,
make_scoped_ptr(
new ProxyService(new SimpleProxyConfigService, NULL, NULL)),
&network_delegate_,
&ftp_transaction_factory_) {}
: request_context_(&socket_factory_,
make_scoped_ptr(new ProxyService(
make_scoped_ptr(new SimpleProxyConfigService),
NULL,
NULL)),
&network_delegate_,
&ftp_transaction_factory_) {}
~URLRequestFtpJobTest() override {
// Clean up any remaining tasks that mess up unrelated tests.
@ -297,8 +300,8 @@ TEST_F(URLRequestFtpJobTest, FtpProxyRequest) {
TEST_F(URLRequestFtpJobTest, FtpProxyRequestOrphanJob) {
// Use a PAC URL so that URLRequestFtpJob's |pac_request_| field is non-NULL.
request_context()->set_proxy_service(make_scoped_ptr(new ProxyService(
new ProxyConfigServiceFixed(
ProxyConfig::CreateFromCustomPacURL(GURL("http://foo"))),
make_scoped_ptr(new ProxyConfigServiceFixed(
ProxyConfig::CreateFromCustomPacURL(GURL("http://foo")))),
make_scoped_ptr(new MockProxyResolverFactory), NULL)));
TestDelegate request_delegate;

@ -16,10 +16,10 @@ URLRequestContextGetter::URLRequestContextGetter(
scoped_refptr<base::SingleThreadTaskRunner> network_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> file_task_runner)
: network_task_runner_(network_task_runner),
file_task_runner_(file_task_runner) {
proxy_config_service_.reset(net::ProxyService::CreateSystemProxyConfigService(
network_task_runner_, file_task_runner));
}
file_task_runner_(file_task_runner),
proxy_config_service_(
net::ProxyService::CreateSystemProxyConfigService(
network_task_runner, file_task_runner)) {}
net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() {
if (!url_request_context_.get()) {