#include "base/callback.h"
#include "base/logging.h"
#include "base/memory/weak_ptr.h"
-#include "base/strings/stringprintf.h"
#include "base/time/time.h"
#include "base/timer/timer.h"
#include "net/base/net_errors.h"
// Initialize base timer with retain_user_info and is_repeating false.
ActualTimer() : base_timer_(false, false) {}
- virtual ~ActualTimer() {}
+ ~ActualTimer() override {}
// MockableTime::Timer implementation:
- virtual void Start(const tracked_objects::Location& posted_from,
- base::TimeDelta delay,
- const base::Closure& user_task) OVERRIDE {
+ void Start(const tracked_objects::Location& posted_from,
+ base::TimeDelta delay,
+ const base::Closure& user_task) override {
base_timer_.Start(posted_from, delay, user_task);
}
- virtual void Stop() OVERRIDE {
- base_timer_.Stop();
- }
+ void Stop() override { base_timer_.Stop(); }
- virtual bool IsRunning() OVERRIDE {
- return base_timer_.IsRunning();
- }
+ bool IsRunning() override { return base_timer_.IsRunning(); }
private:
base::Timer base_timer_;
const char* beacon_status;
} net_error_map[] = {
{ net::OK, "ok" },
+ { net::ERR_ABORTED, "aborted" },
{ net::ERR_TIMED_OUT, "tcp.connection.timed_out" },
{ net::ERR_CONNECTION_CLOSED, "tcp.connection.closed" },
{ net::ERR_CONNECTION_RESET, "tcp.connection.reset" },
std::string* beacon_status_out) {
if (net_error == net::OK) {
if (http_response_code >= 400 && http_response_code < 600)
- *beacon_status_out = base::StringPrintf("http.%d", http_response_code);
+ *beacon_status_out = "http.error";
else
*beacon_status_out = "ok";
return true;
return false;
}
+// TODO(ttuttle): Consider using NPN/ALPN instead, if there's a good way to
+// differentiate HTTP and HTTPS.
+std::string GetDomainReliabilityProtocol(
+ net::HttpResponseInfo::ConnectionInfo connection_info,
+ bool ssl_info_populated) {
+ switch (connection_info) {
+ case net::HttpResponseInfo::CONNECTION_INFO_UNKNOWN:
+ return "";
+ case net::HttpResponseInfo::CONNECTION_INFO_HTTP1:
+ return ssl_info_populated ? "HTTPS" : "HTTP";
+ case net::HttpResponseInfo::CONNECTION_INFO_DEPRECATED_SPDY2:
+ case net::HttpResponseInfo::CONNECTION_INFO_SPDY3:
+ case net::HttpResponseInfo::CONNECTION_INFO_SPDY4:
+ return "SPDY";
+ case net::HttpResponseInfo::CONNECTION_INFO_QUIC1_SPDY3:
+ return "QUIC";
+ case net::HttpResponseInfo::NUM_OF_CONNECTION_INFOS:
+ NOTREACHED();
+ return "";
+ }
+ NOTREACHED();
+ return "";
+}
+
MockableTime::Timer::~Timer() {}
MockableTime::Timer::Timer() {}
return scoped_ptr<MockableTime::Timer>(new ActualTimer());
}
+MockableTimeBackoffEntry::MockableTimeBackoffEntry(
+ const net::BackoffEntry::Policy* const policy,
+ MockableTime* time)
+ : net::BackoffEntry(policy),
+ time_(time) {
+}
+
+MockableTimeBackoffEntry::~MockableTimeBackoffEntry() {}
+
+base::TimeTicks MockableTimeBackoffEntry::ImplGetTimeNow() const {
+ return time_->NowTicks();
+}
+
} // namespace domain_reliability