Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(638)

Side by Side Diff: net/proxy/proxy_service.cc

Issue 10912132: Move ProxyConfigService construction onto the IO thread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Adjust comments Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/proxy/proxy_service.h" 5 #include "net/proxy/proxy_service.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 1300 matching lines...) Expand 10 before | Expand all | Expand 10 after
1311 if (resolver_.get()) 1311 if (resolver_.get())
1312 resolver_->PurgeMemory(); 1312 resolver_->PurgeMemory();
1313 } 1313 }
1314 1314
1315 void ProxyService::ForceReloadProxyConfig() { 1315 void ProxyService::ForceReloadProxyConfig() {
1316 DCHECK(CalledOnValidThread()); 1316 DCHECK(CalledOnValidThread());
1317 ResetProxyConfig(false); 1317 ResetProxyConfig(false);
1318 ApplyProxyConfigIfAvailable(); 1318 ApplyProxyConfigIfAvailable();
1319 } 1319 }
1320 1320
1321 void ProxyService::StartTearDown() {
1322 config_service_->StartTearDown();
1323 }
1324
1321 // static 1325 // static
1322 ProxyConfigService* ProxyService::CreateSystemProxyConfigService( 1326 ProxyConfigService* ProxyService::CreateSystemProxyConfigService(
1323 base::SingleThreadTaskRunner* io_thread_task_runner, 1327 base::SingleThreadTaskRunner* glib_thread_task_runner,
1324 MessageLoop* file_loop) { 1328 MessageLoop* file_loop) {
1325 #if defined(OS_WIN) 1329 #if defined(OS_WIN)
1326 return new ProxyConfigServiceWin(); 1330 return new ProxyConfigServiceWin();
1327 #elif defined(OS_IOS) 1331 #elif defined(OS_IOS)
1328 return new ProxyConfigServiceIOS(); 1332 return new ProxyConfigServiceIOS();
1329 #elif defined(OS_MACOSX) 1333 #elif defined(OS_MACOSX)
1330 return new ProxyConfigServiceMac(io_thread_task_runner); 1334 return new ProxyConfigServiceMac(
1335 MessageLoopForIO::current()->message_loop_proxy());
1331 #elif defined(OS_CHROMEOS) 1336 #elif defined(OS_CHROMEOS)
1332 LOG(ERROR) << "ProxyConfigService for ChromeOS should be created in " 1337 LOG(ERROR) << "ProxyConfigService for ChromeOS should be created in "
1333 << "profile_io_data.cc::CreateProxyConfigService and this should " 1338 << "profile_io_data.cc::CreateProxyConfigService and this should "
1334 << "be used only for examples."; 1339 << "be used only for examples.";
1335 return new UnsetProxyConfigService; 1340 return new UnsetProxyConfigService;
1336 #elif defined(OS_LINUX) 1341 #elif defined(OS_LINUX)
1337 ProxyConfigServiceLinux* linux_config_service =
1338 new ProxyConfigServiceLinux();
1339
1340 // Assume we got called on the thread that runs the default glib
1341 // main loop, so the current thread is where we should be running
1342 // gconf calls from.
1343 scoped_refptr<base::SingleThreadTaskRunner> glib_thread_task_runner =
1344 base::ThreadTaskRunnerHandle::Get();
1345
1346 // The file loop should be a MessageLoopForIO on Linux. 1342 // The file loop should be a MessageLoopForIO on Linux.
1347 DCHECK_EQ(MessageLoop::TYPE_IO, file_loop->type()); 1343 DCHECK_EQ(MessageLoop::TYPE_IO, file_loop->type());
1348 1344 return new ProxyConfigServiceLinux(
1349 // Synchronously fetch the current proxy config (since we are 1345 glib_thread_task_runner,
1350 // running on glib_default_loop). Additionally register for 1346 MessageLoopForIO::current()->message_loop_proxy(),
1351 // notifications (delivered in either |glib_default_loop| or
1352 // |file_loop|) to keep us updated when the proxy config changes.
1353 linux_config_service->SetupAndFetchInitialConfig(
1354 glib_thread_task_runner, io_thread_task_runner,
1355 static_cast<MessageLoopForIO*>(file_loop)); 1347 static_cast<MessageLoopForIO*>(file_loop));
1356
1357 return linux_config_service;
1358 #elif defined(OS_ANDROID) 1348 #elif defined(OS_ANDROID)
1359 return new ProxyConfigServiceAndroid( 1349 return new ProxyConfigServiceAndroid(
1360 io_thread_task_runner, 1350 glib_thread_task_runner,
1361 MessageLoopForUI::current()->message_loop_proxy()); 1351 MessageLoopForIO::current()->message_loop_proxy());
1362 #else 1352 #else
1363 LOG(WARNING) << "Failed to choose a system proxy settings fetcher " 1353 LOG(WARNING) << "Failed to choose a system proxy settings fetcher "
1364 "for this platform."; 1354 "for this platform.";
1365 return new ProxyConfigServiceDirect(); 1355 return new ProxyConfigServiceDirect();
1366 #endif 1356 #endif
1367 } 1357 }
1368 1358
1369 // static 1359 // static
1370 const ProxyService::PacPollPolicy* ProxyService::set_pac_script_poll_policy( 1360 const ProxyService::PacPollPolicy* ProxyService::set_pac_script_poll_policy(
1371 const PacPollPolicy* policy) { 1361 const PacPollPolicy* policy) {
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
1552 OnCompletion(result_); 1542 OnCompletion(result_);
1553 } 1543 }
1554 } 1544 }
1555 1545
1556 void SyncProxyServiceHelper::OnCompletion(int rv) { 1546 void SyncProxyServiceHelper::OnCompletion(int rv) {
1557 result_ = rv; 1547 result_ = rv;
1558 event_.Signal(); 1548 event_.Signal();
1559 } 1549 }
1560 1550
1561 } // namespace net 1551 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698