| 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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 } | 89 } |
| 90 bool notifications_enabled() { return notifications_enabled_; } | 90 bool notifications_enabled() { return notifications_enabled_; } |
| 91 | 91 |
| 92 // Account name, set once a directory has been opened. | 92 // Account name, set once a directory has been opened. |
| 93 void set_account_name(const std::string name) { | 93 void set_account_name(const std::string name) { |
| 94 DCHECK(account_name_.empty()); | 94 DCHECK(account_name_.empty()); |
| 95 account_name_ = name; | 95 account_name_ = name; |
| 96 } | 96 } |
| 97 const std::string& account_name() { return account_name_; } | 97 const std::string& account_name() { return account_name_; } |
| 98 | 98 |
| 99 const ModelSafeRoutingInfo& previous_session_routing_info() const { |
| 100 return previous_session_routing_info_; |
| 101 } |
| 102 |
| 103 void set_previous_session_routing_info(const ModelSafeRoutingInfo& info) { |
| 104 previous_session_routing_info_ = info; |
| 105 } |
| 106 |
| 99 private: | 107 private: |
| 100 // Rather than force clients to set and null-out various context members, we | 108 // Rather than force clients to set and null-out various context members, we |
| 101 // extend our encapsulation boundary to scoped helpers that take care of this | 109 // extend our encapsulation boundary to scoped helpers that take care of this |
| 102 // once they are allocated. See definitions of these below. | 110 // once they are allocated. See definitions of these below. |
| 103 friend class ScopedSessionContextConflictResolver; | 111 friend class ScopedSessionContextConflictResolver; |
| 104 friend class ScopedSessionContextSyncerEventChannel; | 112 friend class ScopedSessionContextSyncerEventChannel; |
| 105 | 113 |
| 106 // These are installed by Syncer objects when needed and may be NULL. | 114 // These are installed by Syncer objects when needed and may be NULL. |
| 107 ConflictResolver* resolver_; | 115 ConflictResolver* resolver_; |
| 108 SyncerEventChannel* syncer_event_channel_; | 116 SyncerEventChannel* syncer_event_channel_; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 119 // can correlate commit traffic with extension-related bookmark mutations. | 127 // can correlate commit traffic with extension-related bookmark mutations. |
| 120 ExtensionsActivityMonitor* extensions_activity_monitor_; | 128 ExtensionsActivityMonitor* extensions_activity_monitor_; |
| 121 | 129 |
| 122 // Kept up to date with talk events to determine whether notifications are | 130 // Kept up to date with talk events to determine whether notifications are |
| 123 // enabled. True only if the notification channel is authorized and open. | 131 // enabled. True only if the notification channel is authorized and open. |
| 124 bool notifications_enabled_; | 132 bool notifications_enabled_; |
| 125 | 133 |
| 126 // The name of the account being synced. | 134 // The name of the account being synced. |
| 127 std::string account_name_; | 135 std::string account_name_; |
| 128 | 136 |
| 137 // Some routing info history to help us clean up types that get disabled |
| 138 // by the user. |
| 139 ModelSafeRoutingInfo previous_session_routing_info_; |
| 140 |
| 129 DISALLOW_COPY_AND_ASSIGN(SyncSessionContext); | 141 DISALLOW_COPY_AND_ASSIGN(SyncSessionContext); |
| 130 }; | 142 }; |
| 131 | 143 |
| 132 // Installs a ConflictResolver to a given session context for the lifetime of | 144 // Installs a ConflictResolver to a given session context for the lifetime of |
| 133 // the ScopedSessionContextConflictResolver. There should never be more than | 145 // the ScopedSessionContextConflictResolver. There should never be more than |
| 134 // one ConflictResolver in the system, so it is an error to use this if the | 146 // one ConflictResolver in the system, so it is an error to use this if the |
| 135 // context already has a resolver. | 147 // context already has a resolver. |
| 136 class ScopedSessionContextConflictResolver { | 148 class ScopedSessionContextConflictResolver { |
| 137 public: | 149 public: |
| 138 // Note: |context| and |resolver| should outlive |this|. | 150 // Note: |context| and |resolver| should outlive |this|. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 169 private: | 181 private: |
| 170 SyncSessionContext* context_; | 182 SyncSessionContext* context_; |
| 171 SyncerEventChannel* channel_; | 183 SyncerEventChannel* channel_; |
| 172 DISALLOW_COPY_AND_ASSIGN(ScopedSessionContextSyncerEventChannel); | 184 DISALLOW_COPY_AND_ASSIGN(ScopedSessionContextSyncerEventChannel); |
| 173 }; | 185 }; |
| 174 | 186 |
| 175 } // namespace sessions | 187 } // namespace sessions |
| 176 } // namespace browser_sync | 188 } // namespace browser_sync |
| 177 | 189 |
| 178 #endif // CHROME_BROWSER_SYNC_SESSIONS_SYNC_SESSION_CONTEXT_H_ | 190 #endif // CHROME_BROWSER_SYNC_SESSIONS_SYNC_SESSION_CONTEXT_H_ |
| OLD | NEW |