| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 13 matching lines...) Expand all Loading... |
| 24 #include "chrome/browser/sync/engine/model_safe_worker.h" | 24 #include "chrome/browser/sync/engine/model_safe_worker.h" |
| 25 #include "chrome/browser/sync/engine/syncer_types.h" | 25 #include "chrome/browser/sync/engine/syncer_types.h" |
| 26 #include "chrome/browser/sync/util/extensions_activity_monitor.h" | 26 #include "chrome/browser/sync/util/extensions_activity_monitor.h" |
| 27 | 27 |
| 28 namespace syncable { | 28 namespace syncable { |
| 29 class DirectoryManager; | 29 class DirectoryManager; |
| 30 } | 30 } |
| 31 | 31 |
| 32 namespace browser_sync { | 32 namespace browser_sync { |
| 33 | 33 |
| 34 class AuthWatcher; | |
| 35 class ConflictResolver; | 34 class ConflictResolver; |
| 36 class ModelSafeWorkerRegistrar; | 35 class ModelSafeWorkerRegistrar; |
| 37 class ServerConnectionManager; | 36 class ServerConnectionManager; |
| 38 | 37 |
| 39 namespace sessions { | 38 namespace sessions { |
| 40 class ScopedSessionContextConflictResolver; | 39 class ScopedSessionContextConflictResolver; |
| 41 class ScopedSessionContextSyncerEventChannel; | 40 class ScopedSessionContextSyncerEventChannel; |
| 42 | 41 |
| 43 class SyncSessionContext { | 42 class SyncSessionContext { |
| 44 public: | 43 public: |
| 45 SyncSessionContext(ServerConnectionManager* connection_manager, | 44 SyncSessionContext(ServerConnectionManager* connection_manager, |
| 46 AuthWatcher* auth_watcher, | |
| 47 syncable::DirectoryManager* directory_manager, | 45 syncable::DirectoryManager* directory_manager, |
| 48 ModelSafeWorkerRegistrar* model_safe_worker_registrar) | 46 ModelSafeWorkerRegistrar* model_safe_worker_registrar) |
| 49 : resolver_(NULL), | 47 : resolver_(NULL), |
| 50 syncer_event_channel_(NULL), | 48 syncer_event_channel_(NULL), |
| 51 connection_manager_(connection_manager), | 49 connection_manager_(connection_manager), |
| 52 auth_watcher_(auth_watcher), | |
| 53 directory_manager_(directory_manager), | 50 directory_manager_(directory_manager), |
| 54 registrar_(model_safe_worker_registrar), | 51 registrar_(model_safe_worker_registrar), |
| 55 extensions_activity_monitor_(new ExtensionsActivityMonitor()), | 52 extensions_activity_monitor_(new ExtensionsActivityMonitor()), |
| 56 notifications_enabled_(false) { | 53 notifications_enabled_(false) { |
| 57 } | 54 } |
| 58 | 55 |
| 59 ~SyncSessionContext() { | 56 ~SyncSessionContext() { |
| 60 // In unittests, there may be no UI thread, so the above will fail. | 57 // In unittests, there may be no UI thread, so the above will fail. |
| 61 if (!ChromeThread::DeleteSoon(ChromeThread::UI, FROM_HERE, | 58 if (!ChromeThread::DeleteSoon(ChromeThread::UI, FROM_HERE, |
| 62 extensions_activity_monitor_)) { | 59 extensions_activity_monitor_)) { |
| 63 delete extensions_activity_monitor_; | 60 delete extensions_activity_monitor_; |
| 64 } | 61 } |
| 65 } | 62 } |
| 66 | 63 |
| 67 ConflictResolver* resolver() { return resolver_; } | 64 ConflictResolver* resolver() { return resolver_; } |
| 68 ServerConnectionManager* connection_manager() { | 65 ServerConnectionManager* connection_manager() { |
| 69 return connection_manager_; | 66 return connection_manager_; |
| 70 } | 67 } |
| 71 AuthWatcher* auth_watcher() { | |
| 72 return auth_watcher_; | |
| 73 } | |
| 74 syncable::DirectoryManager* directory_manager() { | 68 syncable::DirectoryManager* directory_manager() { |
| 75 return directory_manager_; | 69 return directory_manager_; |
| 76 } | 70 } |
| 77 SyncerEventChannel* syncer_event_channel() { | 71 SyncerEventChannel* syncer_event_channel() { |
| 78 return syncer_event_channel_; | 72 return syncer_event_channel_; |
| 79 } | 73 } |
| 80 ModelSafeWorkerRegistrar* registrar() { | 74 ModelSafeWorkerRegistrar* registrar() { |
| 81 return registrar_; | 75 return registrar_; |
| 82 } | 76 } |
| 83 ExtensionsActivityMonitor* extensions_monitor() { | 77 ExtensionsActivityMonitor* extensions_monitor() { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 // extend our encapsulation boundary to scoped helpers that take care of this | 112 // extend our encapsulation boundary to scoped helpers that take care of this |
| 119 // once they are allocated. See definitions of these below. | 113 // once they are allocated. See definitions of these below. |
| 120 friend class ScopedSessionContextConflictResolver; | 114 friend class ScopedSessionContextConflictResolver; |
| 121 friend class ScopedSessionContextSyncerEventChannel; | 115 friend class ScopedSessionContextSyncerEventChannel; |
| 122 | 116 |
| 123 // These are installed by Syncer objects when needed and may be NULL. | 117 // These are installed by Syncer objects when needed and may be NULL. |
| 124 ConflictResolver* resolver_; | 118 ConflictResolver* resolver_; |
| 125 SyncerEventChannel* syncer_event_channel_; | 119 SyncerEventChannel* syncer_event_channel_; |
| 126 | 120 |
| 127 ServerConnectionManager* const connection_manager_; | 121 ServerConnectionManager* const connection_manager_; |
| 128 AuthWatcher* const auth_watcher_; | |
| 129 syncable::DirectoryManager* const directory_manager_; | 122 syncable::DirectoryManager* const directory_manager_; |
| 130 | 123 |
| 131 // A registrar of workers capable of processing work closures on a thread | 124 // A registrar of workers capable of processing work closures on a thread |
| 132 // that is guaranteed to be safe for model modifications. | 125 // that is guaranteed to be safe for model modifications. |
| 133 ModelSafeWorkerRegistrar* registrar_; | 126 ModelSafeWorkerRegistrar* registrar_; |
| 134 | 127 |
| 135 // We use this to stuff extensions activity into CommitMessages so the server | 128 // We use this to stuff extensions activity into CommitMessages so the server |
| 136 // can correlate commit traffic with extension-related bookmark mutations. | 129 // can correlate commit traffic with extension-related bookmark mutations. |
| 137 ExtensionsActivityMonitor* extensions_activity_monitor_; | 130 ExtensionsActivityMonitor* extensions_activity_monitor_; |
| 138 | 131 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 private: | 186 private: |
| 194 SyncSessionContext* context_; | 187 SyncSessionContext* context_; |
| 195 SyncerEventChannel* channel_; | 188 SyncerEventChannel* channel_; |
| 196 DISALLOW_COPY_AND_ASSIGN(ScopedSessionContextSyncerEventChannel); | 189 DISALLOW_COPY_AND_ASSIGN(ScopedSessionContextSyncerEventChannel); |
| 197 }; | 190 }; |
| 198 | 191 |
| 199 } // namespace sessions | 192 } // namespace sessions |
| 200 } // namespace browser_sync | 193 } // namespace browser_sync |
| 201 | 194 |
| 202 #endif // CHROME_BROWSER_SYNC_SESSIONS_SYNC_SESSION_CONTEXT_H_ | 195 #endif // CHROME_BROWSER_SYNC_SESSIONS_SYNC_SESSION_CONTEXT_H_ |
| OLD | NEW |