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 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
670 | 670 |
671 if (result != OK) { | 671 if (result != OK) { |
672 // If it failed last time and failed again with the same error code this | 672 // If it failed last time and failed again with the same error code this |
673 // time, then nothing has actually changed. | 673 // time, then nothing has actually changed. |
674 return false; | 674 return false; |
675 } | 675 } |
676 | 676 |
677 // Otherwise if it succeeded both this time and last time, we need to look | 677 // Otherwise if it succeeded both this time and last time, we need to look |
678 // closer and see if we ended up downloading different content for the PAC | 678 // closer and see if we ended up downloading different content for the PAC |
679 // script. | 679 // script. |
680 return !script_data->Equals(last_script_data_); | 680 return !script_data->Equals(last_script_data_.get()); |
681 } | 681 } |
682 | 682 |
683 void NotifyProxyServiceOfChange( | 683 void NotifyProxyServiceOfChange( |
684 int result, | 684 int result, |
685 const scoped_refptr<ProxyResolverScriptData>& script_data, | 685 const scoped_refptr<ProxyResolverScriptData>& script_data, |
686 const ProxyConfig& effective_config) { | 686 const ProxyConfig& effective_config) { |
687 // Note that |this| may be deleted after calling into the ProxyService. | 687 // Note that |this| may be deleted after calling into the ProxyService. |
688 change_callback_.Run(result, script_data, effective_config); | 688 change_callback_.Run(result, script_data.get(), effective_config); |
689 } | 689 } |
690 | 690 |
691 base::WeakPtrFactory<ProxyScriptDeciderPoller> weak_factory_; | 691 base::WeakPtrFactory<ProxyScriptDeciderPoller> weak_factory_; |
692 | 692 |
693 ChangeCallback change_callback_; | 693 ChangeCallback change_callback_; |
694 ProxyConfig config_; | 694 ProxyConfig config_; |
695 bool proxy_resolver_expects_pac_bytes_; | 695 bool proxy_resolver_expects_pac_bytes_; |
696 ProxyScriptFetcher* proxy_script_fetcher_; | 696 ProxyScriptFetcher* proxy_script_fetcher_; |
697 DhcpProxyScriptFetcher* dhcp_proxy_script_fetcher_; | 697 DhcpProxyScriptFetcher* dhcp_proxy_script_fetcher_; |
698 | 698 |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
980 if (current_state_ == STATE_READY) { | 980 if (current_state_ == STATE_READY) { |
981 // Start the resolve request. | 981 // Start the resolve request. |
982 rv = req->Start(); | 982 rv = req->Start(); |
983 if (rv != ERR_IO_PENDING) | 983 if (rv != ERR_IO_PENDING) |
984 return req->QueryDidComplete(rv); | 984 return req->QueryDidComplete(rv); |
985 } else { | 985 } else { |
986 req->net_log()->BeginEvent(NetLog::TYPE_PROXY_SERVICE_WAITING_FOR_INIT_PAC); | 986 req->net_log()->BeginEvent(NetLog::TYPE_PROXY_SERVICE_WAITING_FOR_INIT_PAC); |
987 } | 987 } |
988 | 988 |
989 DCHECK_EQ(ERR_IO_PENDING, rv); | 989 DCHECK_EQ(ERR_IO_PENDING, rv); |
990 DCHECK(!ContainsPendingRequest(req)); | 990 DCHECK(!ContainsPendingRequest(req.get())); |
991 pending_requests_.push_back(req); | 991 pending_requests_.push_back(req); |
992 | 992 |
993 // Completion will be notified through |callback|, unless the caller cancels | 993 // Completion will be notified through |callback|, unless the caller cancels |
994 // the request using |pac_request|. | 994 // the request using |pac_request|. |
995 if (pac_request) | 995 if (pac_request) |
996 *pac_request = req.get(); | 996 *pac_request = req.get(); |
997 return rv; // ERR_IO_PENDING | 997 return rv; // ERR_IO_PENDING |
998 } | 998 } |
999 | 999 |
1000 int ProxyService::TryToCompleteSynchronously(const GURL& url, | 1000 int ProxyService::TryToCompleteSynchronously(const GURL& url, |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1350 base::ThreadTaskRunnerHandle::Get(); | 1350 base::ThreadTaskRunnerHandle::Get(); |
1351 | 1351 |
1352 // The file loop should be a MessageLoopForIO on Linux. | 1352 // The file loop should be a MessageLoopForIO on Linux. |
1353 DCHECK_EQ(MessageLoop::TYPE_IO, file_loop->type()); | 1353 DCHECK_EQ(MessageLoop::TYPE_IO, file_loop->type()); |
1354 | 1354 |
1355 // Synchronously fetch the current proxy config (since we are | 1355 // Synchronously fetch the current proxy config (since we are |
1356 // running on glib_default_loop). Additionally register for | 1356 // running on glib_default_loop). Additionally register for |
1357 // notifications (delivered in either |glib_default_loop| or | 1357 // notifications (delivered in either |glib_default_loop| or |
1358 // |file_loop|) to keep us updated when the proxy config changes. | 1358 // |file_loop|) to keep us updated when the proxy config changes. |
1359 linux_config_service->SetupAndFetchInitialConfig( | 1359 linux_config_service->SetupAndFetchInitialConfig( |
1360 glib_thread_task_runner, io_thread_task_runner, | 1360 glib_thread_task_runner.get(), io_thread_task_runner, |
1361 static_cast<MessageLoopForIO*>(file_loop)); | 1361 static_cast<MessageLoopForIO*>(file_loop)); |
1362 | 1362 |
1363 return linux_config_service; | 1363 return linux_config_service; |
1364 #elif defined(OS_ANDROID) | 1364 #elif defined(OS_ANDROID) |
1365 return new ProxyConfigServiceAndroid( | 1365 return new ProxyConfigServiceAndroid( |
1366 io_thread_task_runner, | 1366 io_thread_task_runner, |
1367 MessageLoop::current()->message_loop_proxy()); | 1367 MessageLoop::current()->message_loop_proxy()); |
1368 #else | 1368 #else |
1369 LOG(WARNING) << "Failed to choose a system proxy settings fetcher " | 1369 LOG(WARNING) << "Failed to choose a system proxy settings fetcher " |
1370 "for this platform."; | 1370 "for this platform."; |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1558 OnCompletion(result_); | 1558 OnCompletion(result_); |
1559 } | 1559 } |
1560 } | 1560 } |
1561 | 1561 |
1562 void SyncProxyServiceHelper::OnCompletion(int rv) { | 1562 void SyncProxyServiceHelper::OnCompletion(int rv) { |
1563 result_ = rv; | 1563 result_ = rv; |
1564 event_.Signal(); | 1564 event_.Signal(); |
1565 } | 1565 } |
1566 | 1566 |
1567 } // namespace net | 1567 } // namespace net |
OLD | NEW |