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

Side by Side Diff: chrome/browser/sync/sessions/sync_session_context.cc

Issue 8631021: [Sync] Prevent uploading throttled datatypes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: For review. Created 9 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 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 #include "chrome/browser/sync/sessions/sync_session_context.h" 5 #include "chrome/browser/sync/sessions/sync_session_context.h"
6 6
7 #include "chrome/browser/sync/sessions/debug_info_getter.h" 7 #include "chrome/browser/sync/sessions/debug_info_getter.h"
8 #include "chrome/browser/sync/sessions/session_state.h" 8 #include "chrome/browser/sync/sessions/session_state.h"
9 #include "chrome/browser/sync/util/extensions_activity_monitor.h" 9 #include "chrome/browser/sync/util/extensions_activity_monitor.h"
10 #include "content/public/browser/browser_thread.h" 10 #include "content/public/browser/browser_thread.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 51
52 void SyncSessionContext::SetUnthrottleTime(const syncable::ModelTypeSet& types, 52 void SyncSessionContext::SetUnthrottleTime(const syncable::ModelTypeSet& types,
53 const base::TimeTicks& time) { 53 const base::TimeTicks& time) {
54 for (syncable::ModelTypeSet::const_iterator it = types.begin(); 54 for (syncable::ModelTypeSet::const_iterator it = types.begin();
55 it != types.end(); 55 it != types.end();
56 ++it) { 56 ++it) {
57 unthrottle_times_[*it] = time; 57 unthrottle_times_[*it] = time;
58 } 58 }
59 } 59 }
60 60
61 syncable::ModelTypeSet SyncSessionContext::
62 UpdateAndGetCurrentlyThrottledTypes() {
63 UpdateThrottledTypes(base::TimeTicks::Now());
64 return GetThrottledTypes();
65 }
66
67 void SyncSessionContext::UpdateThrottledTypes(const base::TimeTicks& time) {
68 UnthrottleTimes::const_iterator it = unthrottle_times_.begin();
69 while (it != unthrottle_times_.end()) {
70 if (it->second <= time) {
71 // Delete and increment the iterator.
72 UnthrottleTimes::const_iterator iterator_to_delete = it;
73 ++it;
74 unthrottle_times_.erase(iterator_to_delete);
75 } else {
76 // Just increment the iterator.
77 ++it;
78 }
79 }
80 }
81
82 // TODO(lipalani): Call this function and fill the return values in snapshot
83 // so it could be shown in the about:sync page.
84 syncable::ModelTypeSet SyncSessionContext::GetThrottledTypes() const {
85 syncable::ModelTypeSet types;
86 for (UnthrottleTimes::const_iterator it = unthrottle_times_.begin();
87 it != unthrottle_times_.end();
88 ++it) {
89 types.insert(it->first);
90 }
91 return types;
92 }
93
94
61 } // namespace sessions 95 } // namespace sessions
62 } // namespace browser_sync 96 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698