OLD | NEW |
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 1379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1390 } | 1390 } |
1391 | 1391 |
1392 void ProxyService::ForceReloadProxyConfig() { | 1392 void ProxyService::ForceReloadProxyConfig() { |
1393 DCHECK(CalledOnValidThread()); | 1393 DCHECK(CalledOnValidThread()); |
1394 ResetProxyConfig(false); | 1394 ResetProxyConfig(false); |
1395 ApplyProxyConfigIfAvailable(); | 1395 ApplyProxyConfigIfAvailable(); |
1396 } | 1396 } |
1397 | 1397 |
1398 // static | 1398 // static |
1399 ProxyConfigService* ProxyService::CreateSystemProxyConfigService( | 1399 ProxyConfigService* ProxyService::CreateSystemProxyConfigService( |
1400 base::SingleThreadTaskRunner* io_thread_task_runner, | 1400 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner, |
1401 base::MessageLoop* file_loop) { | 1401 const scoped_refptr<base::SingleThreadTaskRunner>& file_task_runner) { |
1402 #if defined(OS_WIN) | 1402 #if defined(OS_WIN) |
1403 return new ProxyConfigServiceWin(); | 1403 return new ProxyConfigServiceWin(); |
1404 #elif defined(OS_IOS) | 1404 #elif defined(OS_IOS) |
1405 return new ProxyConfigServiceIOS(); | 1405 return new ProxyConfigServiceIOS(); |
1406 #elif defined(OS_MACOSX) | 1406 #elif defined(OS_MACOSX) |
1407 return new ProxyConfigServiceMac(io_thread_task_runner); | 1407 return new ProxyConfigServiceMac(io_task_runner); |
1408 #elif defined(OS_CHROMEOS) | 1408 #elif defined(OS_CHROMEOS) |
1409 LOG(ERROR) << "ProxyConfigService for ChromeOS should be created in " | 1409 LOG(ERROR) << "ProxyConfigService for ChromeOS should be created in " |
1410 << "profile_io_data.cc::CreateProxyConfigService and this should " | 1410 << "profile_io_data.cc::CreateProxyConfigService and this should " |
1411 << "be used only for examples."; | 1411 << "be used only for examples."; |
1412 return new UnsetProxyConfigService; | 1412 return new UnsetProxyConfigService; |
1413 #elif defined(OS_LINUX) | 1413 #elif defined(OS_LINUX) |
1414 ProxyConfigServiceLinux* linux_config_service = | 1414 ProxyConfigServiceLinux* linux_config_service = |
1415 new ProxyConfigServiceLinux(); | 1415 new ProxyConfigServiceLinux(); |
1416 | 1416 |
1417 // Assume we got called on the thread that runs the default glib | 1417 // Assume we got called on the thread that runs the default glib |
1418 // main loop, so the current thread is where we should be running | 1418 // main loop, so the current thread is where we should be running |
1419 // gconf calls from. | 1419 // gconf calls from. |
1420 scoped_refptr<base::SingleThreadTaskRunner> glib_thread_task_runner = | 1420 scoped_refptr<base::SingleThreadTaskRunner> glib_thread_task_runner = |
1421 base::ThreadTaskRunnerHandle::Get(); | 1421 base::ThreadTaskRunnerHandle::Get(); |
1422 | 1422 |
1423 // The file loop should be a MessageLoopForIO on Linux. | 1423 // Synchronously fetch the current proxy config (since we are running on |
1424 DCHECK_EQ(base::MessageLoop::TYPE_IO, file_loop->type()); | 1424 // glib_default_loop). Additionally register for notifications (delivered in |
1425 | 1425 // either |glib_default_loop| or |file_task_runner|) to keep us updated when |
1426 // Synchronously fetch the current proxy config (since we are | 1426 // the proxy config changes. |
1427 // running on glib_default_loop). Additionally register for | |
1428 // notifications (delivered in either |glib_default_loop| or | |
1429 // |file_loop|) to keep us updated when the proxy config changes. | |
1430 linux_config_service->SetupAndFetchInitialConfig( | 1427 linux_config_service->SetupAndFetchInitialConfig( |
1431 glib_thread_task_runner.get(), | 1428 glib_thread_task_runner, io_task_runner, file_task_runner); |
1432 io_thread_task_runner, | |
1433 static_cast<base::MessageLoopForIO*>(file_loop)); | |
1434 | 1429 |
1435 return linux_config_service; | 1430 return linux_config_service; |
1436 #elif defined(OS_ANDROID) | 1431 #elif defined(OS_ANDROID) |
1437 return new ProxyConfigServiceAndroid( | 1432 return new ProxyConfigServiceAndroid( |
1438 io_thread_task_runner, | 1433 io_task_runner, base::MessageLoop::current()->message_loop_proxy()); |
1439 base::MessageLoop::current()->message_loop_proxy()); | |
1440 #else | 1434 #else |
1441 LOG(WARNING) << "Failed to choose a system proxy settings fetcher " | 1435 LOG(WARNING) << "Failed to choose a system proxy settings fetcher " |
1442 "for this platform."; | 1436 "for this platform."; |
1443 return new ProxyConfigServiceDirect(); | 1437 return new ProxyConfigServiceDirect(); |
1444 #endif | 1438 #endif |
1445 } | 1439 } |
1446 | 1440 |
1447 // static | 1441 // static |
1448 const ProxyService::PacPollPolicy* ProxyService::set_pac_script_poll_policy( | 1442 const ProxyService::PacPollPolicy* ProxyService::set_pac_script_poll_policy( |
1449 const PacPollPolicy* policy) { | 1443 const PacPollPolicy* policy) { |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1560 State previous_state = ResetProxyConfig(false); | 1554 State previous_state = ResetProxyConfig(false); |
1561 if (previous_state != STATE_NONE) | 1555 if (previous_state != STATE_NONE) |
1562 ApplyProxyConfigIfAvailable(); | 1556 ApplyProxyConfigIfAvailable(); |
1563 } | 1557 } |
1564 | 1558 |
1565 void ProxyService::OnDNSChanged() { | 1559 void ProxyService::OnDNSChanged() { |
1566 OnIPAddressChanged(); | 1560 OnIPAddressChanged(); |
1567 } | 1561 } |
1568 | 1562 |
1569 } // namespace net | 1563 } // namespace net |
OLD | NEW |