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 | 49 |
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 std::vector<ModelSafeWorker*>& workers, | 54 const std::vector<ModelSafeWorker*>& workers, |
55 ExtensionsActivityMonitor* extensions_activity_monitor, | 55 ExtensionsActivityMonitor* extensions_activity_monitor, |
56 ThrottledDataTypeTracker* throttled_data_type_tracker, | 56 ThrottledDataTypeTracker* throttled_data_type_tracker, |
57 const std::vector<SyncEngineEventListener*>& listeners, | 57 const std::vector<SyncEngineEventListener*>& listeners, |
58 DebugInfoGetter* debug_info_getter, | 58 DebugInfoGetter* debug_info_getter, |
59 TrafficRecorder* traffic_recorder); | 59 TrafficRecorder* traffic_recorder, |
| 60 bool keystore_encryption_enabled); |
| 61 |
60 ~SyncSessionContext(); | 62 ~SyncSessionContext(); |
61 | 63 |
62 ConflictResolver* resolver() { return resolver_; } | 64 ConflictResolver* resolver() { return resolver_; } |
63 ServerConnectionManager* connection_manager() { | 65 ServerConnectionManager* connection_manager() { |
64 return connection_manager_; | 66 return connection_manager_; |
65 } | 67 } |
66 syncable::Directory* directory() { | 68 syncable::Directory* directory() { |
67 return directory_; | 69 return directory_; |
68 } | 70 } |
69 | 71 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 | 113 |
112 void NotifyListeners(const SyncEngineEvent& event) { | 114 void NotifyListeners(const SyncEngineEvent& event) { |
113 FOR_EACH_OBSERVER(SyncEngineEventListener, listeners_, | 115 FOR_EACH_OBSERVER(SyncEngineEventListener, listeners_, |
114 OnSyncEngineEvent(event)); | 116 OnSyncEngineEvent(event)); |
115 } | 117 } |
116 | 118 |
117 TrafficRecorder* traffic_recorder() { | 119 TrafficRecorder* traffic_recorder() { |
118 return traffic_recorder_; | 120 return traffic_recorder_; |
119 } | 121 } |
120 | 122 |
| 123 bool keystore_encryption_enabled() const { |
| 124 return keystore_encryption_enabled_; |
| 125 } |
| 126 |
121 private: | 127 private: |
122 // 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 |
123 // 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 |
124 // once they are allocated. See definitions of these below. | 130 // once they are allocated. See definitions of these below. |
125 friend class ScopedSessionContextConflictResolver; | 131 friend class ScopedSessionContextConflictResolver; |
126 friend class TestScopedSessionEventListener; | 132 friend class TestScopedSessionEventListener; |
127 | 133 |
128 // 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. |
129 ConflictResolver* resolver_; | 135 ConflictResolver* resolver_; |
130 | 136 |
(...skipping 24 matching lines...) Expand all Loading... |
155 int max_commit_batch_size_; | 161 int max_commit_batch_size_; |
156 | 162 |
157 ThrottledDataTypeTracker* throttled_data_type_tracker_; | 163 ThrottledDataTypeTracker* throttled_data_type_tracker_; |
158 | 164 |
159 // 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 |
160 // client behavior on server side. | 166 // client behavior on server side. |
161 DebugInfoGetter* const debug_info_getter_; | 167 DebugInfoGetter* const debug_info_getter_; |
162 | 168 |
163 TrafficRecorder* traffic_recorder_; | 169 TrafficRecorder* traffic_recorder_; |
164 | 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 |
165 DISALLOW_COPY_AND_ASSIGN(SyncSessionContext); | 176 DISALLOW_COPY_AND_ASSIGN(SyncSessionContext); |
166 }; | 177 }; |
167 | 178 |
168 // 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 |
169 // the ScopedSessionContextConflictResolver. There should never be more than | 180 // the ScopedSessionContextConflictResolver. There should never be more than |
170 // 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 |
171 // context already has a resolver. | 182 // context already has a resolver. |
172 class ScopedSessionContextConflictResolver { | 183 class ScopedSessionContextConflictResolver { |
173 public: | 184 public: |
174 // Note: |context| and |resolver| should outlive |this|. | 185 // Note: |context| and |resolver| should outlive |this|. |
(...skipping 10 matching lines...) Expand all Loading... |
185 private: | 196 private: |
186 SyncSessionContext* context_; | 197 SyncSessionContext* context_; |
187 ConflictResolver* resolver_; | 198 ConflictResolver* resolver_; |
188 DISALLOW_COPY_AND_ASSIGN(ScopedSessionContextConflictResolver); | 199 DISALLOW_COPY_AND_ASSIGN(ScopedSessionContextConflictResolver); |
189 }; | 200 }; |
190 | 201 |
191 } // namespace sessions | 202 } // namespace sessions |
192 } // namespace syncer | 203 } // namespace syncer |
193 | 204 |
194 #endif // SYNC_SESSIONS_SYNC_SESSION_CONTEXT_H_ | 205 #endif // SYNC_SESSIONS_SYNC_SESSION_CONTEXT_H_ |
OLD | NEW |