diff options
author | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-16 21:41:10 +0000 |
---|---|---|
committer | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-16 21:41:10 +0000 |
commit | 4c2464b49571049ad7128343bfafa9abb3be7e0c (patch) | |
tree | 720f5a9c678057babcfed67f3b7f6f2bb972a35f /net | |
parent | 778b07162832ede8794dc72f859534d7ff6849a2 (diff) | |
download | chromium_src-4c2464b49571049ad7128343bfafa9abb3be7e0c.zip chromium_src-4c2464b49571049ad7128343bfafa9abb3be7e0c.tar.gz chromium_src-4c2464b49571049ad7128343bfafa9abb3be7e0c.tar.bz2 |
Move over another legacy "LoadLog-style" event generator to routing its messages through the NetLog.
BUG=37421
Review URL: http://codereview.chromium.org/1052002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41768 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/proxy/proxy_service.cc | 19 | ||||
-rw-r--r-- | net/proxy/proxy_service.h | 15 | ||||
-rw-r--r-- | net/proxy/proxy_service_unittest.cc | 77 |
3 files changed, 60 insertions, 51 deletions
diff --git a/net/proxy/proxy_service.cc b/net/proxy/proxy_service.cc index bc4a708..4e7a342 100644 --- a/net/proxy/proxy_service.cc +++ b/net/proxy/proxy_service.cc @@ -199,14 +199,15 @@ class ProxyService::PacRequest ProxyService::ProxyService(ProxyConfigService* config_service, ProxyResolver* resolver, - NetworkChangeNotifier* network_change_notifier) + NetworkChangeNotifier* network_change_notifier, + const BoundNetLog& init_proxy_resolver_log) : config_service_(config_service), resolver_(resolver), next_config_id_(1), should_use_proxy_resolver_(false), ALLOW_THIS_IN_INITIALIZER_LIST(init_proxy_resolver_callback_( this, &ProxyService::OnInitProxyResolverComplete)), - init_proxy_resolver_log_(kMaxNumNetLogEntries), + init_proxy_resolver_log_(init_proxy_resolver_log), network_change_notifier_(network_change_notifier) { // Register to receive network change notifications. if (network_change_notifier_) @@ -219,6 +220,7 @@ ProxyService* ProxyService::Create( bool use_v8_resolver, URLRequestContext* url_request_context, NetworkChangeNotifier* network_change_notifier, + NetLog* net_log, MessageLoop* io_loop) { ProxyResolver* proxy_resolver; @@ -238,7 +240,8 @@ ProxyService* ProxyService::Create( proxy_resolver = new SingleThreadedProxyResolver(proxy_resolver); ProxyService* proxy_service = new ProxyService( - proxy_config_service, proxy_resolver, network_change_notifier); + proxy_config_service, proxy_resolver, network_change_notifier, + BoundNetLog::Make(net_log, NetLog::SOURCE_INIT_PROXY_RESOLVER)); if (proxy_resolver->expects_pac_bytes()) { // Configure PAC script downloads to be issued using |url_request_context|. @@ -252,7 +255,8 @@ ProxyService* ProxyService::Create( // static ProxyService* ProxyService::CreateFixed(const ProxyConfig& pc) { - return Create(new ProxyConfigServiceFixed(pc), false, NULL, NULL, NULL); + return Create(new ProxyConfigServiceFixed(pc), false, NULL, NULL, + NULL, NULL); } // static @@ -260,7 +264,8 @@ ProxyService* ProxyService::CreateNull() { // Use a configuration fetcher and proxy resolver which always fail. return new ProxyService(new ProxyConfigServiceNull, new ProxyResolverNull, - NULL); + NULL, + BoundNetLog()); } int ProxyService::ResolveProxy(const GURL& raw_url, @@ -636,11 +641,9 @@ void ProxyService::StartInitProxyResolver() { init_proxy_resolver_.reset( new InitProxyResolver(resolver_.get(), proxy_script_fetcher_.get())); - init_proxy_resolver_log_.Clear(); - int rv = init_proxy_resolver_->Init( config_, &init_proxy_resolver_callback_, - init_proxy_resolver_log_.bound()); + init_proxy_resolver_log_); if (rv != ERR_IO_PENDING) OnInitProxyResolverComplete(rv); diff --git a/net/proxy/proxy_service.h b/net/proxy/proxy_service.h index 2cf3f95..bf176c8 100644 --- a/net/proxy/proxy_service.h +++ b/net/proxy/proxy_service.h @@ -40,7 +40,8 @@ class ProxyService : public base::RefCountedThreadSafe<ProxyService>, // with it to detect when the network setup has changed. This is used to // decide when to re-configure the proxy discovery. ProxyService(ProxyConfigService* config_service, ProxyResolver* resolver, - NetworkChangeNotifier* network_change_notifier); + NetworkChangeNotifier* network_change_notifier, + const BoundNetLog& init_proxy_resolver_log); // Used internally to handle PAC queries. // TODO(eroman): consider naming this simply "Request". @@ -108,13 +109,6 @@ class ProxyService : public base::RefCountedThreadSafe<ProxyService>, // Tells the resolver to purge any memory it does not need. void PurgeMemory(); - // Returns the log for the most recent WPAD + PAC initialization. - // (This shows how much time was spent downloading and parsing the - // PAC scripts for the current configuration). - const CapturingBoundNetLog& init_proxy_resolver_log() const { - return init_proxy_resolver_log_; - } - // Returns true if we have called UpdateConfig() at least once. bool config_has_been_initialized() const { return config_.id() != ProxyConfig::INVALID_ID; @@ -161,6 +155,7 @@ class ProxyService : public base::RefCountedThreadSafe<ProxyService>, bool use_v8_resolver, URLRequestContext* url_request_context, NetworkChangeNotifier* network_change_notifier, + NetLog* net_log, MessageLoop* io_loop); // Convenience method that creates a proxy service using the @@ -286,8 +281,8 @@ class ProxyService : public base::RefCountedThreadSafe<ProxyService>, // |proxy_resolver_| must outlive |init_proxy_resolver_|. scoped_ptr<InitProxyResolver> init_proxy_resolver_; - // Log from the *last* time |init_proxy_resolver_.Init()| was called, or NULL. - CapturingBoundNetLog init_proxy_resolver_log_; + // Log for events generated by |init_proxy_resolver_|. + BoundNetLog init_proxy_resolver_log_; // The (possibly NULL) network change notifier that we use to decide when // to refetch PAC scripts or re-run WPAD. diff --git a/net/proxy/proxy_service_unittest.cc b/net/proxy/proxy_service_unittest.cc index d4a6326..d608a44 100644 --- a/net/proxy/proxy_service_unittest.cc +++ b/net/proxy/proxy_service_unittest.cc @@ -92,7 +92,8 @@ class MockProxyScriptFetcher : public ProxyScriptFetcher { TEST(ProxyServiceTest, Direct) { MockAsyncProxyResolver* resolver = new MockAsyncProxyResolver; scoped_refptr<ProxyService> service( - new ProxyService(new MockProxyConfigService, resolver, NULL)); + new ProxyService(new MockProxyConfigService, resolver, NULL, + BoundNetLog())); GURL url("http://www.google.com/"); @@ -120,7 +121,7 @@ TEST(ProxyServiceTest, PAC) { MockAsyncProxyResolver* resolver = new MockAsyncProxyResolver; scoped_refptr<ProxyService> service( - new ProxyService(config_service, resolver, NULL)); + new ProxyService(config_service, resolver, NULL, BoundNetLog())); GURL url("http://www.google.com/"); @@ -167,7 +168,7 @@ TEST(ProxyServiceTest, PAC_NoIdentityOrHash) { MockAsyncProxyResolver* resolver = new MockAsyncProxyResolver; scoped_refptr<ProxyService> service( - new ProxyService(config_service, resolver, NULL)); + new ProxyService(config_service, resolver, NULL, BoundNetLog())); GURL url("http://username:password@www.google.com/?ref#hash#hash"); @@ -195,7 +196,7 @@ TEST(ProxyServiceTest, PAC_FailoverWithoutDirect) { MockAsyncProxyResolver* resolver = new MockAsyncProxyResolver; scoped_refptr<ProxyService> service( - new ProxyService(config_service, resolver, NULL)); + new ProxyService(config_service, resolver, NULL, BoundNetLog())); GURL url("http://www.google.com/"); @@ -252,7 +253,7 @@ TEST(ProxyServiceTest, PAC_FailoverAfterDirect) { MockAsyncProxyResolver* resolver = new MockAsyncProxyResolver; scoped_refptr<ProxyService> service( - new ProxyService(config_service, resolver, NULL)); + new ProxyService(config_service, resolver, NULL, BoundNetLog())); GURL url("http://www.google.com/"); @@ -314,7 +315,7 @@ TEST(ProxyServiceTest, ProxyResolverFails) { MockAsyncProxyResolver* resolver = new MockAsyncProxyResolver; scoped_refptr<ProxyService> service( - new ProxyService(config_service, resolver, NULL)); + new ProxyService(config_service, resolver, NULL, BoundNetLog())); // Start first resolve request. GURL url("http://www.google.com/"); @@ -367,7 +368,7 @@ TEST(ProxyServiceTest, ProxyFallback) { MockAsyncProxyResolver* resolver = new MockAsyncProxyResolver; scoped_refptr<ProxyService> service( - new ProxyService(config_service, resolver, NULL)); + new ProxyService(config_service, resolver, NULL, BoundNetLog())); GURL url("http://www.google.com/"); @@ -453,7 +454,7 @@ TEST(ProxyServiceTest, ProxyFallbackToDirect) { MockAsyncProxyResolver* resolver = new MockAsyncProxyResolver; scoped_refptr<ProxyService> service( - new ProxyService(config_service, resolver, NULL)); + new ProxyService(config_service, resolver, NULL, BoundNetLog())); GURL url("http://www.google.com/"); @@ -513,7 +514,7 @@ TEST(ProxyServiceTest, ProxyFallback_NewSettings) { MockAsyncProxyResolver* resolver = new MockAsyncProxyResolver; scoped_refptr<ProxyService> service( - new ProxyService(config_service, resolver, NULL)); + new ProxyService(config_service, resolver, NULL, BoundNetLog())); GURL url("http://www.google.com/"); @@ -602,7 +603,7 @@ TEST(ProxyServiceTest, ProxyFallback_BadConfig) { MockAsyncProxyResolver* resolver = new MockAsyncProxyResolver; scoped_refptr<ProxyService> service( - new ProxyService(config_service, resolver, NULL)); + new ProxyService(config_service, resolver, NULL, BoundNetLog())); GURL url("http://www.google.com/"); @@ -687,7 +688,8 @@ TEST(ProxyServiceTest, ProxyBypassList) { config.proxy_rules().bypass_rules.ParseFromString("*.org"); scoped_refptr<ProxyService> service(new ProxyService( - new MockProxyConfigService(config), new MockAsyncProxyResolver, NULL)); + new MockProxyConfigService(config), new MockAsyncProxyResolver, NULL, + BoundNetLog())); int rv; GURL url1("http://www.webkit.org"); @@ -711,7 +713,8 @@ TEST(ProxyServiceTest, PerProtocolProxyTests) { config.set_auto_detect(false); { scoped_refptr<ProxyService> service(new ProxyService( - new MockProxyConfigService(config), new MockAsyncProxyResolver, NULL)); + new MockProxyConfigService(config), new MockAsyncProxyResolver, NULL, + BoundNetLog())); GURL test_url("http://www.msn.com"); ProxyInfo info; TestCompletionCallback callback; @@ -722,7 +725,8 @@ TEST(ProxyServiceTest, PerProtocolProxyTests) { } { scoped_refptr<ProxyService> service(new ProxyService( - new MockProxyConfigService(config), new MockAsyncProxyResolver, NULL)); + new MockProxyConfigService(config), new MockAsyncProxyResolver, NULL, + BoundNetLog())); GURL test_url("ftp://ftp.google.com"); ProxyInfo info; TestCompletionCallback callback; @@ -733,7 +737,8 @@ TEST(ProxyServiceTest, PerProtocolProxyTests) { } { scoped_refptr<ProxyService> service(new ProxyService( - new MockProxyConfigService(config), new MockAsyncProxyResolver, NULL)); + new MockProxyConfigService(config), new MockAsyncProxyResolver, NULL, + BoundNetLog())); GURL test_url("https://webbranch.techcu.com"); ProxyInfo info; TestCompletionCallback callback; @@ -745,7 +750,8 @@ TEST(ProxyServiceTest, PerProtocolProxyTests) { { config.proxy_rules().ParseFromString("foopy1:8080"); scoped_refptr<ProxyService> service(new ProxyService( - new MockProxyConfigService(config), new MockAsyncProxyResolver, NULL)); + new MockProxyConfigService(config), new MockAsyncProxyResolver, NULL, + BoundNetLog())); GURL test_url("http://www.microsoft.com"); ProxyInfo info; TestCompletionCallback callback; @@ -767,7 +773,8 @@ TEST(ProxyServiceTest, DefaultProxyFallbackToSOCKS) { { scoped_refptr<ProxyService> service(new ProxyService( - new MockProxyConfigService(config), new MockAsyncProxyResolver, NULL)); + new MockProxyConfigService(config), new MockAsyncProxyResolver, NULL, + BoundNetLog())); GURL test_url("http://www.msn.com"); ProxyInfo info; TestCompletionCallback callback; @@ -778,7 +785,8 @@ TEST(ProxyServiceTest, DefaultProxyFallbackToSOCKS) { } { scoped_refptr<ProxyService> service(new ProxyService( - new MockProxyConfigService(config), new MockAsyncProxyResolver, NULL)); + new MockProxyConfigService(config), new MockAsyncProxyResolver, NULL, + BoundNetLog())); GURL test_url("ftp://ftp.google.com"); ProxyInfo info; TestCompletionCallback callback; @@ -789,7 +797,8 @@ TEST(ProxyServiceTest, DefaultProxyFallbackToSOCKS) { } { scoped_refptr<ProxyService> service(new ProxyService( - new MockProxyConfigService(config), new MockAsyncProxyResolver, NULL)); + new MockProxyConfigService(config), new MockAsyncProxyResolver, NULL, + BoundNetLog())); GURL test_url("https://webbranch.techcu.com"); ProxyInfo info; TestCompletionCallback callback; @@ -800,7 +809,8 @@ TEST(ProxyServiceTest, DefaultProxyFallbackToSOCKS) { } { scoped_refptr<ProxyService> service(new ProxyService( - new MockProxyConfigService(config), new MockAsyncProxyResolver, NULL)); + new MockProxyConfigService(config), new MockAsyncProxyResolver, NULL, + BoundNetLog())); GURL test_url("unknown://www.microsoft.com"); ProxyInfo info; TestCompletionCallback callback; @@ -819,7 +829,7 @@ TEST(ProxyServiceTest, CancelInProgressRequest) { MockAsyncProxyResolver* resolver = new MockAsyncProxyResolver; scoped_refptr<ProxyService> service( - new ProxyService(config_service, resolver, NULL)); + new ProxyService(config_service, resolver, NULL, BoundNetLog())); // Start 3 requests. @@ -894,7 +904,7 @@ TEST(ProxyServiceTest, InitialPACScriptDownload) { new MockAsyncProxyResolverExpectsBytes; scoped_refptr<ProxyService> service( - new ProxyService(config_service, resolver, NULL)); + new ProxyService(config_service, resolver, NULL, BoundNetLog())); MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher; service->SetProxyScriptFetcher(fetcher); @@ -973,7 +983,7 @@ TEST(ProxyServiceTest, ChangeScriptFetcherWhilePACDownloadInProgress) { new MockAsyncProxyResolverExpectsBytes; scoped_refptr<ProxyService> service( - new ProxyService(config_service, resolver, NULL)); + new ProxyService(config_service, resolver, NULL, BoundNetLog())); MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher; service->SetProxyScriptFetcher(fetcher); @@ -1030,7 +1040,7 @@ TEST(ProxyServiceTest, CancelWhilePACFetching) { new MockAsyncProxyResolverExpectsBytes; scoped_refptr<ProxyService> service( - new ProxyService(config_service, resolver, NULL)); + new ProxyService(config_service, resolver, NULL, BoundNetLog())); MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher; service->SetProxyScriptFetcher(fetcher); @@ -1118,7 +1128,7 @@ TEST(ProxyServiceTest, FallbackFromAutodetectToCustomPac) { MockAsyncProxyResolverExpectsBytes* resolver = new MockAsyncProxyResolverExpectsBytes; scoped_refptr<ProxyService> service( - new ProxyService(config_service, resolver, NULL)); + new ProxyService(config_service, resolver, NULL, BoundNetLog())); MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher; service->SetProxyScriptFetcher(fetcher); @@ -1189,7 +1199,7 @@ TEST(ProxyServiceTest, FallbackFromAutodetectToCustomPac2) { MockAsyncProxyResolverExpectsBytes* resolver = new MockAsyncProxyResolverExpectsBytes; scoped_refptr<ProxyService> service( - new ProxyService(config_service, resolver, NULL)); + new ProxyService(config_service, resolver, NULL, BoundNetLog())); MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher; service->SetProxyScriptFetcher(fetcher); @@ -1265,7 +1275,7 @@ TEST(ProxyServiceTest, FallbackFromAutodetectToCustomToManual) { MockAsyncProxyResolverExpectsBytes* resolver = new MockAsyncProxyResolverExpectsBytes; scoped_refptr<ProxyService> service( - new ProxyService(config_service, resolver, NULL)); + new ProxyService(config_service, resolver, NULL, BoundNetLog())); MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher; service->SetProxyScriptFetcher(fetcher); @@ -1323,7 +1333,7 @@ TEST(ProxyServiceTest, BypassDoesntApplyToPac) { MockAsyncProxyResolverExpectsBytes* resolver = new MockAsyncProxyResolverExpectsBytes; scoped_refptr<ProxyService> service( - new ProxyService(config_service, resolver, NULL)); + new ProxyService(config_service, resolver, NULL, BoundNetLog())); MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher; service->SetProxyScriptFetcher(fetcher); @@ -1391,7 +1401,7 @@ TEST(ProxyServiceTest, DeleteWhileInitProxyResolverHasOutstandingFetch) { MockAsyncProxyResolverExpectsBytes* resolver = new MockAsyncProxyResolverExpectsBytes; scoped_refptr<ProxyService> service( - new ProxyService(config_service, resolver, NULL)); + new ProxyService(config_service, resolver, NULL, BoundNetLog())); MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher; service->SetProxyScriptFetcher(fetcher); @@ -1427,7 +1437,7 @@ TEST(ProxyServiceTest, DeleteWhileInitProxyResolverHasOutstandingSet) { MockAsyncProxyResolver* resolver = new MockAsyncProxyResolver; scoped_refptr<ProxyService> service( - new ProxyService(config_service, resolver, NULL)); + new ProxyService(config_service, resolver, NULL, BoundNetLog())); GURL url("http://www.google.com/"); @@ -1450,7 +1460,7 @@ TEST(ProxyServiceTest, ResetProxyConfigService) { scoped_refptr<ProxyService> service(new ProxyService( new MockProxyConfigService(config1), new MockAsyncProxyResolverExpectsBytes, - NULL)); + NULL, BoundNetLog())); ProxyInfo info; TestCompletionCallback callback1; @@ -1482,7 +1492,7 @@ TEST(ProxyServiceTest, UpdateConfigAfterFailedAutodetect) { MockProxyConfigService* config_service = new MockProxyConfigService(config); MockAsyncProxyResolver* resolver = new MockAsyncProxyResolver; scoped_refptr<ProxyService> service( - new ProxyService(config_service, resolver, NULL)); + new ProxyService(config_service, resolver, NULL, BoundNetLog())); // Start 1 requests. @@ -1528,7 +1538,7 @@ TEST(ProxyServiceTest, UpdateConfigFromPACToDirect) { MockProxyConfigService* config_service = new MockProxyConfigService(config); MockAsyncProxyResolver* resolver = new MockAsyncProxyResolver; scoped_refptr<ProxyService> service( - new ProxyService(config_service, resolver, NULL)); + new ProxyService(config_service, resolver, NULL, BoundNetLog())); // Start 1 request. @@ -1583,7 +1593,8 @@ TEST(ProxyServiceTest, NetworkChangeTriggersPacRefetch) { MockNetworkChangeNotifier network_change_notifier; scoped_refptr<ProxyService> service( - new ProxyService(config_service, resolver, &network_change_notifier)); + new ProxyService(config_service, resolver, &network_change_notifier, + BoundNetLog())); MockProxyScriptFetcher* fetcher = new MockProxyScriptFetcher; service->SetProxyScriptFetcher(fetcher); |