Index: net/url_request/url_request_throttler_entry.h |
diff --git a/net/url_request/url_request_throttler_entry.h b/net/url_request/url_request_throttler_entry.h |
index 7cc4133fb0538898543accddd8f5c11882fce3ad..75e6aa0c69efbb9f49c67697271ba7b27b5f38cb 100644 |
--- a/net/url_request/url_request_throttler_entry.h |
+++ b/net/url_request/url_request_throttler_entry.h |
@@ -10,7 +10,9 @@ |
#include <string> |
#include "base/basictypes.h" |
+#include "base/time.h" |
#include "net/base/backoff_entry.h" |
+#include "net/base/net_log.h" |
#include "net/url_request/url_request_throttler_entry_interface.h" |
namespace net { |
@@ -69,12 +71,14 @@ class NET_API URLRequestThrottlerEntry |
static const char kExponentialThrottlingDisableValue[]; |
// The manager object's lifetime must enclose the lifetime of this object. |
- explicit URLRequestThrottlerEntry(URLRequestThrottlerManager* manager); |
+ explicit URLRequestThrottlerEntry(URLRequestThrottlerManager* manager, |
+ const std::string& url_id); |
// The life span of instances created with this constructor is set to |
// infinite, and the number of initial errors to ignore is set to 0. |
// It is only used by unit tests. |
URLRequestThrottlerEntry(URLRequestThrottlerManager* manager, |
+ const std::string& url_id, |
int sliding_window_period_ms, |
int max_send_threshold, |
int initial_backoff_ms, |
@@ -100,15 +104,19 @@ class NET_API URLRequestThrottlerEntry |
virtual void UpdateWithResponse( |
const std::string& host, |
const URLRequestThrottlerHeaderInterface* response); |
- virtual void ReceivedContentWasMalformed(); |
+ virtual void ReceivedContentWasMalformed(int response_code); |
protected: |
virtual ~URLRequestThrottlerEntry(); |
void Initialize(); |
+ // Returns true if the given response code is considered an error for |
+ // throttling purposes. |
+ bool IsConsideredError(int response_code); |
+ |
// Equivalent to TimeTicks::Now(), virtual to be mockable for testing purpose. |
- virtual base::TimeTicks GetTimeNow() const; |
+ virtual base::TimeTicks ImplGetTimeNow() const; |
// Used internally to increase release time following a retry-after header. |
void HandleCustomRetryAfter(const std::string& header_value); |
@@ -117,6 +125,10 @@ class NET_API URLRequestThrottlerEntry |
void HandleThrottlingHeader(const std::string& header_value, |
const std::string& host); |
+ // Used internally to keep track of failure->success transitions and |
+ // generate statistics about them. |
+ void HandleMetricsTracking(int response_code); |
+ |
// Retrieves the back-off entry object we're using. Used to enable a |
// unit testing seam for dependency injection in tests. |
virtual const BackoffEntry* GetBackoffEntry() const; |
@@ -154,9 +166,23 @@ class NET_API URLRequestThrottlerEntry |
// Access it through GetBackoffEntry() to allow a unit test seam. |
BackoffEntry backoff_entry_; |
+ // The time of the last successful response, plus knowledge of whether |
+ // the last response was successful or not, let us generate statistics on |
+ // the length of perceived downtime for a given URL, and the error count |
+ // when such transitions occur. This is useful for experiments with |
+ // throttling but will likely become redundant after they are finished. |
+ // TODO(joi): Remove when the time is right |
+ base::TimeTicks last_successful_response_time_; |
+ bool last_response_was_success_; |
+ |
// Weak back-reference to the manager object managing us. |
URLRequestThrottlerManager* manager_; |
+ // Canonicalized URL string that this entry is for; used for logging only. |
+ std::string url_id_; |
+ |
+ BoundNetLog net_log_; |
+ |
DISALLOW_COPY_AND_ASSIGN(URLRequestThrottlerEntry); |
}; |