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

Unified 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: Formatting. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/proxy/proxy_service.cc
diff --git a/net/proxy/proxy_service.cc b/net/proxy/proxy_service.cc
index b3d3be442d3247fdec861484230f9b7d876d095a..b3edb994f2808ab75454012df21844e80397f1eb 100644
--- a/net/proxy/proxy_service.cc
+++ b/net/proxy/proxy_service.cc
@@ -13,8 +13,10 @@
#include "base/memory/weak_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/message_loop/message_loop_proxy.h"
+#include "base/metrics/histogram_macros.h"
#include "base/strings/string_util.h"
#include "base/thread_task_runner_handle.h"
+#include "base/time/time.h"
#include "base/values.h"
#include "net/base/completion_callback.h"
#include "net/base/load_flags.h"
@@ -361,6 +363,20 @@ class UnsetProxyConfigService : public ProxyConfigService {
};
#endif
+void RecordResolveProxyTime(TimeTicks start_time) {
+ UMA_HISTOGRAM_CUSTOM_TIMES("Net.ProxyService.ResolveProxyTime",
+ TimeTicks::Now() - start_time,
+ base::TimeDelta::FromMicroseconds(100),
+ base::TimeDelta::FromSeconds(20), 50);
+}
+
+void ResolveProxyCallbackHelper(TimeTicks start_time,
+ const CompletionCallback& callback,
+ int result) {
+ RecordResolveProxyTime(start_time);
+ callback.Run(result);
+}
+
} // namespace
// ProxyService::InitProxyResolver --------------------------------------------
@@ -827,6 +843,9 @@ class ProxyService::PacRequest
network_delegate_, results_);
if (rv == ERR_IO_PENDING)
rv = Start();
+ else
+ UMA_HISTOGRAM_BOOLEAN("Net.ProxyService.ResolvedUsingScript", false);
+
if (rv != ERR_IO_PENDING)
QueryComplete(rv);
}
@@ -863,6 +882,16 @@ class ProxyService::PacRequest
int QueryDidComplete(int result_code) {
DCHECK(!was_cancelled());
+ TimeTicks now = TimeTicks::Now();
+ if (is_started()) {
+ // The resolve job was completed as a result of calling |GetProxyForURL|.
+ UMA_HISTOGRAM_BOOLEAN("Net.ProxyService.ResolvedUsingScript", true);
+ UMA_HISTOGRAM_CUSTOM_TIMES("Net.ProxyService.GetProxyUsingScriptTime",
+ now - proxy_resolve_start_time_,
+ base::TimeDelta::FromMicroseconds(100),
+ base::TimeDelta::FromSeconds(20), 50);
+ }
+
// Clear |resolve_job_| so is_started() returns false while
// DidFinishResolvingProxy() runs.
resolve_job_ = nullptr;
@@ -878,7 +907,7 @@ class ProxyService::PacRequest
results_->config_source_ = config_source_;
results_->did_use_pac_script_ = true;
results_->proxy_resolve_start_time_ = proxy_resolve_start_time_;
- results_->proxy_resolve_end_time_ = TimeTicks::Now();
+ results_->proxy_resolve_end_time_ = now;
// Reset the state associated with in-progress-resolve.
config_id_ = ProxyConfig::kInvalidConfigID;
@@ -1047,6 +1076,7 @@ int ProxyService::ResolveProxyHelper(const GURL& raw_url,
const BoundNetLog& net_log) {
DCHECK(CalledOnValidThread());
+ TimeTicks start_time = TimeTicks::Now();
net_log.BeginEvent(NetLog::TYPE_PROXY_SERVICE);
// Notify our polling-based dependencies that a resolve is taking place.
@@ -1066,22 +1096,31 @@ int ProxyService::ResolveProxyHelper(const GURL& raw_url,
// using a direct connection for example).
int rv = TryToCompleteSynchronously(url, load_flags,
network_delegate, result);
- if (rv != ERR_IO_PENDING)
- return DidFinishResolvingProxy(url, load_flags, network_delegate,
- result, rv, net_log);
+ if (rv != ERR_IO_PENDING) {
+ UMA_HISTOGRAM_BOOLEAN("Net.ProxyService.ResolvedUsingScript", false);
eroman 2015/05/08 21:12:39 This is split between multiple locations. Please p
Anand Mistry (off Chromium) 2015/05/11 07:40:35 Done.
+ rv = DidFinishResolvingProxy(url, load_flags, network_delegate, result, rv,
+ net_log);
+ RecordResolveProxyTime(start_time);
+ return rv;
+ }
- if (callback.is_null())
+ if (callback.is_null()) {
+ UMA_HISTOGRAM_BOOLEAN("Net.ProxyService.ResolvedUsingScript", false);
eroman 2015/05/08 21:12:39 Remove the logging here. If there was no callback
Anand Mistry (off Chromium) 2015/05/11 07:40:35 Done.
+ RecordResolveProxyTime(start_time);
return ERR_IO_PENDING;
+ }
- scoped_refptr<PacRequest> req(
- new PacRequest(this, url, load_flags, network_delegate,
- result, callback, net_log));
+ scoped_refptr<PacRequest> req(new PacRequest(
+ this, url, load_flags, network_delegate, result,
+ base::Bind(&ResolveProxyCallbackHelper, start_time, callback), net_log));
if (current_state_ == STATE_READY) {
// Start the resolve request.
rv = req->Start();
- if (rv != ERR_IO_PENDING)
+ if (rv != ERR_IO_PENDING) {
+ RecordResolveProxyTime(start_time);
return req->QueryDidComplete(rv);
+ }
} else {
req->net_log()->BeginEvent(NetLog::TYPE_PROXY_SERVICE_WAITING_FOR_INIT_PAC);
}
@@ -1379,6 +1418,11 @@ int ProxyService::DidFinishResolvingProxy(const GURL& url,
ProxyInfo* result,
int result_code,
const BoundNetLog& net_log) {
+ // This function "fixes" the result code, so make sure script terminated
+ // errors are tracked.
+ UMA_HISTOGRAM_BOOLEAN("Net.ProxyService.ScriptTerminated",
+ result_code == ERR_PAC_SCRIPT_TERMINATED);
+
// Log the result of the proxy resolution.
if (result_code == OK) {
// Allow the network delegate to interpose on the resolution decision,
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698