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

Side by Side Diff: net/base/backoff_entry.h

Issue 6966038: Anti-DDoS enhancements: Log to net log, UMA stats, improved policy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to head. Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #ifndef NET_BASE_BACKOFF_ITEM_H_ 5 #ifndef NET_BASE_BACKOFF_ITEM_H_
6 #define NET_BASE_BACKOFF_ITEM_H_ 6 #define NET_BASE_BACKOFF_ITEM_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/threading/non_thread_safe.h" 9 #include "base/threading/non_thread_safe.h"
10 #include "base/time.h" 10 #include "base/time.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 62
63 // Causes this object reject requests until the specified absolute time. 63 // Causes this object reject requests until the specified absolute time.
64 // This can be used to e.g. implement support for a Retry-After header. 64 // This can be used to e.g. implement support for a Retry-After header.
65 void SetCustomReleaseTime(const base::TimeTicks& release_time); 65 void SetCustomReleaseTime(const base::TimeTicks& release_time);
66 66
67 // Returns true if this object has no significant state (i.e. you could 67 // Returns true if this object has no significant state (i.e. you could
68 // just as well start with a fresh BackoffEntry object), and hasn't 68 // just as well start with a fresh BackoffEntry object), and hasn't
69 // had for Policy::entry_lifetime_ms_. 69 // had for Policy::entry_lifetime_ms_.
70 bool CanDiscard() const; 70 bool CanDiscard() const;
71 71
72 // Resets this entry to a fresh (as if just constructed) state.
73 void Reset();
74
75 // Returns the failure count for this entry.
76 int failure_count() const { return failure_count_; }
77
72 protected: 78 protected:
73 // Equivalent to TimeTicks::Now(), virtual so unit tests can override. 79 // Equivalent to TimeTicks::Now(), virtual so unit tests can override.
74 // TODO(joi): Switch to constructor-time dependency injection? 80 virtual base::TimeTicks ImplGetTimeNow() const;
75 virtual base::TimeTicks GetTimeNow() const;
76 81
77 private: 82 private:
78 // Calculates when requests should again be allowed through. 83 // Calculates when requests should again be allowed through.
79 base::TimeTicks CalculateReleaseTime() const; 84 base::TimeTicks CalculateReleaseTime() const;
80 85
81 // Timestamp calculated by the exponential back-off algorithm at which we are 86 // Timestamp calculated by the exponential back-off algorithm at which we are
82 // allowed to start sending requests again. 87 // allowed to start sending requests again.
83 base::TimeTicks exponential_backoff_release_time_; 88 base::TimeTicks exponential_backoff_release_time_;
84 89
85 // Counts request errors; reset on success. 90 // Counts request errors; reset on success.
86 int failure_count_; 91 int failure_count_;
87 92
88 const Policy* const policy_; 93 const Policy* const policy_;
89 94
90 DISALLOW_COPY_AND_ASSIGN(BackoffEntry); 95 DISALLOW_COPY_AND_ASSIGN(BackoffEntry);
91 }; 96 };
92 97
93 } // namespace net 98 } // namespace net
94 99
95 #endif // NET_BASE_BACKOFF_ITEM_H_ 100 #endif // NET_BASE_BACKOFF_ITEM_H_
OLDNEW
« no previous file with comments | « chrome/service/cloud_print/cloud_print_url_fetcher_unittest.cc ('k') | net/base/backoff_entry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698