Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(302)

Side by Side Diff: components/sync/sessions_impl/sync_session_context.h

Issue 2258873003: [Sync] Move sessions/ to engine/cycle/ and rename things to match. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // SyncSessionContext encapsulates the contextual information and engine
6 // components specific to a SyncSession. Unlike the SyncSession, the context
7 // can be reused across several sync cycles.
8 //
9 // The context does not take ownership of its pointer members. It's up to
10 // the surrounding classes to ensure those members remain valid while the
11 // context is in use.
12 //
13 // It can only be used from the SyncerThread.
14
15 #ifndef COMPONENTS_SYNC_SESSIONS_IMPL_SYNC_SESSION_CONTEXT_H_
16 #define COMPONENTS_SYNC_SESSIONS_IMPL_SYNC_SESSION_CONTEXT_H_
17
18 #include <stdint.h>
19
20 #include <string>
21 #include <vector>
22
23 #include "base/macros.h"
24 #include "components/sync/engine_impl/model_type_registry.h"
25 #include "components/sync/engine_impl/sync_engine_event_listener.h"
26 #include "components/sync/sessions_impl/debug_info_getter.h"
27
28 namespace syncer {
29
30 class ExtensionsActivity;
31 class ModelTypeRegistry;
32 class ServerConnectionManager;
33
34 namespace syncable {
35 class Directory;
36 }
37
38 // Default number of items a client can commit in a single message.
39 static const int kDefaultMaxCommitBatchSize = 25;
40
41 namespace sessions {
42 class TestScopedSessionEventListener;
43
44 class SyncSessionContext {
45 public:
46 SyncSessionContext(ServerConnectionManager* connection_manager,
47 syncable::Directory* directory,
48 ExtensionsActivity* extensions_activity,
49 const std::vector<SyncEngineEventListener*>& listeners,
50 DebugInfoGetter* debug_info_getter,
51 ModelTypeRegistry* model_type_registry,
52 bool keystore_encryption_enabled,
53 bool client_enabled_pre_commit_update_avoidance,
54 const std::string& invalidator_client_id);
55
56 ~SyncSessionContext();
57
58 ServerConnectionManager* connection_manager() { return connection_manager_; }
59 syncable::Directory* directory() { return directory_; }
60
61 ModelTypeSet GetEnabledTypes() const;
62
63 void SetRoutingInfo(const ModelSafeRoutingInfo& routing_info);
64
65 ExtensionsActivity* extensions_activity() {
66 return extensions_activity_.get();
67 }
68
69 DebugInfoGetter* debug_info_getter() { return debug_info_getter_; }
70
71 // Talk notification status.
72 void set_notifications_enabled(bool enabled) {
73 notifications_enabled_ = enabled;
74 }
75 bool notifications_enabled() { return notifications_enabled_; }
76
77 // Account name, set once a directory has been opened.
78 void set_account_name(const std::string& name) { account_name_ = name; }
79 const std::string& account_name() const { return account_name_; }
80
81 void set_max_commit_batch_size(int batch_size) {
82 max_commit_batch_size_ = batch_size;
83 }
84 int32_t max_commit_batch_size() const { return max_commit_batch_size_; }
85
86 base::ObserverList<SyncEngineEventListener>* listeners() {
87 return &listeners_;
88 }
89
90 bool keystore_encryption_enabled() const {
91 return keystore_encryption_enabled_;
92 }
93
94 void set_hierarchy_conflict_detected(bool value) {
95 client_status_.set_hierarchy_conflict_detected(value);
96 }
97
98 const sync_pb::ClientStatus& client_status() const { return client_status_; }
99
100 const std::string& invalidator_client_id() const {
101 return invalidator_client_id_;
102 }
103
104 bool ShouldFetchUpdatesBeforeCommit() const {
105 return !(server_enabled_pre_commit_update_avoidance_ ||
106 client_enabled_pre_commit_update_avoidance_);
107 }
108
109 void set_server_enabled_pre_commit_update_avoidance(bool value) {
110 server_enabled_pre_commit_update_avoidance_ = value;
111 }
112
113 ModelTypeRegistry* model_type_registry() { return model_type_registry_; }
114
115 bool cookie_jar_mismatch() const { return cookie_jar_mismatch_; }
116
117 void set_cookie_jar_mismatch(bool cookie_jar_mismatch) {
118 cookie_jar_mismatch_ = cookie_jar_mismatch;
119 }
120
121 bool cookie_jar_empty() const { return cookie_jar_empty_; }
122
123 void set_cookie_jar_empty(bool empty_jar) { cookie_jar_empty_ = empty_jar; }
124
125 private:
126 // Rather than force clients to set and null-out various context members, we
127 // extend our encapsulation boundary to scoped helpers that take care of this
128 // once they are allocated. See definitions of these below.
129 friend class TestScopedSessionEventListener;
130
131 base::ObserverList<SyncEngineEventListener> listeners_;
132
133 ServerConnectionManager* const connection_manager_;
134 syncable::Directory* const directory_;
135
136 // We use this to stuff extensions activity into CommitMessages so the server
137 // can correlate commit traffic with extension-related bookmark mutations.
138 scoped_refptr<ExtensionsActivity> extensions_activity_;
139
140 // Kept up to date with talk events to determine whether notifications are
141 // enabled. True only if the notification channel is authorized and open.
142 bool notifications_enabled_;
143
144 // The name of the account being synced.
145 std::string account_name_;
146
147 // The server limits the number of items a client can commit in one batch.
148 int max_commit_batch_size_;
149
150 // We use this to get debug info to send to the server for debugging
151 // client behavior on server side.
152 DebugInfoGetter* const debug_info_getter_;
153
154 ModelTypeRegistry* model_type_registry_;
155
156 // Satus information to be sent up to the server.
157 sync_pb::ClientStatus client_status_;
158
159 // Temporary variable while keystore encryption is behind a flag. True if
160 // we should attempt performing keystore encryption related work, false if
161 // the experiment is not enabled.
162 bool keystore_encryption_enabled_;
163
164 // This is a copy of the identifier the that the invalidations client used to
165 // register itself with the invalidations server during startup. We need to
166 // provide this to the sync server when we make changes to enable it to
167 // prevent us from receiving notifications of changes we make ourselves.
168 const std::string invalidator_client_id_;
169
170 // Flag to enable or disable the no pre-commit GetUpdates experiment. When
171 // this flag is set to false, the syncer has the option of not performing at
172 // GetUpdates request when there is nothing to fetch.
173 bool server_enabled_pre_commit_update_avoidance_;
174
175 // If true, indicates that we've been passed a command-line flag to force
176 // enable the pre-commit update avoidance experiment described above.
177 const bool client_enabled_pre_commit_update_avoidance_;
178
179 // Whether the account(s) present in the content area's cookie jar match the
180 // chrome account. If multiple accounts are present in the cookie jar, a
181 // mismatch implies all of them are different from the chrome account.
182 bool cookie_jar_mismatch_;
183
184 // If there's a cookie jar mismatch, whether the cookie jar was empty or not.
185 bool cookie_jar_empty_;
186
187 DISALLOW_COPY_AND_ASSIGN(SyncSessionContext);
188 };
189
190 } // namespace sessions
191 } // namespace syncer
192
193 #endif // COMPONENTS_SYNC_SESSIONS_IMPL_SYNC_SESSION_CONTEXT_H_
OLDNEW
« no previous file with comments | « components/sync/sessions_impl/sync_session.cc ('k') | components/sync/sessions_impl/sync_session_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698