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(const syncable::ModelTypeSet& types, | 52 void SyncSessionContext::SetUnthrottleTime(syncable::ModelEnumSet types, |
53 const base::TimeTicks& time) { | 53 const base::TimeTicks& time) { |
54 for (syncable::ModelTypeSet::const_iterator it = types.begin(); | 54 for (syncable::ModelEnumSet::Iterator it = types.First(); |
55 it != types.end(); | 55 it.Good(); it.Inc()) { |
56 ++it) { | 56 unthrottle_times_[it.Get()] = time; |
57 unthrottle_times_[*it] = time; | |
58 } | 57 } |
59 } | 58 } |
60 | 59 |
61 void SyncSessionContext::PruneUnthrottledTypes(const base::TimeTicks& time) { | 60 void SyncSessionContext::PruneUnthrottledTypes(const base::TimeTicks& time) { |
62 UnthrottleTimes::iterator it = unthrottle_times_.begin(); | 61 UnthrottleTimes::iterator it = unthrottle_times_.begin(); |
63 while (it != unthrottle_times_.end()) { | 62 while (it != unthrottle_times_.end()) { |
64 if (it->second <= time) { | 63 if (it->second <= time) { |
65 // Delete and increment the iterator. | 64 // Delete and increment the iterator. |
66 UnthrottleTimes::iterator iterator_to_delete = it; | 65 UnthrottleTimes::iterator iterator_to_delete = it; |
67 ++it; | 66 ++it; |
68 unthrottle_times_.erase(iterator_to_delete); | 67 unthrottle_times_.erase(iterator_to_delete); |
69 } else { | 68 } else { |
70 // Just increment the iterator. | 69 // Just increment the iterator. |
71 ++it; | 70 ++it; |
72 } | 71 } |
73 } | 72 } |
74 } | 73 } |
75 | 74 |
76 // 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 |
77 // so it could be shown in the about:sync page. | 76 // so it could be shown in the about:sync page. |
78 syncable::ModelTypeSet SyncSessionContext::GetThrottledTypes() const { | 77 syncable::ModelEnumSet SyncSessionContext::GetThrottledTypes() const { |
79 syncable::ModelTypeSet types; | 78 syncable::ModelEnumSet types; |
80 for (UnthrottleTimes::const_iterator it = unthrottle_times_.begin(); | 79 for (UnthrottleTimes::const_iterator it = unthrottle_times_.begin(); |
81 it != unthrottle_times_.end(); | 80 it != unthrottle_times_.end(); |
82 ++it) { | 81 ++it) { |
83 types.insert(it->first); | 82 types.Put(it->first); |
84 } | 83 } |
85 return types; | 84 return types; |
86 } | 85 } |
87 | 86 |
88 } // namespace sessions | 87 } // namespace sessions |
89 } // namespace browser_sync | 88 } // namespace browser_sync |
OLD | NEW |