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

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

Issue 1783008: Cleanup: Remove the implicit constructor for BoundNetLog that allowed passing... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Sync Created 10 years, 8 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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"
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 ProxyResolver::RequestHandle resolve_job_; 194 ProxyResolver::RequestHandle resolve_job_;
195 ProxyConfig::ID config_id_; // The config id when the resolve was started. 195 ProxyConfig::ID config_id_; // The config id when the resolve was started.
196 BoundNetLog net_log_; 196 BoundNetLog net_log_;
197 }; 197 };
198 198
199 // ProxyService --------------------------------------------------------------- 199 // ProxyService ---------------------------------------------------------------
200 200
201 ProxyService::ProxyService(ProxyConfigService* config_service, 201 ProxyService::ProxyService(ProxyConfigService* config_service,
202 ProxyResolver* resolver, 202 ProxyResolver* resolver,
203 NetworkChangeNotifier* network_change_notifier, 203 NetworkChangeNotifier* network_change_notifier,
204 const BoundNetLog& init_proxy_resolver_log) 204 NetLog* net_log)
205 : config_service_(config_service), 205 : config_service_(config_service),
206 resolver_(resolver), 206 resolver_(resolver),
207 next_config_id_(1), 207 next_config_id_(1),
208 should_use_proxy_resolver_(false), 208 should_use_proxy_resolver_(false),
209 ALLOW_THIS_IN_INITIALIZER_LIST(init_proxy_resolver_callback_( 209 ALLOW_THIS_IN_INITIALIZER_LIST(init_proxy_resolver_callback_(
210 this, &ProxyService::OnInitProxyResolverComplete)), 210 this, &ProxyService::OnInitProxyResolverComplete)),
211 init_proxy_resolver_log_(init_proxy_resolver_log), 211 net_log_(net_log),
212 network_change_notifier_(network_change_notifier) { 212 network_change_notifier_(network_change_notifier) {
213 // Register to receive network change notifications. 213 // Register to receive network change notifications.
214 if (network_change_notifier_) 214 if (network_change_notifier_)
215 network_change_notifier_->AddObserver(this); 215 network_change_notifier_->AddObserver(this);
216 } 216 }
217 217
218 // static 218 // static
219 ProxyService* ProxyService::Create( 219 ProxyService* ProxyService::Create(
220 ProxyConfigService* proxy_config_service, 220 ProxyConfigService* proxy_config_service,
221 bool use_v8_resolver, 221 bool use_v8_resolver,
(...skipping 22 matching lines...) Expand all
244 new SingleThreadedProxyResolverUsingBridgedHostResolver( 244 new SingleThreadedProxyResolverUsingBridgedHostResolver(
245 new ProxyResolverV8(js_bindings), 245 new ProxyResolverV8(js_bindings),
246 sync_host_resolver); 246 sync_host_resolver);
247 } else { 247 } else {
248 proxy_resolver = 248 proxy_resolver =
249 new SingleThreadedProxyResolver(CreateNonV8ProxyResolver()); 249 new SingleThreadedProxyResolver(CreateNonV8ProxyResolver());
250 } 250 }
251 251
252 ProxyService* proxy_service = new ProxyService( 252 ProxyService* proxy_service = new ProxyService(
253 proxy_config_service, proxy_resolver, network_change_notifier, 253 proxy_config_service, proxy_resolver, network_change_notifier,
254 BoundNetLog::Make(net_log, NetLog::SOURCE_INIT_PROXY_RESOLVER)); 254 net_log);
255 255
256 if (proxy_resolver->expects_pac_bytes()) { 256 if (proxy_resolver->expects_pac_bytes()) {
257 // Configure PAC script downloads to be issued using |url_request_context|. 257 // Configure PAC script downloads to be issued using |url_request_context|.
258 DCHECK(url_request_context); 258 DCHECK(url_request_context);
259 proxy_service->SetProxyScriptFetcher( 259 proxy_service->SetProxyScriptFetcher(
260 ProxyScriptFetcher::Create(url_request_context)); 260 ProxyScriptFetcher::Create(url_request_context));
261 } 261 }
262 262
263 return proxy_service; 263 return proxy_service;
264 } 264 }
265 265
266 // static 266 // static
267 ProxyService* ProxyService::CreateFixed(const ProxyConfig& pc) { 267 ProxyService* ProxyService::CreateFixed(const ProxyConfig& pc) {
268 return Create(new ProxyConfigServiceFixed(pc), false, NULL, NULL, 268 return Create(new ProxyConfigServiceFixed(pc), false, NULL, NULL,
269 NULL, NULL); 269 NULL, NULL);
270 } 270 }
271 271
272 // static 272 // static
273 ProxyService* ProxyService::CreateNull() { 273 ProxyService* ProxyService::CreateNull() {
274 // Use a configuration fetcher and proxy resolver which always fail. 274 // Use a configuration fetcher and proxy resolver which always fail.
275 return new ProxyService(new ProxyConfigServiceNull, 275 return new ProxyService(new ProxyConfigServiceNull,
276 new ProxyResolverNull, 276 new ProxyResolverNull,
277 NULL, 277 NULL,
278 BoundNetLog()); 278 NULL);
279 } 279 }
280 280
281 int ProxyService::ResolveProxy(const GURL& raw_url, 281 int ProxyService::ResolveProxy(const GURL& raw_url,
282 ProxyInfo* result, 282 ProxyInfo* result,
283 CompletionCallback* callback, 283 CompletionCallback* callback,
284 PacRequest** pac_request, 284 PacRequest** pac_request,
285 const BoundNetLog& net_log) { 285 const BoundNetLog& net_log) {
286 DCHECK(callback); 286 DCHECK(callback);
287 287
288 net_log.BeginEvent(NetLog::TYPE_PROXY_SERVICE, NULL); 288 net_log.BeginEvent(NetLog::TYPE_PROXY_SERVICE, NULL);
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 } 513 }
514 } 514 }
515 515
516 ProxyScriptFetcher* ProxyService::GetProxyScriptFetcher() const { 516 ProxyScriptFetcher* ProxyService::GetProxyScriptFetcher() const {
517 return proxy_script_fetcher_.get(); 517 return proxy_script_fetcher_.get();
518 } 518 }
519 519
520 void ProxyService::ResetConfigService( 520 void ProxyService::ResetConfigService(
521 ProxyConfigService* new_proxy_config_service) { 521 ProxyConfigService* new_proxy_config_service) {
522 config_service_.reset(new_proxy_config_service); 522 config_service_.reset(new_proxy_config_service);
523 UpdateConfig(NULL); 523 UpdateConfig(BoundNetLog());
524 } 524 }
525 525
526 void ProxyService::PurgeMemory() { 526 void ProxyService::PurgeMemory() {
527 if (resolver_.get()) 527 if (resolver_.get())
528 resolver_->PurgeMemory(); 528 resolver_->PurgeMemory();
529 } 529 }
530 530
531 void ProxyService::ForceReloadProxyConfig() { 531 void ProxyService::ForceReloadProxyConfig() {
532 // Mark the current configuration as being un-initialized, then force it to 532 // Mark the current configuration as being un-initialized, then force it to
533 // start updating (normally this would happen lazily during the next 533 // start updating (normally this would happen lazily during the next
534 // call to ResolveProxy()). 534 // call to ResolveProxy()).
535 config_.set_id(ProxyConfig::INVALID_ID); 535 config_.set_id(ProxyConfig::INVALID_ID);
536 UpdateConfig(NULL); 536 UpdateConfig(BoundNetLog());
537 } 537 }
538 538
539 // static 539 // static
540 ProxyConfigService* ProxyService::CreateSystemProxyConfigService( 540 ProxyConfigService* ProxyService::CreateSystemProxyConfigService(
541 MessageLoop* io_loop, MessageLoop* file_loop) { 541 MessageLoop* io_loop, MessageLoop* file_loop) {
542 #if defined(OS_WIN) 542 #if defined(OS_WIN)
543 return new ProxyConfigServiceWin(); 543 return new ProxyConfigServiceWin();
544 #elif defined(OS_MACOSX) 544 #elif defined(OS_MACOSX)
545 return new ProxyConfigServiceMac(); 545 return new ProxyConfigServiceMac();
546 #elif defined(OS_LINUX) 546 #elif defined(OS_LINUX)
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 646
647 // Calls OnInitProxyResolverComplete() on completion. 647 // Calls OnInitProxyResolverComplete() on completion.
648 StartInitProxyResolver(); 648 StartInitProxyResolver();
649 } 649 }
650 } 650 }
651 651
652 void ProxyService::StartInitProxyResolver() { 652 void ProxyService::StartInitProxyResolver() {
653 DCHECK(!init_proxy_resolver_.get()); 653 DCHECK(!init_proxy_resolver_.get());
654 654
655 init_proxy_resolver_.reset( 655 init_proxy_resolver_.reset(
656 new InitProxyResolver(resolver_.get(), proxy_script_fetcher_.get())); 656 new InitProxyResolver(resolver_.get(), proxy_script_fetcher_.get(),
657 net_log_));
657 658
658 int rv = init_proxy_resolver_->Init( 659 int rv = init_proxy_resolver_->Init(
659 config_, &init_proxy_resolver_callback_, 660 config_, &init_proxy_resolver_callback_);
660 init_proxy_resolver_log_);
661 661
662 if (rv != ERR_IO_PENDING) 662 if (rv != ERR_IO_PENDING)
663 OnInitProxyResolverComplete(rv); 663 OnInitProxyResolverComplete(rv);
664 } 664 }
665 665
666 void ProxyService::UpdateConfigIfOld(const BoundNetLog& net_log) { 666 void ProxyService::UpdateConfigIfOld(const BoundNetLog& net_log) {
667 // The overhead of calling ProxyConfigService::GetProxyConfig is very low. 667 // The overhead of calling ProxyConfigService::GetProxyConfig is very low.
668 const TimeDelta kProxyConfigMaxAge = TimeDelta::FromSeconds(5); 668 const TimeDelta kProxyConfigMaxAge = TimeDelta::FromSeconds(5);
669 669
670 // Periodically check for a new config. 670 // Periodically check for a new config.
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 OnCompletion(result_); 743 OnCompletion(result_);
744 } 744 }
745 } 745 }
746 746
747 void SyncProxyServiceHelper::OnCompletion(int rv) { 747 void SyncProxyServiceHelper::OnCompletion(int rv) {
748 result_ = rv; 748 result_ = rv;
749 event_.Signal(); 749 event_.Signal();
750 } 750 }
751 751
752 } // namespace net 752 } // 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