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

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

Issue 1121823004: Add some basic UMA for proxy service. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Tweak summary and rebase. Created 5 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
« no previous file with comments | « net/proxy/proxy_service.h ('k') | tools/metrics/histograms/histograms.xml » ('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) 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"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "base/message_loop/message_loop.h" 14 #include "base/message_loop/message_loop.h"
15 #include "base/message_loop/message_loop_proxy.h" 15 #include "base/message_loop/message_loop_proxy.h"
16 #include "base/metrics/histogram_macros.h"
16 #include "base/strings/string_util.h" 17 #include "base/strings/string_util.h"
17 #include "base/thread_task_runner_handle.h" 18 #include "base/thread_task_runner_handle.h"
19 #include "base/time/time.h"
18 #include "base/values.h" 20 #include "base/values.h"
19 #include "net/base/completion_callback.h" 21 #include "net/base/completion_callback.h"
20 #include "net/base/load_flags.h" 22 #include "net/base/load_flags.h"
21 #include "net/base/net_errors.h" 23 #include "net/base/net_errors.h"
22 #include "net/base/net_util.h" 24 #include "net/base/net_util.h"
23 #include "net/log/net_log.h" 25 #include "net/log/net_log.h"
24 #include "net/proxy/dhcp_proxy_script_fetcher.h" 26 #include "net/proxy/dhcp_proxy_script_fetcher.h"
25 #include "net/proxy/multi_threaded_proxy_resolver.h" 27 #include "net/proxy/multi_threaded_proxy_resolver.h"
26 #include "net/proxy/network_delegate_error_observer.h" 28 #include "net/proxy/network_delegate_error_observer.h"
27 #include "net/proxy/proxy_config_service_fixed.h" 29 #include "net/proxy/proxy_config_service_fixed.h"
(...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after
849 // Returns true if Cancel() has been called. 851 // Returns true if Cancel() has been called.
850 bool was_cancelled() const { 852 bool was_cancelled() const {
851 return user_callback_.is_null(); 853 return user_callback_.is_null();
852 } 854 }
853 855
854 // Helper to call after ProxyResolver completion (both synchronous and 856 // Helper to call after ProxyResolver completion (both synchronous and
855 // asynchronous). Fixes up the result that is to be returned to user. 857 // asynchronous). Fixes up the result that is to be returned to user.
856 int QueryDidComplete(int result_code) { 858 int QueryDidComplete(int result_code) {
857 DCHECK(!was_cancelled()); 859 DCHECK(!was_cancelled());
858 860
861 // This state is cleared when resolve_job_ is set to nullptr below.
862 bool script_executed = is_started();
863
859 // Clear |resolve_job_| so is_started() returns false while 864 // Clear |resolve_job_| so is_started() returns false while
860 // DidFinishResolvingProxy() runs. 865 // DidFinishResolvingProxy() runs.
861 resolve_job_ = nullptr; 866 resolve_job_ = nullptr;
862 867
863 // Note that DidFinishResolvingProxy might modify |results_|. 868 // Note that DidFinishResolvingProxy might modify |results_|.
864 int rv = service_->DidFinishResolvingProxy(url_, load_flags_, 869 int rv = service_->DidFinishResolvingProxy(
865 network_delegate_, results_, 870 url_, load_flags_, network_delegate_, results_, result_code, net_log_,
866 result_code, net_log_); 871 creation_time_, script_executed);
867 872
868 // Make a note in the results which configuration was in use at the 873 // Make a note in the results which configuration was in use at the
869 // time of the resolve. 874 // time of the resolve.
870 results_->config_id_ = config_id_; 875 results_->config_id_ = config_id_;
871 results_->config_source_ = config_source_; 876 results_->config_source_ = config_source_;
872 results_->did_use_pac_script_ = true; 877 results_->did_use_pac_script_ = true;
873 results_->proxy_resolve_start_time_ = creation_time_; 878 results_->proxy_resolve_start_time_ = creation_time_;
874 results_->proxy_resolve_end_time_ = TimeTicks::Now(); 879 results_->proxy_resolve_end_time_ = TimeTicks::Now();
875 880
876 // Reset the state associated with in-progress-resolve. 881 // Reset the state associated with in-progress-resolve.
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
1052 ApplyProxyConfigIfAvailable(); 1057 ApplyProxyConfigIfAvailable();
1053 1058
1054 // Strip away any reference fragments and the username/password, as they 1059 // Strip away any reference fragments and the username/password, as they
1055 // are not relevant to proxy resolution. 1060 // are not relevant to proxy resolution.
1056 GURL url = SimplifyUrlForRequest(raw_url); 1061 GURL url = SimplifyUrlForRequest(raw_url);
1057 1062
1058 // Check if the request can be completed right away. (This is the case when 1063 // Check if the request can be completed right away. (This is the case when
1059 // using a direct connection for example). 1064 // using a direct connection for example).
1060 int rv = TryToCompleteSynchronously(url, load_flags, 1065 int rv = TryToCompleteSynchronously(url, load_flags,
1061 network_delegate, result); 1066 network_delegate, result);
1062 if (rv != ERR_IO_PENDING) 1067 if (rv != ERR_IO_PENDING) {
1063 return DidFinishResolvingProxy(url, load_flags, network_delegate, 1068 rv = DidFinishResolvingProxy(
1064 result, rv, net_log); 1069 url, load_flags, network_delegate, result, rv, net_log,
1070 callback.is_null() ? TimeTicks() : TimeTicks::Now(), false);
1071 return rv;
1072 }
1065 1073
1066 if (callback.is_null()) 1074 if (callback.is_null())
1067 return ERR_IO_PENDING; 1075 return ERR_IO_PENDING;
1068 1076
1069 scoped_refptr<PacRequest> req( 1077 scoped_refptr<PacRequest> req(
1070 new PacRequest(this, url, load_flags, network_delegate, 1078 new PacRequest(this, url, load_flags, network_delegate,
1071 result, callback, net_log)); 1079 result, callback, net_log));
1072 1080
1073 if (current_state_ == STATE_READY) { 1081 if (current_state_ == STATE_READY) {
1074 // Start the resolve request. 1082 // Start the resolve request.
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
1364 PendingRequests::iterator it = std::find( 1372 PendingRequests::iterator it = std::find(
1365 pending_requests_.begin(), pending_requests_.end(), req); 1373 pending_requests_.begin(), pending_requests_.end(), req);
1366 pending_requests_.erase(it); 1374 pending_requests_.erase(it);
1367 } 1375 }
1368 1376
1369 int ProxyService::DidFinishResolvingProxy(const GURL& url, 1377 int ProxyService::DidFinishResolvingProxy(const GURL& url,
1370 int load_flags, 1378 int load_flags,
1371 NetworkDelegate* network_delegate, 1379 NetworkDelegate* network_delegate,
1372 ProxyInfo* result, 1380 ProxyInfo* result,
1373 int result_code, 1381 int result_code,
1374 const BoundNetLog& net_log) { 1382 const BoundNetLog& net_log,
1383 base::TimeTicks start_time,
1384 bool script_executed) {
1385 // Don't track any metrics if start_time is 0, which will happen when the user
1386 // calls |TryResolveProxySynchronously|.
1387 if (!start_time.is_null()) {
1388 TimeDelta diff = TimeTicks::Now() - start_time;
1389 if (script_executed) {
1390 // This function "fixes" the result code, so make sure script terminated
1391 // errors are tracked. Only track result codes that were a result of
1392 // script execution.
1393 UMA_HISTOGRAM_BOOLEAN("Net.ProxyService.ScriptTerminated",
1394 result_code == ERR_PAC_SCRIPT_TERMINATED);
1395 UMA_HISTOGRAM_CUSTOM_TIMES("Net.ProxyService.GetProxyUsingScriptTime",
1396 diff, base::TimeDelta::FromMicroseconds(100),
1397 base::TimeDelta::FromSeconds(20), 50);
1398 }
1399 UMA_HISTOGRAM_BOOLEAN("Net.ProxyService.ResolvedUsingScript",
1400 script_executed);
1401 UMA_HISTOGRAM_CUSTOM_TIMES("Net.ProxyService.ResolveProxyTime", diff,
1402 base::TimeDelta::FromMicroseconds(100),
1403 base::TimeDelta::FromSeconds(20), 50);
1404 }
1405
1375 // Log the result of the proxy resolution. 1406 // Log the result of the proxy resolution.
1376 if (result_code == OK) { 1407 if (result_code == OK) {
1377 // Allow the network delegate to interpose on the resolution decision, 1408 // Allow the network delegate to interpose on the resolution decision,
1378 // possibly modifying the ProxyInfo. 1409 // possibly modifying the ProxyInfo.
1379 if (network_delegate) 1410 if (network_delegate)
1380 network_delegate->NotifyResolveProxy(url, load_flags, *this, result); 1411 network_delegate->NotifyResolveProxy(url, load_flags, *this, result);
1381 1412
1382 // When logging all events is enabled, dump the proxy list. 1413 // When logging all events is enabled, dump the proxy list.
1383 if (net_log.IsCapturing()) { 1414 if (net_log.IsCapturing()) {
1384 net_log.AddEvent( 1415 net_log.AddEvent(
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
1631 State previous_state = ResetProxyConfig(false); 1662 State previous_state = ResetProxyConfig(false);
1632 if (previous_state != STATE_NONE) 1663 if (previous_state != STATE_NONE)
1633 ApplyProxyConfigIfAvailable(); 1664 ApplyProxyConfigIfAvailable();
1634 } 1665 }
1635 1666
1636 void ProxyService::OnDNSChanged() { 1667 void ProxyService::OnDNSChanged() {
1637 OnIPAddressChanged(); 1668 OnIPAddressChanged();
1638 } 1669 }
1639 1670
1640 } // namespace net 1671 } // namespace net
OLDNEW
« no previous file with comments | « net/proxy/proxy_service.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698