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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 } | 42 } |
43 | 43 |
44 SyncSessionContext::~SyncSessionContext() { | 44 SyncSessionContext::~SyncSessionContext() { |
45 // In unittests, there may be no UI thread, so the above will fail. | 45 // In unittests, there may be no UI thread, so the above will fail. |
46 if (!BrowserThread::DeleteSoon(BrowserThread::UI, FROM_HERE, | 46 if (!BrowserThread::DeleteSoon(BrowserThread::UI, FROM_HERE, |
47 extensions_activity_monitor_)) { | 47 extensions_activity_monitor_)) { |
48 delete extensions_activity_monitor_; | 48 delete extensions_activity_monitor_; |
49 } | 49 } |
50 } | 50 } |
51 | 51 |
52 void SyncSessionContext::SetUnthrottleTime(syncable::ModelEnumSet types, | 52 void SyncSessionContext::SetUnthrottleTime(syncable::ModelTypeSet types, |
53 const base::TimeTicks& time) { | 53 const base::TimeTicks& time) { |
54 for (syncable::ModelEnumSet::Iterator it = types.First(); | 54 for (syncable::ModelTypeSet::Iterator it = types.First(); |
55 it.Good(); it.Inc()) { | 55 it.Good(); it.Inc()) { |
56 unthrottle_times_[it.Get()] = time; | 56 unthrottle_times_[it.Get()] = time; |
57 } | 57 } |
58 } | 58 } |
59 | 59 |
60 void SyncSessionContext::PruneUnthrottledTypes(const base::TimeTicks& time) { | 60 void SyncSessionContext::PruneUnthrottledTypes(const base::TimeTicks& time) { |
61 UnthrottleTimes::iterator it = unthrottle_times_.begin(); | 61 UnthrottleTimes::iterator it = unthrottle_times_.begin(); |
62 while (it != unthrottle_times_.end()) { | 62 while (it != unthrottle_times_.end()) { |
63 if (it->second <= time) { | 63 if (it->second <= time) { |
64 // Delete and increment the iterator. | 64 // Delete and increment the iterator. |
65 UnthrottleTimes::iterator iterator_to_delete = it; | 65 UnthrottleTimes::iterator iterator_to_delete = it; |
66 ++it; | 66 ++it; |
67 unthrottle_times_.erase(iterator_to_delete); | 67 unthrottle_times_.erase(iterator_to_delete); |
68 } else { | 68 } else { |
69 // Just increment the iterator. | 69 // Just increment the iterator. |
70 ++it; | 70 ++it; |
71 } | 71 } |
72 } | 72 } |
73 } | 73 } |
74 | 74 |
75 // TODO(lipalani): Call this function and fill the return values in snapshot | 75 // TODO(lipalani): Call this function and fill the return values in snapshot |
76 // so it could be shown in the about:sync page. | 76 // so it could be shown in the about:sync page. |
77 syncable::ModelEnumSet SyncSessionContext::GetThrottledTypes() const { | 77 syncable::ModelTypeSet SyncSessionContext::GetThrottledTypes() const { |
78 syncable::ModelEnumSet types; | 78 syncable::ModelTypeSet types; |
79 for (UnthrottleTimes::const_iterator it = unthrottle_times_.begin(); | 79 for (UnthrottleTimes::const_iterator it = unthrottle_times_.begin(); |
80 it != unthrottle_times_.end(); | 80 it != unthrottle_times_.end(); |
81 ++it) { | 81 ++it) { |
82 types.Put(it->first); | 82 types.Put(it->first); |
83 } | 83 } |
84 return types; | 84 return types; |
85 } | 85 } |
86 | 86 |
87 } // namespace sessions | 87 } // namespace sessions |
88 } // namespace browser_sync | 88 } // namespace browser_sync |
OLD | NEW |