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

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

Issue 7019015: Revert 85646 - Adds support for the DHCP portion of the WPAD (proxy auto-discovery) protocol. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 7 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
« no previous file with comments | « net/proxy/proxy_service.h ('k') | net/proxy/proxy_service_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/message_loop.h" 11 #include "base/message_loop.h"
12 #include "base/message_loop_proxy.h" 12 #include "base/message_loop_proxy.h"
13 #include "base/string_util.h" 13 #include "base/string_util.h"
14 #include "base/values.h" 14 #include "base/values.h"
15 #include "googleurl/src/gurl.h" 15 #include "googleurl/src/gurl.h"
16 #include "net/base/net_errors.h" 16 #include "net/base/net_errors.h"
17 #include "net/base/net_log.h" 17 #include "net/base/net_log.h"
18 #include "net/base/net_util.h" 18 #include "net/base/net_util.h"
19 #include "net/proxy/dhcp_proxy_script_fetcher.h"
20 #include "net/proxy/init_proxy_resolver.h" 19 #include "net/proxy/init_proxy_resolver.h"
21 #include "net/proxy/multi_threaded_proxy_resolver.h" 20 #include "net/proxy/multi_threaded_proxy_resolver.h"
22 #include "net/proxy/network_delegate_error_observer.h" 21 #include "net/proxy/network_delegate_error_observer.h"
23 #include "net/proxy/proxy_config_service_fixed.h" 22 #include "net/proxy/proxy_config_service_fixed.h"
24 #include "net/proxy/proxy_resolver.h" 23 #include "net/proxy/proxy_resolver.h"
25 #include "net/proxy/proxy_resolver_js_bindings.h" 24 #include "net/proxy/proxy_resolver_js_bindings.h"
26 #include "net/proxy/proxy_resolver_v8.h" 25 #include "net/proxy/proxy_resolver_v8.h"
27 #include "net/proxy/proxy_script_fetcher.h" 26 #include "net/proxy/proxy_script_fetcher.h"
28 #include "net/proxy/sync_host_resolver_bridge.h" 27 #include "net/proxy/sync_host_resolver_bridge.h"
29 #include "net/url_request/url_request_context.h" 28 #include "net/url_request/url_request_context.h"
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 kNumMillisToStallAfterNetworkChanges)) { 402 kNumMillisToStallAfterNetworkChanges)) {
404 NetworkChangeNotifier::AddIPAddressObserver(this); 403 NetworkChangeNotifier::AddIPAddressObserver(this);
405 ResetConfigService(config_service); 404 ResetConfigService(config_service);
406 } 405 }
407 406
408 // static 407 // static
409 ProxyService* ProxyService::CreateUsingV8ProxyResolver( 408 ProxyService* ProxyService::CreateUsingV8ProxyResolver(
410 ProxyConfigService* proxy_config_service, 409 ProxyConfigService* proxy_config_service,
411 size_t num_pac_threads, 410 size_t num_pac_threads,
412 ProxyScriptFetcher* proxy_script_fetcher, 411 ProxyScriptFetcher* proxy_script_fetcher,
413 DhcpProxyScriptFetcher* dhcp_proxy_script_fetcher,
414 HostResolver* host_resolver, 412 HostResolver* host_resolver,
415 NetLog* net_log, 413 NetLog* net_log,
416 NetworkDelegate* network_delegate) { 414 NetworkDelegate* network_delegate) {
417 DCHECK(proxy_config_service); 415 DCHECK(proxy_config_service);
418 DCHECK(proxy_script_fetcher); 416 DCHECK(proxy_script_fetcher);
419 DCHECK(dhcp_proxy_script_fetcher);
420 DCHECK(host_resolver); 417 DCHECK(host_resolver);
421 418
422 if (num_pac_threads == 0) 419 if (num_pac_threads == 0)
423 num_pac_threads = kDefaultNumPacThreads; 420 num_pac_threads = kDefaultNumPacThreads;
424 421
425 ProxyResolverFactory* sync_resolver_factory = 422 ProxyResolverFactory* sync_resolver_factory =
426 new ProxyResolverFactoryForV8( 423 new ProxyResolverFactoryForV8(
427 host_resolver, 424 host_resolver,
428 MessageLoop::current(), 425 MessageLoop::current(),
429 base::MessageLoopProxy::CreateForCurrentThread(), 426 base::MessageLoopProxy::CreateForCurrentThread(),
430 net_log, 427 net_log,
431 network_delegate); 428 network_delegate);
432 429
433 ProxyResolver* proxy_resolver = 430 ProxyResolver* proxy_resolver =
434 new MultiThreadedProxyResolver(sync_resolver_factory, num_pac_threads); 431 new MultiThreadedProxyResolver(sync_resolver_factory, num_pac_threads);
435 432
436 ProxyService* proxy_service = 433 ProxyService* proxy_service =
437 new ProxyService(proxy_config_service, proxy_resolver, net_log); 434 new ProxyService(proxy_config_service, proxy_resolver, net_log);
438 435
439 // Configure fetchers to use for PAC script downloads and auto-detect. 436 // Configure PAC script downloads to be issued using |proxy_script_fetcher|.
440 proxy_service->SetProxyScriptFetchers(proxy_script_fetcher, 437 proxy_service->SetProxyScriptFetcher(proxy_script_fetcher);
441 dhcp_proxy_script_fetcher);
442 438
443 return proxy_service; 439 return proxy_service;
444 } 440 }
445 441
446 // static 442 // static
447 ProxyService* ProxyService::CreateUsingSystemProxyResolver( 443 ProxyService* ProxyService::CreateUsingSystemProxyResolver(
448 ProxyConfigService* proxy_config_service, 444 ProxyConfigService* proxy_config_service,
449 size_t num_pac_threads, 445 size_t num_pac_threads,
450 NetLog* net_log) { 446 NetLog* net_log) {
451 DCHECK(proxy_config_service); 447 DCHECK(proxy_config_service);
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 result_code = OK; 767 result_code = OK;
772 } else { 768 } else {
773 result_code = ERR_MANDATORY_PROXY_CONFIGURATION_FAILED; 769 result_code = ERR_MANDATORY_PROXY_CONFIGURATION_FAILED;
774 } 770 }
775 } 771 }
776 772
777 net_log.EndEvent(NetLog::TYPE_PROXY_SERVICE, NULL); 773 net_log.EndEvent(NetLog::TYPE_PROXY_SERVICE, NULL);
778 return result_code; 774 return result_code;
779 } 775 }
780 776
781 void ProxyService::SetProxyScriptFetchers( 777 void ProxyService::SetProxyScriptFetcher(
782 ProxyScriptFetcher* proxy_script_fetcher, 778 ProxyScriptFetcher* proxy_script_fetcher) {
783 DhcpProxyScriptFetcher* dhcp_proxy_script_fetcher) {
784 DCHECK(CalledOnValidThread()); 779 DCHECK(CalledOnValidThread());
785 State previous_state = ResetProxyConfig(false); 780 State previous_state = ResetProxyConfig(false);
786 proxy_script_fetcher_.reset(proxy_script_fetcher); 781 proxy_script_fetcher_.reset(proxy_script_fetcher);
787 dhcp_proxy_script_fetcher_.reset(dhcp_proxy_script_fetcher);
788 if (previous_state != STATE_NONE) 782 if (previous_state != STATE_NONE)
789 ApplyProxyConfigIfAvailable(); 783 ApplyProxyConfigIfAvailable();
790 } 784 }
791 785
792 ProxyScriptFetcher* ProxyService::GetProxyScriptFetcher() const { 786 ProxyScriptFetcher* ProxyService::GetProxyScriptFetcher() const {
793 DCHECK(CalledOnValidThread()); 787 DCHECK(CalledOnValidThread());
794 return proxy_script_fetcher_.get(); 788 return proxy_script_fetcher_.get();
795 } 789 }
796 790
797 ProxyService::State ProxyService::ResetProxyConfig(bool reset_fetched_config) { 791 ProxyService::State ProxyService::ResetProxyConfig(bool reset_fetched_config) {
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
926 if (!fetched_config_.HasAutomaticSettings()) { 920 if (!fetched_config_.HasAutomaticSettings()) {
927 config_ = fetched_config_; 921 config_ = fetched_config_;
928 SetReady(); 922 SetReady();
929 return; 923 return;
930 } 924 }
931 925
932 // Start downloading + testing the PAC scripts for this new configuration. 926 // Start downloading + testing the PAC scripts for this new configuration.
933 current_state_ = STATE_WAITING_FOR_INIT_PROXY_RESOLVER; 927 current_state_ = STATE_WAITING_FOR_INIT_PROXY_RESOLVER;
934 928
935 init_proxy_resolver_.reset( 929 init_proxy_resolver_.reset(
936 new InitProxyResolver(resolver_.get(), 930 new InitProxyResolver(resolver_.get(), proxy_script_fetcher_.get(),
937 proxy_script_fetcher_.get(),
938 dhcp_proxy_script_fetcher_.get(),
939 net_log_)); 931 net_log_));
940 932
941 // If we changed networks recently, we should delay running proxy auto-config. 933 // If we changed networks recently, we should delay running proxy auto-config.
942 base::TimeDelta wait_delay = 934 base::TimeDelta wait_delay =
943 stall_proxy_autoconfig_until_ - base::TimeTicks::Now(); 935 stall_proxy_autoconfig_until_ - base::TimeTicks::Now();
944 936
945 int rv = init_proxy_resolver_->Init( 937 int rv = init_proxy_resolver_->Init(
946 fetched_config_, wait_delay, &config_, &init_proxy_resolver_callback_); 938 fetched_config_, wait_delay, &config_, &init_proxy_resolver_callback_);
947 939
948 if (rv != ERR_IO_PENDING) 940 if (rv != ERR_IO_PENDING)
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1019 OnCompletion(result_); 1011 OnCompletion(result_);
1020 } 1012 }
1021 } 1013 }
1022 1014
1023 void SyncProxyServiceHelper::OnCompletion(int rv) { 1015 void SyncProxyServiceHelper::OnCompletion(int rv) {
1024 result_ = rv; 1016 result_ = rv;
1025 event_.Signal(); 1017 event_.Signal();
1026 } 1018 }
1027 1019
1028 } // namespace net 1020 } // namespace net
OLDNEW
« no previous file with comments | « net/proxy/proxy_service.h ('k') | net/proxy/proxy_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698