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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 const std::string& account_name() { return account_name_; } | 98 const std::string& account_name() { return account_name_; } |
99 | 99 |
100 const ModelSafeRoutingInfo& previous_session_routing_info() const { | 100 const ModelSafeRoutingInfo& previous_session_routing_info() const { |
101 return previous_session_routing_info_; | 101 return previous_session_routing_info_; |
102 } | 102 } |
103 | 103 |
104 void set_previous_session_routing_info(const ModelSafeRoutingInfo& info) { | 104 void set_previous_session_routing_info(const ModelSafeRoutingInfo& info) { |
105 previous_session_routing_info_ = info; | 105 previous_session_routing_info_ = info; |
106 } | 106 } |
107 | 107 |
| 108 sessions::SyncSessionSnapshot* previous_session_snapshot() { |
| 109 return previous_session_snapshot_.get(); |
| 110 } |
| 111 |
| 112 void set_last_snapshot(const SyncSessionSnapshot& snapshot) { |
| 113 previous_session_snapshot_.reset(new SyncSessionSnapshot(snapshot)); |
| 114 } |
| 115 |
108 private: | 116 private: |
109 // Rather than force clients to set and null-out various context members, we | 117 // Rather than force clients to set and null-out various context members, we |
110 // extend our encapsulation boundary to scoped helpers that take care of this | 118 // extend our encapsulation boundary to scoped helpers that take care of this |
111 // once they are allocated. See definitions of these below. | 119 // once they are allocated. See definitions of these below. |
112 friend class ScopedSessionContextConflictResolver; | 120 friend class ScopedSessionContextConflictResolver; |
113 friend class ScopedSessionContextSyncerEventChannel; | 121 friend class ScopedSessionContextSyncerEventChannel; |
114 | 122 |
115 // These are installed by Syncer objects when needed and may be NULL. | 123 // These are installed by Syncer objects when needed and may be NULL. |
116 ConflictResolver* resolver_; | 124 ConflictResolver* resolver_; |
117 SyncerEventChannel* syncer_event_channel_; | 125 SyncerEventChannel* syncer_event_channel_; |
(...skipping 14 matching lines...) Expand all Loading... |
132 // enabled. True only if the notification channel is authorized and open. | 140 // enabled. True only if the notification channel is authorized and open. |
133 bool notifications_enabled_; | 141 bool notifications_enabled_; |
134 | 142 |
135 // The name of the account being synced. | 143 // The name of the account being synced. |
136 std::string account_name_; | 144 std::string account_name_; |
137 | 145 |
138 // Some routing info history to help us clean up types that get disabled | 146 // Some routing info history to help us clean up types that get disabled |
139 // by the user. | 147 // by the user. |
140 ModelSafeRoutingInfo previous_session_routing_info_; | 148 ModelSafeRoutingInfo previous_session_routing_info_; |
141 | 149 |
| 150 // Cache of last session snapshot information. |
| 151 scoped_ptr<sessions::SyncSessionSnapshot> previous_session_snapshot_; |
| 152 |
142 DISALLOW_COPY_AND_ASSIGN(SyncSessionContext); | 153 DISALLOW_COPY_AND_ASSIGN(SyncSessionContext); |
143 }; | 154 }; |
144 | 155 |
145 // Installs a ConflictResolver to a given session context for the lifetime of | 156 // Installs a ConflictResolver to a given session context for the lifetime of |
146 // the ScopedSessionContextConflictResolver. There should never be more than | 157 // the ScopedSessionContextConflictResolver. There should never be more than |
147 // one ConflictResolver in the system, so it is an error to use this if the | 158 // one ConflictResolver in the system, so it is an error to use this if the |
148 // context already has a resolver. | 159 // context already has a resolver. |
149 class ScopedSessionContextConflictResolver { | 160 class ScopedSessionContextConflictResolver { |
150 public: | 161 public: |
151 // Note: |context| and |resolver| should outlive |this|. | 162 // Note: |context| and |resolver| should outlive |this|. |
(...skipping 30 matching lines...) Expand all Loading... |
182 private: | 193 private: |
183 SyncSessionContext* context_; | 194 SyncSessionContext* context_; |
184 SyncerEventChannel* channel_; | 195 SyncerEventChannel* channel_; |
185 DISALLOW_COPY_AND_ASSIGN(ScopedSessionContextSyncerEventChannel); | 196 DISALLOW_COPY_AND_ASSIGN(ScopedSessionContextSyncerEventChannel); |
186 }; | 197 }; |
187 | 198 |
188 } // namespace sessions | 199 } // namespace sessions |
189 } // namespace browser_sync | 200 } // namespace browser_sync |
190 | 201 |
191 #endif // CHROME_BROWSER_SYNC_SESSIONS_SYNC_SESSION_CONTEXT_H_ | 202 #endif // CHROME_BROWSER_SYNC_SESSIONS_SYNC_SESSION_CONTEXT_H_ |
OLD | NEW |