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

Unified Diff: sync/engine/throttled_data_type_tracker.h

Issue 10454105: sync: Refactor per-datatype throttling (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments Created 8 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sync/engine/syncer_unittest.cc ('k') | sync/engine/throttled_data_type_tracker.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/engine/throttled_data_type_tracker.h
diff --git a/sync/engine/throttled_data_type_tracker.h b/sync/engine/throttled_data_type_tracker.h
new file mode 100644
index 0000000000000000000000000000000000000000..aa2835bdb696104afa915c4352a2a771ea31afea
--- /dev/null
+++ b/sync/engine/throttled_data_type_tracker.h
@@ -0,0 +1,55 @@
+// Copyright (c) 2012 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 SYNC_ENGINE_THROTTLED_DATA_TYPE_TRACKER_H_
+#define SYNC_ENGINE_THROTTLED_DATA_TYPE_TRACKER_H_
+#pragma once
+
+#include <map>
+
+#include "base/gtest_prod_util.h"
+#include "sync/internal_api/public/syncable/model_type.h"
+
+namespace browser_sync {
+
+class AllStatus;
+
+class ThrottledDataTypeTracker {
+ public:
+ // The given allstatus argument will be kept up to date on this object's list
+ // of throttled types. The argument may be NULL in tests.
+ explicit ThrottledDataTypeTracker(AllStatus* allstatus);
+ ~ThrottledDataTypeTracker();
+
+ // Throttles a set of data types until the specified time is reached.
+ void SetUnthrottleTime(syncable::ModelTypeSet types,
+ const base::TimeTicks& time);
+
+ // Given an input of the current time (usually from time::Now()), removes from
+ // the set of throttled types any types whose throttling period has expired.
+ void PruneUnthrottledTypes(const base::TimeTicks& time);
+
+ // Returns the set of types which are currently throttled.
+ syncable::ModelTypeSet GetThrottledTypes() const;
+
+ private:
+ FRIEND_TEST_ALL_PREFIXES(ThrottledDataTypeTrackerTest,
+ AddUnthrottleTimeTest);
+ FRIEND_TEST_ALL_PREFIXES(ThrottledDataTypeTrackerTest,
+ GetCurrentlyThrottledTypesTest);
+
+ typedef std::map<syncable::ModelType, base::TimeTicks> UnthrottleTimes;
+
+ // This is a map from throttled data types to the time at which they can be
+ // unthrottled.
+ UnthrottleTimes unthrottle_times_;
+
+ AllStatus* allstatus_;
+
+ DISALLOW_COPY_AND_ASSIGN(ThrottledDataTypeTracker);
+};
+
+} // namespace browser_sync
+
+#endif // SYNC_ENGINE_THROTTLED_DATA_TYPE_TRACKER_H_
« no previous file with comments | « sync/engine/syncer_unittest.cc ('k') | sync/engine/throttled_data_type_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698