| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // SyncSessionContext encapsulates the contextual information and engine | 5 // SyncSessionContext encapsulates the contextual information and engine |
| 6 // components specific to a SyncSession. A context is accessible via | 6 // components specific to a SyncSession. A context is accessible via |
| 7 // a SyncSession so that session SyncerCommands and parts of the engine have | 7 // a SyncSession so that session SyncerCommands and parts of the engine have |
| 8 // a convenient way to access other parts. In this way it can be thought of as | 8 // a convenient way to access other parts. In this way it can be thought of as |
| 9 // the surrounding environment for the SyncSession. The components of this | 9 // the surrounding environment for the SyncSession. The components of this |
| 10 // environment are either valid or not valid for the entire context lifetime, | 10 // environment are either valid or not valid for the entire context lifetime, |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 struct SyncSessionSnapshot; | 49 struct SyncSessionSnapshot; |
| 50 class TestScopedSessionEventListener; | 50 class TestScopedSessionEventListener; |
| 51 | 51 |
| 52 class SyncSessionContext { | 52 class SyncSessionContext { |
| 53 public: | 53 public: |
| 54 SyncSessionContext(ServerConnectionManager* connection_manager, | 54 SyncSessionContext(ServerConnectionManager* connection_manager, |
| 55 syncable::Directory* directory, | 55 syncable::Directory* directory, |
| 56 ModelSafeWorkerRegistrar* model_safe_worker_registrar, | 56 ModelSafeWorkerRegistrar* model_safe_worker_registrar, |
| 57 ExtensionsActivityMonitor* extensions_activity_monitor, | 57 ExtensionsActivityMonitor* extensions_activity_monitor, |
| 58 const std::vector<SyncEngineEventListener*>& listeners, | 58 const std::vector<SyncEngineEventListener*>& listeners, |
| 59 DebugInfoGetter* debug_info_getter); | 59 DebugInfoGetter* debug_info_getter, |
| 60 browser_sync::TrafficRecorder* traffic_recorder); |
| 60 | 61 |
| 61 // Empty constructor for unit tests. | 62 // Empty constructor for unit tests. |
| 62 SyncSessionContext(); | 63 SyncSessionContext(); |
| 63 virtual ~SyncSessionContext(); | 64 virtual ~SyncSessionContext(); |
| 64 | 65 |
| 65 ConflictResolver* resolver() { return resolver_; } | 66 ConflictResolver* resolver() { return resolver_; } |
| 66 ServerConnectionManager* connection_manager() { | 67 ServerConnectionManager* connection_manager() { |
| 67 return connection_manager_; | 68 return connection_manager_; |
| 68 } | 69 } |
| 69 syncable::Directory* directory() { | 70 syncable::Directory* directory() { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 | 119 |
| 119 // This prunes the |unthrottle_time_| map based on the |time| passed in. This | 120 // This prunes the |unthrottle_time_| map based on the |time| passed in. This |
| 120 // is called by syncer at the SYNCER_BEGIN stage. | 121 // is called by syncer at the SYNCER_BEGIN stage. |
| 121 void PruneUnthrottledTypes(const base::TimeTicks& time); | 122 void PruneUnthrottledTypes(const base::TimeTicks& time); |
| 122 | 123 |
| 123 // This returns the list of currently throttled types. Unless server returns | 124 // This returns the list of currently throttled types. Unless server returns |
| 124 // new throttled types this will remain constant through out the sync cycle. | 125 // new throttled types this will remain constant through out the sync cycle. |
| 125 syncable::ModelTypeSet GetThrottledTypes() const; | 126 syncable::ModelTypeSet GetThrottledTypes() const; |
| 126 | 127 |
| 127 browser_sync::TrafficRecorder* traffic_recorder() { | 128 browser_sync::TrafficRecorder* traffic_recorder() { |
| 128 return &traffic_recorder_; | 129 return traffic_recorder_; |
| 129 } | 130 } |
| 130 | 131 |
| 131 private: | 132 private: |
| 132 typedef std::map<syncable::ModelType, base::TimeTicks> UnthrottleTimes; | 133 typedef std::map<syncable::ModelType, base::TimeTicks> UnthrottleTimes; |
| 133 | 134 |
| 134 FRIEND_TEST_ALL_PREFIXES(SyncSessionContextTest, AddUnthrottleTimeTest); | 135 FRIEND_TEST_ALL_PREFIXES(SyncSessionContextTest, AddUnthrottleTimeTest); |
| 135 FRIEND_TEST_ALL_PREFIXES(SyncSessionContextTest, | 136 FRIEND_TEST_ALL_PREFIXES(SyncSessionContextTest, |
| 136 GetCurrentlyThrottledTypesTest); | 137 GetCurrentlyThrottledTypesTest); |
| 137 | 138 |
| 138 // Rather than force clients to set and null-out various context members, we | 139 // Rather than force clients to set and null-out various context members, we |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 scoped_ptr<sessions::SyncSessionSnapshot> previous_session_snapshot_; | 176 scoped_ptr<sessions::SyncSessionSnapshot> previous_session_snapshot_; |
| 176 | 177 |
| 177 // We use this to get debug info to send to the server for debugging | 178 // We use this to get debug info to send to the server for debugging |
| 178 // client behavior on server side. | 179 // client behavior on server side. |
| 179 DebugInfoGetter* const debug_info_getter_; | 180 DebugInfoGetter* const debug_info_getter_; |
| 180 | 181 |
| 181 // This is a map from throttled data types to the time at which they can be | 182 // This is a map from throttled data types to the time at which they can be |
| 182 // unthrottled. | 183 // unthrottled. |
| 183 UnthrottleTimes unthrottle_times_; | 184 UnthrottleTimes unthrottle_times_; |
| 184 | 185 |
| 185 // TODO(lipalani): Move the creation of this to |SyncManager|. | 186 browser_sync::TrafficRecorder* traffic_recorder_; |
| 186 browser_sync::TrafficRecorder traffic_recorder_; | |
| 187 | 187 |
| 188 DISALLOW_COPY_AND_ASSIGN(SyncSessionContext); | 188 DISALLOW_COPY_AND_ASSIGN(SyncSessionContext); |
| 189 }; | 189 }; |
| 190 | 190 |
| 191 // Installs a ConflictResolver to a given session context for the lifetime of | 191 // Installs a ConflictResolver to a given session context for the lifetime of |
| 192 // the ScopedSessionContextConflictResolver. There should never be more than | 192 // the ScopedSessionContextConflictResolver. There should never be more than |
| 193 // one ConflictResolver in the system, so it is an error to use this if the | 193 // one ConflictResolver in the system, so it is an error to use this if the |
| 194 // context already has a resolver. | 194 // context already has a resolver. |
| 195 class ScopedSessionContextConflictResolver { | 195 class ScopedSessionContextConflictResolver { |
| 196 public: | 196 public: |
| (...skipping 10 matching lines...) Expand all Loading... |
| 207 private: | 207 private: |
| 208 SyncSessionContext* context_; | 208 SyncSessionContext* context_; |
| 209 ConflictResolver* resolver_; | 209 ConflictResolver* resolver_; |
| 210 DISALLOW_COPY_AND_ASSIGN(ScopedSessionContextConflictResolver); | 210 DISALLOW_COPY_AND_ASSIGN(ScopedSessionContextConflictResolver); |
| 211 }; | 211 }; |
| 212 | 212 |
| 213 } // namespace sessions | 213 } // namespace sessions |
| 214 } // namespace browser_sync | 214 } // namespace browser_sync |
| 215 | 215 |
| 216 #endif // SYNC_SESSIONS_SYNC_SESSION_CONTEXT_H_ | 216 #endif // SYNC_SESSIONS_SYNC_SESSION_CONTEXT_H_ |
| OLD | NEW |