| 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/syncer_types.h" | 24 #include "chrome/browser/sync/engine/syncer_types.h" |
| 25 #include "chrome/browser/sync/util/extensions_activity_monitor.h" | 25 #include "chrome/browser/sync/util/extensions_activity_monitor.h" |
| 26 | 26 |
| 27 namespace syncable { | 27 namespace syncable { |
| 28 class DirectoryManager; | 28 class DirectoryManager; |
| 29 } | 29 } |
| 30 | 30 |
| 31 namespace browser_sync { | 31 namespace browser_sync { |
| 32 | 32 |
| 33 class ConflictResolver; | 33 class ConflictResolver; |
| 34 class ModelSafeWorkerRegistrar; |
| 34 class ServerConnectionManager; | 35 class ServerConnectionManager; |
| 35 | 36 |
| 36 namespace sessions { | 37 namespace sessions { |
| 37 class ScopedSessionContextConflictResolver; | 38 class ScopedSessionContextConflictResolver; |
| 38 class ScopedSessionContextSyncerEventChannel; | 39 class ScopedSessionContextSyncerEventChannel; |
| 39 | 40 |
| 40 class SyncSessionContext { | 41 class SyncSessionContext { |
| 41 public: | 42 public: |
| 42 SyncSessionContext(ServerConnectionManager* connection_manager, | 43 SyncSessionContext(ServerConnectionManager* connection_manager, |
| 43 syncable::DirectoryManager* directory_manager, | 44 syncable::DirectoryManager* directory_manager, |
| 44 ModelSafeWorker* model_safe_worker) | 45 ModelSafeWorkerRegistrar* model_safe_worker_registrar) |
| 45 : resolver_(NULL), | 46 : resolver_(NULL), |
| 46 syncer_event_channel_(NULL), | 47 syncer_event_channel_(NULL), |
| 47 connection_manager_(connection_manager), | 48 connection_manager_(connection_manager), |
| 48 directory_manager_(directory_manager), | 49 directory_manager_(directory_manager), |
| 49 model_safe_worker_(model_safe_worker), | 50 registrar_(model_safe_worker_registrar), |
| 50 extensions_activity_monitor_(new ExtensionsActivityMonitor()), | 51 extensions_activity_monitor_(new ExtensionsActivityMonitor()), |
| 51 notifications_enabled_(false) { | 52 notifications_enabled_(false) { |
| 52 } | 53 } |
| 53 | 54 |
| 54 ~SyncSessionContext() { | 55 ~SyncSessionContext() { |
| 55 // In unittests, there may be no UI thread, so the above will fail. | 56 // In unittests, there may be no UI thread, so the above will fail. |
| 56 if (!ChromeThread::DeleteSoon(ChromeThread::UI, FROM_HERE, | 57 if (!ChromeThread::DeleteSoon(ChromeThread::UI, FROM_HERE, |
| 57 extensions_activity_monitor_)) { | 58 extensions_activity_monitor_)) { |
| 58 delete extensions_activity_monitor_; | 59 delete extensions_activity_monitor_; |
| 59 } | 60 } |
| 60 } | 61 } |
| 61 | 62 |
| 62 ConflictResolver* resolver() { return resolver_; } | 63 ConflictResolver* resolver() { return resolver_; } |
| 63 ServerConnectionManager* connection_manager() { | 64 ServerConnectionManager* connection_manager() { |
| 64 return connection_manager_; | 65 return connection_manager_; |
| 65 } | 66 } |
| 66 syncable::DirectoryManager* directory_manager() { | 67 syncable::DirectoryManager* directory_manager() { |
| 67 return directory_manager_; | 68 return directory_manager_; |
| 68 } | 69 } |
| 69 SyncerEventChannel* syncer_event_channel() { | 70 SyncerEventChannel* syncer_event_channel() { |
| 70 return syncer_event_channel_; | 71 return syncer_event_channel_; |
| 71 } | 72 } |
| 72 ModelSafeWorker* model_safe_worker() { | 73 ModelSafeWorkerRegistrar* registrar() { |
| 73 return model_safe_worker_.get(); | 74 return registrar_; |
| 74 } | 75 } |
| 75 ExtensionsActivityMonitor* extensions_monitor() { | 76 ExtensionsActivityMonitor* extensions_monitor() { |
| 76 return extensions_activity_monitor_; | 77 return extensions_activity_monitor_; |
| 77 } | 78 } |
| 78 | 79 |
| 79 // Talk notification status. | 80 // Talk notification status. |
| 80 void set_notifications_enabled(bool enabled) { | 81 void set_notifications_enabled(bool enabled) { |
| 81 notifications_enabled_ = enabled; | 82 notifications_enabled_ = enabled; |
| 82 } | 83 } |
| 83 bool notifications_enabled() { return notifications_enabled_; } | 84 bool notifications_enabled() { return notifications_enabled_; } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 96 friend class ScopedSessionContextConflictResolver; | 97 friend class ScopedSessionContextConflictResolver; |
| 97 friend class ScopedSessionContextSyncerEventChannel; | 98 friend class ScopedSessionContextSyncerEventChannel; |
| 98 | 99 |
| 99 // These are installed by Syncer objects when needed and may be NULL. | 100 // These are installed by Syncer objects when needed and may be NULL. |
| 100 ConflictResolver* resolver_; | 101 ConflictResolver* resolver_; |
| 101 SyncerEventChannel* syncer_event_channel_; | 102 SyncerEventChannel* syncer_event_channel_; |
| 102 | 103 |
| 103 ServerConnectionManager* const connection_manager_; | 104 ServerConnectionManager* const connection_manager_; |
| 104 syncable::DirectoryManager* const directory_manager_; | 105 syncable::DirectoryManager* const directory_manager_; |
| 105 | 106 |
| 106 // A worker capable of processing work closures on a thread that is | 107 // A registrar of workers capable of processing work closures on a thread |
| 107 // guaranteed to be safe for model modifications. | 108 // that is guaranteed to be safe for model modifications. |
| 108 scoped_ptr<ModelSafeWorker> model_safe_worker_; | 109 ModelSafeWorkerRegistrar* registrar_; |
| 109 | 110 |
| 110 // We use this to stuff extensions activity into CommitMessages so the server | 111 // We use this to stuff extensions activity into CommitMessages so the server |
| 111 // can correlate commit traffic with extension-related bookmark mutations. | 112 // can correlate commit traffic with extension-related bookmark mutations. |
| 112 ExtensionsActivityMonitor* extensions_activity_monitor_; | 113 ExtensionsActivityMonitor* extensions_activity_monitor_; |
| 113 | 114 |
| 114 // Kept up to date with talk events to determine whether notifications are | 115 // Kept up to date with talk events to determine whether notifications are |
| 115 // enabled. True only if the notification channel is authorized and open. | 116 // enabled. True only if the notification channel is authorized and open. |
| 116 bool notifications_enabled_; | 117 bool notifications_enabled_; |
| 117 | 118 |
| 118 // The name of the account being synced. | 119 // The name of the account being synced. |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 private: | 162 private: |
| 162 SyncSessionContext* context_; | 163 SyncSessionContext* context_; |
| 163 SyncerEventChannel* channel_; | 164 SyncerEventChannel* channel_; |
| 164 DISALLOW_COPY_AND_ASSIGN(ScopedSessionContextSyncerEventChannel); | 165 DISALLOW_COPY_AND_ASSIGN(ScopedSessionContextSyncerEventChannel); |
| 165 }; | 166 }; |
| 166 | 167 |
| 167 } // namespace sessions | 168 } // namespace sessions |
| 168 } // namespace browser_sync | 169 } // namespace browser_sync |
| 169 | 170 |
| 170 #endif // CHROME_BROWSER_SYNC_SESSIONS_SYNC_SESSION_CONTEXT_H_ | 171 #endif // CHROME_BROWSER_SYNC_SESSIONS_SYNC_SESSION_CONTEXT_H_ |
| OLD | NEW |