OLD | NEW |
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 Loading... |
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 void SyncSessionContext::PruneUnthrottledTypes(const base::TimeTicks& time) { |
| 62 UnthrottleTimes::iterator it = unthrottle_times_.begin(); |
| 63 while (it != unthrottle_times_.end()) { |
| 64 if (it->second <= time) { |
| 65 // Delete and increment the iterator. |
| 66 UnthrottleTimes::iterator iterator_to_delete = it; |
| 67 ++it; |
| 68 unthrottle_times_.erase(iterator_to_delete); |
| 69 } else { |
| 70 // Just increment the iterator. |
| 71 ++it; |
| 72 } |
| 73 } |
| 74 } |
| 75 |
| 76 // TODO(lipalani): Call this function and fill the return values in snapshot |
| 77 // so it could be shown in the about:sync page. |
| 78 syncable::ModelTypeSet SyncSessionContext::GetThrottledTypes() const { |
| 79 syncable::ModelTypeSet types; |
| 80 for (UnthrottleTimes::const_iterator it = unthrottle_times_.begin(); |
| 81 it != unthrottle_times_.end(); |
| 82 ++it) { |
| 83 types.insert(it->first); |
| 84 } |
| 85 return types; |
| 86 } |
| 87 |
61 } // namespace sessions | 88 } // namespace sessions |
62 } // namespace browser_sync | 89 } // namespace browser_sync |
OLD | NEW |