| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 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 | 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 // SyncCycleContext encapsulates the contextual information and engine |
| 6 // components specific to a SyncSession. Unlike the SyncSession, the context | 6 // components specific to a SyncCycle. Unlike the SyncCycle, the context |
| 7 // can be reused across several sync cycles. | 7 // can be reused across several sync cycles. |
| 8 // | 8 // |
| 9 // The context does not take ownership of its pointer members. It's up to | 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 | 10 // the surrounding classes to ensure those members remain valid while the |
| 11 // context is in use. | 11 // context is in use. |
| 12 // | 12 // |
| 13 // It can only be used from the SyncerThread. | 13 // It can only be used from the SyncerThread. |
| 14 | 14 |
| 15 #ifndef COMPONENTS_SYNC_SESSIONS_IMPL_SYNC_SESSION_CONTEXT_H_ | 15 #ifndef COMPONENTS_SYNC_ENGINE_IMPL_CYCLE_SYNC_CYCLE_CONTEXT_H_ |
| 16 #define COMPONENTS_SYNC_SESSIONS_IMPL_SYNC_SESSION_CONTEXT_H_ | 16 #define COMPONENTS_SYNC_ENGINE_IMPL_CYCLE_SYNC_CYCLE_CONTEXT_H_ |
| 17 | 17 |
| 18 #include <stdint.h> | 18 #include <stdint.h> |
| 19 | 19 |
| 20 #include <string> | 20 #include <string> |
| 21 #include <vector> | 21 #include <vector> |
| 22 | 22 |
| 23 #include "base/macros.h" | 23 #include "base/macros.h" |
| 24 #include "components/sync/engine_impl/cycle/debug_info_getter.h" |
| 24 #include "components/sync/engine_impl/model_type_registry.h" | 25 #include "components/sync/engine_impl/model_type_registry.h" |
| 25 #include "components/sync/engine_impl/sync_engine_event_listener.h" | 26 #include "components/sync/engine_impl/sync_engine_event_listener.h" |
| 26 #include "components/sync/sessions_impl/debug_info_getter.h" | |
| 27 | 27 |
| 28 namespace syncer { | 28 namespace syncer { |
| 29 | 29 |
| 30 class ExtensionsActivity; | 30 class ExtensionsActivity; |
| 31 class ModelTypeRegistry; | 31 class ModelTypeRegistry; |
| 32 class ServerConnectionManager; | 32 class ServerConnectionManager; |
| 33 | 33 |
| 34 namespace syncable { | 34 namespace syncable { |
| 35 class Directory; | 35 class Directory; |
| 36 } | 36 } |
| 37 | 37 |
| 38 // Default number of items a client can commit in a single message. | 38 // Default number of items a client can commit in a single message. |
| 39 static const int kDefaultMaxCommitBatchSize = 25; | 39 static const int kDefaultMaxCommitBatchSize = 25; |
| 40 | 40 |
| 41 namespace sessions { | 41 class SyncCycleContext { |
| 42 class TestScopedSessionEventListener; | 42 public: |
| 43 SyncCycleContext(ServerConnectionManager* connection_manager, |
| 44 syncable::Directory* directory, |
| 45 ExtensionsActivity* extensions_activity, |
| 46 const std::vector<SyncEngineEventListener*>& listeners, |
| 47 DebugInfoGetter* debug_info_getter, |
| 48 ModelTypeRegistry* model_type_registry, |
| 49 bool keystore_encryption_enabled, |
| 50 bool client_enabled_pre_commit_update_avoidance, |
| 51 const std::string& invalidator_client_id); |
| 43 | 52 |
| 44 class SyncSessionContext { | 53 ~SyncCycleContext(); |
| 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 | 54 |
| 58 ServerConnectionManager* connection_manager() { return connection_manager_; } | 55 ServerConnectionManager* connection_manager() { return connection_manager_; } |
| 59 syncable::Directory* directory() { return directory_; } | 56 syncable::Directory* directory() { return directory_; } |
| 60 | 57 |
| 61 ModelTypeSet GetEnabledTypes() const; | 58 ModelTypeSet GetEnabledTypes() const; |
| 62 | 59 |
| 63 void SetRoutingInfo(const ModelSafeRoutingInfo& routing_info); | 60 void SetRoutingInfo(const ModelSafeRoutingInfo& routing_info); |
| 64 | 61 |
| 65 ExtensionsActivity* extensions_activity() { | 62 ExtensionsActivity* extensions_activity() { |
| 66 return extensions_activity_.get(); | 63 return extensions_activity_.get(); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 | 113 |
| 117 void set_cookie_jar_mismatch(bool cookie_jar_mismatch) { | 114 void set_cookie_jar_mismatch(bool cookie_jar_mismatch) { |
| 118 cookie_jar_mismatch_ = cookie_jar_mismatch; | 115 cookie_jar_mismatch_ = cookie_jar_mismatch; |
| 119 } | 116 } |
| 120 | 117 |
| 121 bool cookie_jar_empty() const { return cookie_jar_empty_; } | 118 bool cookie_jar_empty() const { return cookie_jar_empty_; } |
| 122 | 119 |
| 123 void set_cookie_jar_empty(bool empty_jar) { cookie_jar_empty_ = empty_jar; } | 120 void set_cookie_jar_empty(bool empty_jar) { cookie_jar_empty_ = empty_jar; } |
| 124 | 121 |
| 125 private: | 122 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_; | 123 base::ObserverList<SyncEngineEventListener> listeners_; |
| 132 | 124 |
| 133 ServerConnectionManager* const connection_manager_; | 125 ServerConnectionManager* const connection_manager_; |
| 134 syncable::Directory* const directory_; | 126 syncable::Directory* const directory_; |
| 135 | 127 |
| 136 // We use this to stuff extensions activity into CommitMessages so the server | 128 // We use this to stuff extensions activity into CommitMessages so the server |
| 137 // can correlate commit traffic with extension-related bookmark mutations. | 129 // can correlate commit traffic with extension-related bookmark mutations. |
| 138 scoped_refptr<ExtensionsActivity> extensions_activity_; | 130 scoped_refptr<ExtensionsActivity> extensions_activity_; |
| 139 | 131 |
| 140 // Kept up to date with talk events to determine whether notifications are | 132 // Kept up to date with talk events to determine whether notifications are |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 const bool client_enabled_pre_commit_update_avoidance_; | 169 const bool client_enabled_pre_commit_update_avoidance_; |
| 178 | 170 |
| 179 // Whether the account(s) present in the content area's cookie jar match the | 171 // 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 | 172 // chrome account. If multiple accounts are present in the cookie jar, a |
| 181 // mismatch implies all of them are different from the chrome account. | 173 // mismatch implies all of them are different from the chrome account. |
| 182 bool cookie_jar_mismatch_; | 174 bool cookie_jar_mismatch_; |
| 183 | 175 |
| 184 // If there's a cookie jar mismatch, whether the cookie jar was empty or not. | 176 // If there's a cookie jar mismatch, whether the cookie jar was empty or not. |
| 185 bool cookie_jar_empty_; | 177 bool cookie_jar_empty_; |
| 186 | 178 |
| 187 DISALLOW_COPY_AND_ASSIGN(SyncSessionContext); | 179 DISALLOW_COPY_AND_ASSIGN(SyncCycleContext); |
| 188 }; | 180 }; |
| 189 | 181 |
| 190 } // namespace sessions | |
| 191 } // namespace syncer | 182 } // namespace syncer |
| 192 | 183 |
| 193 #endif // COMPONENTS_SYNC_SESSIONS_IMPL_SYNC_SESSION_CONTEXT_H_ | 184 #endif // COMPONENTS_SYNC_ENGINE_IMPL_CYCLE_SYNC_CYCLE_CONTEXT_H_ |
| OLD | NEW |