#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/message_loop/message_loop_proxy.h"
-#include "base/metrics/histogram.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/threading/thread.h"
url_(url),
was_waiting_for_thread_(false) {
DCHECK(!callback.is_null());
- start_time_ = base::TimeTicks::Now();
}
BoundNetLog* net_log() { return &net_log_; }
virtual void FinishedWaitingForThread() OVERRIDE {
DCHECK(executor());
- submitted_to_thread_time_ = base::TimeTicks::Now();
-
if (was_waiting_for_thread_) {
net_log_.EndEvent(NetLog::TYPE_WAITING_FOR_PROXY_RESOLVER_THREAD);
}
void QueryComplete(int result_code) {
// The Job may have been cancelled after it was started.
if (!was_cancelled()) {
- RecordPerformanceMetrics();
if (result_code >= OK) { // Note: unit-tests use values > 0.
results_->Use(results_buf_);
}
OnJobCompleted();
}
- void RecordPerformanceMetrics() {
- DCHECK(!was_cancelled());
-
- base::TimeTicks now = base::TimeTicks::Now();
-
- // Log the total time the request took to complete.
- UMA_HISTOGRAM_MEDIUM_TIMES("Net.MTPR_GetProxyForUrl_Time",
- now - start_time_);
-
- // Log the time the request was stalled waiting for a thread to free up.
- UMA_HISTOGRAM_MEDIUM_TIMES("Net.MTPR_GetProxyForUrl_Thread_Wait_Time",
- submitted_to_thread_time_ - start_time_);
- }
-
// Must only be used on the "origin" thread.
ProxyInfo* results_;
// Usable from within DoQuery on the worker thread.
ProxyInfo results_buf_;
- base::TimeTicks start_time_;
- base::TimeTicks submitted_to_thread_time_;
-
bool was_waiting_for_thread_;
};