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, |
11 // or they are valid for explicitly scoped periods of time by using Scoped | 11 // or they are valid for explicitly scoped periods of time by using Scoped |
12 // installation utilities found below. This means that the context assumes no | 12 // installation utilities found below. This means that the context assumes no |
13 // ownership whatsoever of any object that was not created by the context | 13 // ownership whatsoever of any object that was not created by the context |
14 // itself. | 14 // itself. |
15 // | 15 // |
16 // It can only be used from the SyncerThread. | 16 // It can only be used from the SyncerThread. |
17 | 17 |
18 #ifndef SYNC_SESSIONS_SYNC_SESSION_CONTEXT_H_ | 18 #ifndef SYNC_SESSIONS_SYNC_SESSION_CONTEXT_H_ |
19 #define SYNC_SESSIONS_SYNC_SESSION_CONTEXT_H_ | 19 #define SYNC_SESSIONS_SYNC_SESSION_CONTEXT_H_ |
20 #pragma once | 20 #pragma once |
21 | 21 |
22 #include <map> | 22 #include <map> |
23 #include <string> | 23 #include <string> |
| 24 #include <vector> |
24 | 25 |
25 #include "base/gtest_prod_util.h" | 26 #include "base/gtest_prod_util.h" |
26 #include "base/memory/scoped_ptr.h" | |
27 #include "base/time.h" | 27 #include "base/time.h" |
28 #include "sync/engine/model_safe_worker.h" | 28 #include "sync/engine/model_safe_worker.h" |
29 #include "sync/engine/syncer_types.h" | 29 #include "sync/engine/syncer_types.h" |
30 #include "sync/engine/sync_engine_event.h" | 30 #include "sync/engine/sync_engine_event.h" |
31 #include "sync/engine/traffic_recorder.h" | 31 #include "sync/engine/traffic_recorder.h" |
32 #include "sync/sessions/debug_info_getter.h" | 32 #include "sync/sessions/debug_info_getter.h" |
33 | 33 |
34 namespace syncable { | 34 namespace syncable { |
35 class Directory; | 35 class Directory; |
36 } | 36 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 return debug_info_getter_; | 82 return debug_info_getter_; |
83 } | 83 } |
84 | 84 |
85 // Talk notification status. | 85 // Talk notification status. |
86 void set_notifications_enabled(bool enabled) { | 86 void set_notifications_enabled(bool enabled) { |
87 notifications_enabled_ = enabled; | 87 notifications_enabled_ = enabled; |
88 } | 88 } |
89 bool notifications_enabled() { return notifications_enabled_; } | 89 bool notifications_enabled() { return notifications_enabled_; } |
90 | 90 |
91 // Account name, set once a directory has been opened. | 91 // Account name, set once a directory has been opened. |
92 void set_account_name(const std::string name) { | 92 void set_account_name(const std::string& name) { |
93 DCHECK(account_name_.empty()); | 93 DCHECK(account_name_.empty()); |
94 account_name_ = name; | 94 account_name_ = name; |
95 } | 95 } |
96 const std::string& account_name() const { return account_name_; } | 96 const std::string& account_name() const { return account_name_; } |
97 | 97 |
98 void set_max_commit_batch_size(int batch_size) { | 98 void set_max_commit_batch_size(int batch_size) { |
99 max_commit_batch_size_ = batch_size; | 99 max_commit_batch_size_ = batch_size; |
100 } | 100 } |
101 int32 max_commit_batch_size() const { return max_commit_batch_size_; } | 101 int32 max_commit_batch_size() const { return max_commit_batch_size_; } |
102 | 102 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 public: | 193 public: |
194 // Note: |context| and |resolver| should outlive |this|. | 194 // Note: |context| and |resolver| should outlive |this|. |
195 ScopedSessionContextConflictResolver(SyncSessionContext* context, | 195 ScopedSessionContextConflictResolver(SyncSessionContext* context, |
196 ConflictResolver* resolver) | 196 ConflictResolver* resolver) |
197 : context_(context), resolver_(resolver) { | 197 : context_(context), resolver_(resolver) { |
198 DCHECK(NULL == context->resolver_); | 198 DCHECK(NULL == context->resolver_); |
199 context->resolver_ = resolver; | 199 context->resolver_ = resolver; |
200 } | 200 } |
201 ~ScopedSessionContextConflictResolver() { | 201 ~ScopedSessionContextConflictResolver() { |
202 context_->resolver_ = NULL; | 202 context_->resolver_ = NULL; |
203 } | 203 } |
| 204 |
204 private: | 205 private: |
205 SyncSessionContext* context_; | 206 SyncSessionContext* context_; |
206 ConflictResolver* resolver_; | 207 ConflictResolver* resolver_; |
207 DISALLOW_COPY_AND_ASSIGN(ScopedSessionContextConflictResolver); | 208 DISALLOW_COPY_AND_ASSIGN(ScopedSessionContextConflictResolver); |
208 }; | 209 }; |
209 | 210 |
210 } // namespace sessions | 211 } // namespace sessions |
211 } // namespace browser_sync | 212 } // namespace browser_sync |
212 | 213 |
213 #endif // SYNC_SESSIONS_SYNC_SESSION_CONTEXT_H_ | 214 #endif // SYNC_SESSIONS_SYNC_SESSION_CONTEXT_H_ |
OLD | NEW |