| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 class SyncSessionContext { | 50 class SyncSessionContext { |
| 51 public: | 51 public: |
| 52 SyncSessionContext(ServerConnectionManager* connection_manager, | 52 SyncSessionContext(ServerConnectionManager* connection_manager, |
| 53 syncable::Directory* directory, | 53 syncable::Directory* directory, |
| 54 const ModelSafeRoutingInfo& model_safe_routing_info, | 54 const ModelSafeRoutingInfo& model_safe_routing_info, |
| 55 const std::vector<ModelSafeWorker*>& workers, | 55 const std::vector<ModelSafeWorker*>& workers, |
| 56 ExtensionsActivityMonitor* extensions_activity_monitor, | 56 ExtensionsActivityMonitor* extensions_activity_monitor, |
| 57 ThrottledDataTypeTracker* throttled_data_type_tracker, | 57 ThrottledDataTypeTracker* throttled_data_type_tracker, |
| 58 const std::vector<SyncEngineEventListener*>& listeners, | 58 const std::vector<SyncEngineEventListener*>& listeners, |
| 59 DebugInfoGetter* debug_info_getter, | 59 DebugInfoGetter* debug_info_getter, |
| 60 syncer::TrafficRecorder* traffic_recorder); | 60 TrafficRecorder* traffic_recorder); |
| 61 ~SyncSessionContext(); | 61 ~SyncSessionContext(); |
| 62 | 62 |
| 63 ConflictResolver* resolver() { return resolver_; } | 63 ConflictResolver* resolver() { return resolver_; } |
| 64 ServerConnectionManager* connection_manager() { | 64 ServerConnectionManager* connection_manager() { |
| 65 return connection_manager_; | 65 return connection_manager_; |
| 66 } | 66 } |
| 67 syncable::Directory* directory() { | 67 syncable::Directory* directory() { |
| 68 return directory_; | 68 return directory_; |
| 69 } | 69 } |
| 70 | 70 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 | 116 |
| 117 void set_previous_session_routing_info(const ModelSafeRoutingInfo& info) { | 117 void set_previous_session_routing_info(const ModelSafeRoutingInfo& info) { |
| 118 previous_session_routing_info_ = info; | 118 previous_session_routing_info_ = info; |
| 119 } | 119 } |
| 120 | 120 |
| 121 void NotifyListeners(const SyncEngineEvent& event) { | 121 void NotifyListeners(const SyncEngineEvent& event) { |
| 122 FOR_EACH_OBSERVER(SyncEngineEventListener, listeners_, | 122 FOR_EACH_OBSERVER(SyncEngineEventListener, listeners_, |
| 123 OnSyncEngineEvent(event)); | 123 OnSyncEngineEvent(event)); |
| 124 } | 124 } |
| 125 | 125 |
| 126 syncer::TrafficRecorder* traffic_recorder() { | 126 TrafficRecorder* traffic_recorder() { |
| 127 return traffic_recorder_; | 127 return traffic_recorder_; |
| 128 } | 128 } |
| 129 | 129 |
| 130 private: | 130 private: |
| 131 // Rather than force clients to set and null-out various context members, we | 131 // Rather than force clients to set and null-out various context members, we |
| 132 // extend our encapsulation boundary to scoped helpers that take care of this | 132 // extend our encapsulation boundary to scoped helpers that take care of this |
| 133 // once they are allocated. See definitions of these below. | 133 // once they are allocated. See definitions of these below. |
| 134 friend class ScopedSessionContextConflictResolver; | 134 friend class ScopedSessionContextConflictResolver; |
| 135 friend class TestScopedSessionEventListener; | 135 friend class TestScopedSessionEventListener; |
| 136 | 136 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 166 // Some routing info history to help us clean up types that get disabled | 166 // Some routing info history to help us clean up types that get disabled |
| 167 // by the user. | 167 // by the user. |
| 168 ModelSafeRoutingInfo previous_session_routing_info_; | 168 ModelSafeRoutingInfo previous_session_routing_info_; |
| 169 | 169 |
| 170 ThrottledDataTypeTracker* throttled_data_type_tracker_; | 170 ThrottledDataTypeTracker* throttled_data_type_tracker_; |
| 171 | 171 |
| 172 // We use this to get debug info to send to the server for debugging | 172 // We use this to get debug info to send to the server for debugging |
| 173 // client behavior on server side. | 173 // client behavior on server side. |
| 174 DebugInfoGetter* const debug_info_getter_; | 174 DebugInfoGetter* const debug_info_getter_; |
| 175 | 175 |
| 176 syncer::TrafficRecorder* traffic_recorder_; | 176 TrafficRecorder* traffic_recorder_; |
| 177 | 177 |
| 178 DISALLOW_COPY_AND_ASSIGN(SyncSessionContext); | 178 DISALLOW_COPY_AND_ASSIGN(SyncSessionContext); |
| 179 }; | 179 }; |
| 180 | 180 |
| 181 // Installs a ConflictResolver to a given session context for the lifetime of | 181 // Installs a ConflictResolver to a given session context for the lifetime of |
| 182 // the ScopedSessionContextConflictResolver. There should never be more than | 182 // the ScopedSessionContextConflictResolver. There should never be more than |
| 183 // one ConflictResolver in the system, so it is an error to use this if the | 183 // one ConflictResolver in the system, so it is an error to use this if the |
| 184 // context already has a resolver. | 184 // context already has a resolver. |
| 185 class ScopedSessionContextConflictResolver { | 185 class ScopedSessionContextConflictResolver { |
| 186 public: | 186 public: |
| (...skipping 11 matching lines...) Expand all Loading... |
| 198 private: | 198 private: |
| 199 SyncSessionContext* context_; | 199 SyncSessionContext* context_; |
| 200 ConflictResolver* resolver_; | 200 ConflictResolver* resolver_; |
| 201 DISALLOW_COPY_AND_ASSIGN(ScopedSessionContextConflictResolver); | 201 DISALLOW_COPY_AND_ASSIGN(ScopedSessionContextConflictResolver); |
| 202 }; | 202 }; |
| 203 | 203 |
| 204 } // namespace sessions | 204 } // namespace sessions |
| 205 } // namespace syncer | 205 } // namespace syncer |
| 206 | 206 |
| 207 #endif // SYNC_SESSIONS_SYNC_SESSION_CONTEXT_H_ | 207 #endif // SYNC_SESSIONS_SYNC_SESSION_CONTEXT_H_ |
| OLD | NEW |