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 syncer::TrafficRecorder* traffic_recorder, |
| 61 bool keystore_encryption_enabled); |
61 ~SyncSessionContext(); | 62 ~SyncSessionContext(); |
62 | 63 |
63 ConflictResolver* resolver() { return resolver_; } | 64 ConflictResolver* resolver() { return resolver_; } |
64 ServerConnectionManager* connection_manager() { | 65 ServerConnectionManager* connection_manager() { |
65 return connection_manager_; | 66 return connection_manager_; |
66 } | 67 } |
67 syncable::Directory* directory() { | 68 syncable::Directory* directory() { |
68 return directory_; | 69 return directory_; |
69 } | 70 } |
70 | 71 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 | 113 |
113 void NotifyListeners(const SyncEngineEvent& event) { | 114 void NotifyListeners(const SyncEngineEvent& event) { |
114 FOR_EACH_OBSERVER(SyncEngineEventListener, listeners_, | 115 FOR_EACH_OBSERVER(SyncEngineEventListener, listeners_, |
115 OnSyncEngineEvent(event)); | 116 OnSyncEngineEvent(event)); |
116 } | 117 } |
117 | 118 |
118 syncer::TrafficRecorder* traffic_recorder() { | 119 syncer::TrafficRecorder* traffic_recorder() { |
119 return traffic_recorder_; | 120 return traffic_recorder_; |
120 } | 121 } |
121 | 122 |
| 123 bool keystore_encryption_enabled() const { |
| 124 return keystore_encryption_enabled_; |
| 125 } |
| 126 |
122 private: | 127 private: |
123 // Rather than force clients to set and null-out various context members, we | 128 // Rather than force clients to set and null-out various context members, we |
124 // extend our encapsulation boundary to scoped helpers that take care of this | 129 // extend our encapsulation boundary to scoped helpers that take care of this |
125 // once they are allocated. See definitions of these below. | 130 // once they are allocated. See definitions of these below. |
126 friend class ScopedSessionContextConflictResolver; | 131 friend class ScopedSessionContextConflictResolver; |
127 friend class TestScopedSessionEventListener; | 132 friend class TestScopedSessionEventListener; |
128 | 133 |
129 // This is installed by Syncer objects when needed and may be NULL. | 134 // This is installed by Syncer objects when needed and may be NULL. |
130 ConflictResolver* resolver_; | 135 ConflictResolver* resolver_; |
131 | 136 |
(...skipping 24 matching lines...) Expand all Loading... |
156 int max_commit_batch_size_; | 161 int max_commit_batch_size_; |
157 | 162 |
158 ThrottledDataTypeTracker* throttled_data_type_tracker_; | 163 ThrottledDataTypeTracker* throttled_data_type_tracker_; |
159 | 164 |
160 // We use this to get debug info to send to the server for debugging | 165 // We use this to get debug info to send to the server for debugging |
161 // client behavior on server side. | 166 // client behavior on server side. |
162 DebugInfoGetter* const debug_info_getter_; | 167 DebugInfoGetter* const debug_info_getter_; |
163 | 168 |
164 syncer::TrafficRecorder* traffic_recorder_; | 169 syncer::TrafficRecorder* traffic_recorder_; |
165 | 170 |
| 171 // Temporary variable while keystore encryption is behind a flag. True if |
| 172 // we should attempt performing keystore encryption related work, false if |
| 173 // the experiment is not enabled. |
| 174 bool keystore_encryption_enabled_; |
| 175 |
166 DISALLOW_COPY_AND_ASSIGN(SyncSessionContext); | 176 DISALLOW_COPY_AND_ASSIGN(SyncSessionContext); |
167 }; | 177 }; |
168 | 178 |
169 // Installs a ConflictResolver to a given session context for the lifetime of | 179 // Installs a ConflictResolver to a given session context for the lifetime of |
170 // the ScopedSessionContextConflictResolver. There should never be more than | 180 // the ScopedSessionContextConflictResolver. There should never be more than |
171 // one ConflictResolver in the system, so it is an error to use this if the | 181 // one ConflictResolver in the system, so it is an error to use this if the |
172 // context already has a resolver. | 182 // context already has a resolver. |
173 class ScopedSessionContextConflictResolver { | 183 class ScopedSessionContextConflictResolver { |
174 public: | 184 public: |
175 // Note: |context| and |resolver| should outlive |this|. | 185 // Note: |context| and |resolver| should outlive |this|. |
(...skipping 10 matching lines...) Expand all Loading... |
186 private: | 196 private: |
187 SyncSessionContext* context_; | 197 SyncSessionContext* context_; |
188 ConflictResolver* resolver_; | 198 ConflictResolver* resolver_; |
189 DISALLOW_COPY_AND_ASSIGN(ScopedSessionContextConflictResolver); | 199 DISALLOW_COPY_AND_ASSIGN(ScopedSessionContextConflictResolver); |
190 }; | 200 }; |
191 | 201 |
192 } // namespace sessions | 202 } // namespace sessions |
193 } // namespace syncer | 203 } // namespace syncer |
194 | 204 |
195 #endif // SYNC_SESSIONS_SYNC_SESSION_CONTEXT_H_ | 205 #endif // SYNC_SESSIONS_SYNC_SESSION_CONTEXT_H_ |
OLD | NEW |