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

Unified Diff: chrome/browser/policy/cloud/rate_limiter.h

Issue 109743002: Move policy code into components/policy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: moar fixes Created 7 years 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 | « chrome/browser/policy/cloud/policy_builder.cc ('k') | chrome/browser/policy/cloud/rate_limiter.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/policy/cloud/rate_limiter.h
diff --git a/chrome/browser/policy/cloud/rate_limiter.h b/chrome/browser/policy/cloud/rate_limiter.h
deleted file mode 100644
index 00af48dd4215278b9477fd79c5033ecc62d8c3ab..0000000000000000000000000000000000000000
--- a/chrome/browser/policy/cloud/rate_limiter.h
+++ /dev/null
@@ -1,59 +0,0 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_POLICY_CLOUD_RATE_LIMITER_H_
-#define CHROME_BROWSER_POLICY_CLOUD_RATE_LIMITER_H_
-
-#include <queue>
-
-#include "base/basictypes.h"
-#include "base/callback.h"
-#include "base/cancelable_callback.h"
-#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/threading/non_thread_safe.h"
-#include "base/time/time.h"
-
-namespace base {
-class SequencedTaskRunner;
-class TickClock;
-}
-
-namespace policy {
-
-// A simple class to limit the rate at which a callback is invoked.
-class RateLimiter : public base::NonThreadSafe {
- public:
- // Will limit invocations of |callback| to |max_requests| per |duration|.
- // |task_runner| is used to post delayed tasks, and |clock| is used to
- // measure elapsed time.
- RateLimiter(size_t max_requests,
- const base::TimeDelta& duration,
- const base::Closure& callback,
- scoped_refptr<base::SequencedTaskRunner> task_runner,
- scoped_ptr<base::TickClock> clock);
- ~RateLimiter();
-
- // Posts a request to invoke |callback_|. It is invoked immediately if the
- // rate in the preceding |duration_| period is within the limit, otherwise
- // the callback will be invoked later, ensuring the allowed rate is not
- // exceeded.
- void PostRequest();
-
- private:
- const size_t max_requests_;
- const base::TimeDelta duration_;
- base::Closure callback_;
- scoped_refptr<base::SequencedTaskRunner> task_runner_;
- scoped_ptr<base::TickClock> clock_;
-
- std::queue<base::TimeTicks> invocation_times_;
- base::CancelableClosure delayed_callback_;
-
- DISALLOW_COPY_AND_ASSIGN(RateLimiter);
-};
-
-} // namespace policy
-
-#endif // CHROME_BROWSER_POLICY_CLOUD_RATE_LIMITER_H_
« no previous file with comments | « chrome/browser/policy/cloud/policy_builder.cc ('k') | chrome/browser/policy/cloud/rate_limiter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698