summaryrefslogtreecommitdiffstats
path: root/sync/sessions/sync_session_context.cc
diff options
context:
space:
mode:
authorrlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-13 22:14:05 +0000
committerrlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-13 22:14:05 +0000
commitc0383289e19de6601268360fb7234f94f63a19e4 (patch)
treefa5cab3ae06ef88aa6aad928ca80a69a70a703c4 /sync/sessions/sync_session_context.cc
parent7e929f48631779ae0264733b1a7769712c204d42 (diff)
downloadchromium_src-c0383289e19de6601268360fb7234f94f63a19e4.zip
chromium_src-c0383289e19de6601268360fb7234f94f63a19e4.tar.gz
chromium_src-c0383289e19de6601268360fb7234f94f63a19e4.tar.bz2
sync: Refactor per-datatype throttling
This CL pulls the code to track throttled data types out of the sync session context and into a class meant for that purpose. This new class, ThrottledDataTypeTracker, also implements code to notify the AllStatus object whenever the set of throttled datatypes is changed. The fact that ThrottledDataTypeTracker, which lives in sync/engine, references AllStatus caused some problems with DEPS checks. After a few iterations during code review, this commit now includes the following additional changes: - Move all_status.{cc,h} from sync/internal_api to sync/engine. - Move the SyncManager::Status inner class out of SyncManager and into sync/internal_api/public/engine/sync_status.{cc,h}. The class has been renamed to SyncStatus. This CL does not include code to expose the throttled status on the chrome://sync page, though it does contain functionality we will use to implement it in a future commit. BUG=125065 TEST= Review URL: https://chromiumcodereview.appspot.com/10454105 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@141992 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync/sessions/sync_session_context.cc')
-rw-r--r--sync/sessions/sync_session_context.cc46
1 files changed, 3 insertions, 43 deletions
diff --git a/sync/sessions/sync_session_context.cc b/sync/sessions/sync_session_context.cc
index 8af1955..ce9d938 100644
--- a/sync/sessions/sync_session_context.cc
+++ b/sync/sessions/sync_session_context.cc
@@ -4,6 +4,7 @@
#include "sync/sessions/sync_session_context.h"
+#include "sync/engine/throttled_data_type_tracker.h"
#include "sync/sessions/debug_info_getter.h"
#include "sync/util/extensions_activity_monitor.h"
@@ -19,6 +20,7 @@ SyncSessionContext::SyncSessionContext(
const ModelSafeRoutingInfo& model_safe_routing_info,
const std::vector<ModelSafeWorker*>& workers,
ExtensionsActivityMonitor* extensions_activity_monitor,
+ ThrottledDataTypeTracker* throttled_data_type_tracker,
const std::vector<SyncEngineEventListener*>& listeners,
DebugInfoGetter* debug_info_getter,
browser_sync::TrafficRecorder* traffic_recorder)
@@ -30,6 +32,7 @@ SyncSessionContext::SyncSessionContext(
extensions_activity_monitor_(extensions_activity_monitor),
notifications_enabled_(false),
max_commit_batch_size_(kDefaultMaxCommitBatchSize),
+ throttled_data_type_tracker_(throttled_data_type_tracker),
debug_info_getter_(debug_info_getter),
traffic_recorder_(traffic_recorder) {
std::vector<SyncEngineEventListener*>::const_iterator it;
@@ -37,51 +40,8 @@ SyncSessionContext::SyncSessionContext(
listeners_.AddObserver(*it);
}
-SyncSessionContext::SyncSessionContext()
- : connection_manager_(NULL),
- directory_(NULL),
- extensions_activity_monitor_(NULL),
- debug_info_getter_(NULL),
- traffic_recorder_(NULL) {
-}
-
SyncSessionContext::~SyncSessionContext() {
}
-void SyncSessionContext::SetUnthrottleTime(syncable::ModelTypeSet types,
- const base::TimeTicks& time) {
- for (syncable::ModelTypeSet::Iterator it = types.First();
- it.Good(); it.Inc()) {
- unthrottle_times_[it.Get()] = time;
- }
-}
-
-void SyncSessionContext::PruneUnthrottledTypes(const base::TimeTicks& time) {
- UnthrottleTimes::iterator it = unthrottle_times_.begin();
- while (it != unthrottle_times_.end()) {
- if (it->second <= time) {
- // Delete and increment the iterator.
- UnthrottleTimes::iterator iterator_to_delete = it;
- ++it;
- unthrottle_times_.erase(iterator_to_delete);
- } else {
- // Just increment the iterator.
- ++it;
- }
- }
-}
-
-// TODO(lipalani): Call this function and fill the return values in snapshot
-// so it could be shown in the about:sync page.
-syncable::ModelTypeSet SyncSessionContext::GetThrottledTypes() const {
- syncable::ModelTypeSet types;
- for (UnthrottleTimes::const_iterator it = unthrottle_times_.begin();
- it != unthrottle_times_.end();
- ++it) {
- types.Put(it->first);
- }
- return types;
-}
-
} // namespace sessions
} // namespace browser_sync