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

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

Issue 1052002: Move over another legacy "LoadLog-style" event generator to routing its messa... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Address willchan's comments Created 10 years, 9 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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 GURL url_; 192 GURL url_;
193 ProxyResolver::RequestHandle resolve_job_; 193 ProxyResolver::RequestHandle resolve_job_;
194 ProxyConfig::ID config_id_; // The config id when the resolve was started. 194 ProxyConfig::ID config_id_; // The config id when the resolve was started.
195 BoundNetLog net_log_; 195 BoundNetLog net_log_;
196 }; 196 };
197 197
198 // ProxyService --------------------------------------------------------------- 198 // ProxyService ---------------------------------------------------------------
199 199
200 ProxyService::ProxyService(ProxyConfigService* config_service, 200 ProxyService::ProxyService(ProxyConfigService* config_service,
201 ProxyResolver* resolver, 201 ProxyResolver* resolver,
202 NetworkChangeNotifier* network_change_notifier) 202 NetworkChangeNotifier* network_change_notifier,
203 const BoundNetLog& init_proxy_resolver_log)
203 : config_service_(config_service), 204 : config_service_(config_service),
204 resolver_(resolver), 205 resolver_(resolver),
205 next_config_id_(1), 206 next_config_id_(1),
206 should_use_proxy_resolver_(false), 207 should_use_proxy_resolver_(false),
207 ALLOW_THIS_IN_INITIALIZER_LIST(init_proxy_resolver_callback_( 208 ALLOW_THIS_IN_INITIALIZER_LIST(init_proxy_resolver_callback_(
208 this, &ProxyService::OnInitProxyResolverComplete)), 209 this, &ProxyService::OnInitProxyResolverComplete)),
209 init_proxy_resolver_log_(kMaxNumNetLogEntries), 210 init_proxy_resolver_log_(init_proxy_resolver_log),
210 network_change_notifier_(network_change_notifier) { 211 network_change_notifier_(network_change_notifier) {
211 // Register to receive network change notifications. 212 // Register to receive network change notifications.
212 if (network_change_notifier_) 213 if (network_change_notifier_)
213 network_change_notifier_->AddObserver(this); 214 network_change_notifier_->AddObserver(this);
214 } 215 }
215 216
216 // static 217 // static
217 ProxyService* ProxyService::Create( 218 ProxyService* ProxyService::Create(
218 ProxyConfigService* proxy_config_service, 219 ProxyConfigService* proxy_config_service,
219 bool use_v8_resolver, 220 bool use_v8_resolver,
220 URLRequestContext* url_request_context, 221 URLRequestContext* url_request_context,
221 NetworkChangeNotifier* network_change_notifier, 222 NetworkChangeNotifier* network_change_notifier,
223 NetLog* net_log,
222 MessageLoop* io_loop) { 224 MessageLoop* io_loop) {
223 ProxyResolver* proxy_resolver; 225 ProxyResolver* proxy_resolver;
224 226
225 if (use_v8_resolver) { 227 if (use_v8_resolver) {
226 // Send javascript errors and alerts to LOG(INFO). 228 // Send javascript errors and alerts to LOG(INFO).
227 HostResolver* host_resolver = url_request_context->host_resolver(); 229 HostResolver* host_resolver = url_request_context->host_resolver();
228 ProxyResolverJSBindings* js_bindings = 230 ProxyResolverJSBindings* js_bindings =
229 ProxyResolverJSBindings::CreateDefault(host_resolver, io_loop); 231 ProxyResolverJSBindings::CreateDefault(host_resolver, io_loop);
230 232
231 proxy_resolver = new ProxyResolverV8(js_bindings); 233 proxy_resolver = new ProxyResolverV8(js_bindings);
232 } else { 234 } else {
233 proxy_resolver = CreateNonV8ProxyResolver(); 235 proxy_resolver = CreateNonV8ProxyResolver();
234 } 236 }
235 237
236 // Wrap the (synchronous) ProxyResolver implementation in a single-threaded 238 // Wrap the (synchronous) ProxyResolver implementation in a single-threaded
237 // runner. This will dispatch requests to a threadpool of size 1. 239 // runner. This will dispatch requests to a threadpool of size 1.
238 proxy_resolver = new SingleThreadedProxyResolver(proxy_resolver); 240 proxy_resolver = new SingleThreadedProxyResolver(proxy_resolver);
239 241
240 ProxyService* proxy_service = new ProxyService( 242 ProxyService* proxy_service = new ProxyService(
241 proxy_config_service, proxy_resolver, network_change_notifier); 243 proxy_config_service, proxy_resolver, network_change_notifier,
244 BoundNetLog::Make(net_log, NetLog::SOURCE_INIT_PROXY_RESOLVER));
242 245
243 if (proxy_resolver->expects_pac_bytes()) { 246 if (proxy_resolver->expects_pac_bytes()) {
244 // Configure PAC script downloads to be issued using |url_request_context|. 247 // Configure PAC script downloads to be issued using |url_request_context|.
245 DCHECK(url_request_context); 248 DCHECK(url_request_context);
246 proxy_service->SetProxyScriptFetcher( 249 proxy_service->SetProxyScriptFetcher(
247 ProxyScriptFetcher::Create(url_request_context)); 250 ProxyScriptFetcher::Create(url_request_context));
248 } 251 }
249 252
250 return proxy_service; 253 return proxy_service;
251 } 254 }
252 255
253 // static 256 // static
254 ProxyService* ProxyService::CreateFixed(const ProxyConfig& pc) { 257 ProxyService* ProxyService::CreateFixed(const ProxyConfig& pc) {
255 return Create(new ProxyConfigServiceFixed(pc), false, NULL, NULL, NULL); 258 return Create(new ProxyConfigServiceFixed(pc), false, NULL, NULL,
259 NULL, NULL);
256 } 260 }
257 261
258 // static 262 // static
259 ProxyService* ProxyService::CreateNull() { 263 ProxyService* ProxyService::CreateNull() {
260 // Use a configuration fetcher and proxy resolver which always fail. 264 // Use a configuration fetcher and proxy resolver which always fail.
261 return new ProxyService(new ProxyConfigServiceNull, 265 return new ProxyService(new ProxyConfigServiceNull,
262 new ProxyResolverNull, 266 new ProxyResolverNull,
263 NULL); 267 NULL,
268 BoundNetLog());
264 } 269 }
265 270
266 int ProxyService::ResolveProxy(const GURL& raw_url, 271 int ProxyService::ResolveProxy(const GURL& raw_url,
267 ProxyInfo* result, 272 ProxyInfo* result,
268 CompletionCallback* callback, 273 CompletionCallback* callback,
269 PacRequest** pac_request, 274 PacRequest** pac_request,
270 const BoundNetLog& net_log) { 275 const BoundNetLog& net_log) {
271 DCHECK(callback); 276 DCHECK(callback);
272 277
273 net_log.BeginEvent(NetLog::TYPE_PROXY_SERVICE); 278 net_log.BeginEvent(NetLog::TYPE_PROXY_SERVICE);
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 StartInitProxyResolver(); 634 StartInitProxyResolver();
630 } 635 }
631 } 636 }
632 637
633 void ProxyService::StartInitProxyResolver() { 638 void ProxyService::StartInitProxyResolver() {
634 DCHECK(!init_proxy_resolver_.get()); 639 DCHECK(!init_proxy_resolver_.get());
635 640
636 init_proxy_resolver_.reset( 641 init_proxy_resolver_.reset(
637 new InitProxyResolver(resolver_.get(), proxy_script_fetcher_.get())); 642 new InitProxyResolver(resolver_.get(), proxy_script_fetcher_.get()));
638 643
639 init_proxy_resolver_log_.Clear();
640
641 int rv = init_proxy_resolver_->Init( 644 int rv = init_proxy_resolver_->Init(
642 config_, &init_proxy_resolver_callback_, 645 config_, &init_proxy_resolver_callback_,
643 init_proxy_resolver_log_.bound()); 646 init_proxy_resolver_log_);
644 647
645 if (rv != ERR_IO_PENDING) 648 if (rv != ERR_IO_PENDING)
646 OnInitProxyResolverComplete(rv); 649 OnInitProxyResolverComplete(rv);
647 } 650 }
648 651
649 void ProxyService::UpdateConfigIfOld(const BoundNetLog& net_log) { 652 void ProxyService::UpdateConfigIfOld(const BoundNetLog& net_log) {
650 // The overhead of calling ProxyConfigService::GetProxyConfig is very low. 653 // The overhead of calling ProxyConfigService::GetProxyConfig is very low.
651 const TimeDelta kProxyConfigMaxAge = TimeDelta::FromSeconds(5); 654 const TimeDelta kProxyConfigMaxAge = TimeDelta::FromSeconds(5);
652 655
653 // Periodically check for a new config. 656 // Periodically check for a new config.
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 OnCompletion(result_); 729 OnCompletion(result_);
727 } 730 }
728 } 731 }
729 732
730 void SyncProxyServiceHelper::OnCompletion(int rv) { 733 void SyncProxyServiceHelper::OnCompletion(int rv) {
731 result_ = rv; 734 result_ = rv;
732 event_.Signal(); 735 event_.Signal();
733 } 736 }
734 737
735 } // namespace net 738 } // 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