| 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 // SyncSessionContext encapsulates the contextual information and engine |
| 6 // components specific to a SyncSession. Unlike the SyncSession, the context | 6 // components specific to a SyncSession. Unlike the SyncSession, 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 SYNC_SESSIONS_SYNC_SESSION_CONTEXT_H_ | 15 #ifndef COMPONENTS_SYNC_SESSIONS_IMPL_SYNC_SESSION_CONTEXT_H_ |
| 16 #define SYNC_SESSIONS_SYNC_SESSION_CONTEXT_H_ | 16 #define COMPONENTS_SYNC_SESSIONS_IMPL_SYNC_SESSION_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 "sync/base/sync_export.h" | 24 #include "components/sync/base/sync_export.h" |
| 25 #include "sync/engine/sync_engine_event_listener.h" | 25 #include "components/sync/engine_impl/sync_engine_event_listener.h" |
| 26 #include "sync/sessions/debug_info_getter.h" | 26 #include "components/sync/sessions_impl/debug_info_getter.h" |
| 27 #include "sync/sessions/model_type_registry.h" | 27 #include "components/sync/sessions_impl/model_type_registry.h" |
| 28 | 28 |
| 29 namespace syncer { | 29 namespace syncer { |
| 30 | 30 |
| 31 class ExtensionsActivity; | 31 class ExtensionsActivity; |
| 32 class ModelTypeRegistry; | 32 class ModelTypeRegistry; |
| 33 class ServerConnectionManager; | 33 class ServerConnectionManager; |
| 34 | 34 |
| 35 namespace syncable { | 35 namespace syncable { |
| 36 class Directory; | 36 class Directory; |
| 37 } | 37 } |
| 38 | 38 |
| 39 // Default number of items a client can commit in a single message. | 39 // Default number of items a client can commit in a single message. |
| 40 static const int kDefaultMaxCommitBatchSize = 25; | 40 static const int kDefaultMaxCommitBatchSize = 25; |
| 41 | 41 |
| 42 namespace sessions { | 42 namespace sessions { |
| 43 class TestScopedSessionEventListener; | 43 class TestScopedSessionEventListener; |
| 44 | 44 |
| 45 class SYNC_EXPORT SyncSessionContext { | 45 class SYNC_EXPORT SyncSessionContext { |
| 46 public: | 46 public: |
| 47 SyncSessionContext( | 47 SyncSessionContext(ServerConnectionManager* connection_manager, |
| 48 ServerConnectionManager* connection_manager, | 48 syncable::Directory* directory, |
| 49 syncable::Directory* directory, | 49 ExtensionsActivity* extensions_activity, |
| 50 ExtensionsActivity* extensions_activity, | 50 const std::vector<SyncEngineEventListener*>& listeners, |
| 51 const std::vector<SyncEngineEventListener*>& listeners, | 51 DebugInfoGetter* debug_info_getter, |
| 52 DebugInfoGetter* debug_info_getter, | 52 ModelTypeRegistry* model_type_registry, |
| 53 ModelTypeRegistry* model_type_registry, | 53 bool keystore_encryption_enabled, |
| 54 bool keystore_encryption_enabled, | 54 bool client_enabled_pre_commit_update_avoidance, |
| 55 bool client_enabled_pre_commit_update_avoidance, | 55 const std::string& invalidator_client_id); |
| 56 const std::string& invalidator_client_id); | |
| 57 | 56 |
| 58 ~SyncSessionContext(); | 57 ~SyncSessionContext(); |
| 59 | 58 |
| 60 ServerConnectionManager* connection_manager() { | 59 ServerConnectionManager* connection_manager() { return connection_manager_; } |
| 61 return connection_manager_; | 60 syncable::Directory* directory() { return directory_; } |
| 62 } | |
| 63 syncable::Directory* directory() { | |
| 64 return directory_; | |
| 65 } | |
| 66 | 61 |
| 67 ModelTypeSet GetEnabledTypes() const; | 62 ModelTypeSet GetEnabledTypes() const; |
| 68 | 63 |
| 69 void SetRoutingInfo(const ModelSafeRoutingInfo& routing_info); | 64 void SetRoutingInfo(const ModelSafeRoutingInfo& routing_info); |
| 70 | 65 |
| 71 ExtensionsActivity* extensions_activity() { | 66 ExtensionsActivity* extensions_activity() { |
| 72 return extensions_activity_.get(); | 67 return extensions_activity_.get(); |
| 73 } | 68 } |
| 74 | 69 |
| 75 DebugInfoGetter* debug_info_getter() { | 70 DebugInfoGetter* debug_info_getter() { return debug_info_getter_; } |
| 76 return debug_info_getter_; | |
| 77 } | |
| 78 | 71 |
| 79 // Talk notification status. | 72 // Talk notification status. |
| 80 void set_notifications_enabled(bool enabled) { | 73 void set_notifications_enabled(bool enabled) { |
| 81 notifications_enabled_ = enabled; | 74 notifications_enabled_ = enabled; |
| 82 } | 75 } |
| 83 bool notifications_enabled() { return notifications_enabled_; } | 76 bool notifications_enabled() { return notifications_enabled_; } |
| 84 | 77 |
| 85 // Account name, set once a directory has been opened. | 78 // Account name, set once a directory has been opened. |
| 86 void set_account_name(const std::string& name) { | 79 void set_account_name(const std::string& name) { account_name_ = name; } |
| 87 account_name_ = name; | |
| 88 } | |
| 89 const std::string& account_name() const { return account_name_; } | 80 const std::string& account_name() const { return account_name_; } |
| 90 | 81 |
| 91 void set_max_commit_batch_size(int batch_size) { | 82 void set_max_commit_batch_size(int batch_size) { |
| 92 max_commit_batch_size_ = batch_size; | 83 max_commit_batch_size_ = batch_size; |
| 93 } | 84 } |
| 94 int32_t max_commit_batch_size() const { return max_commit_batch_size_; } | 85 int32_t max_commit_batch_size() const { return max_commit_batch_size_; } |
| 95 | 86 |
| 96 base::ObserverList<SyncEngineEventListener>* listeners() { | 87 base::ObserverList<SyncEngineEventListener>* listeners() { |
| 97 return &listeners_; | 88 return &listeners_; |
| 98 } | 89 } |
| 99 | 90 |
| 100 bool keystore_encryption_enabled() const { | 91 bool keystore_encryption_enabled() const { |
| 101 return keystore_encryption_enabled_; | 92 return keystore_encryption_enabled_; |
| 102 } | 93 } |
| 103 | 94 |
| 104 void set_hierarchy_conflict_detected(bool value) { | 95 void set_hierarchy_conflict_detected(bool value) { |
| 105 client_status_.set_hierarchy_conflict_detected(value); | 96 client_status_.set_hierarchy_conflict_detected(value); |
| 106 } | 97 } |
| 107 | 98 |
| 108 const sync_pb::ClientStatus& client_status() const { | 99 const sync_pb::ClientStatus& client_status() const { return client_status_; } |
| 109 return client_status_; | |
| 110 } | |
| 111 | 100 |
| 112 const std::string& invalidator_client_id() const { | 101 const std::string& invalidator_client_id() const { |
| 113 return invalidator_client_id_; | 102 return invalidator_client_id_; |
| 114 } | 103 } |
| 115 | 104 |
| 116 bool ShouldFetchUpdatesBeforeCommit() const { | 105 bool ShouldFetchUpdatesBeforeCommit() const { |
| 117 return !(server_enabled_pre_commit_update_avoidance_ || | 106 return !(server_enabled_pre_commit_update_avoidance_ || |
| 118 client_enabled_pre_commit_update_avoidance_); | 107 client_enabled_pre_commit_update_avoidance_); |
| 119 } | 108 } |
| 120 | 109 |
| 121 void set_server_enabled_pre_commit_update_avoidance(bool value) { | 110 void set_server_enabled_pre_commit_update_avoidance(bool value) { |
| 122 server_enabled_pre_commit_update_avoidance_ = value; | 111 server_enabled_pre_commit_update_avoidance_ = value; |
| 123 } | 112 } |
| 124 | 113 |
| 125 ModelTypeRegistry* model_type_registry() { | 114 ModelTypeRegistry* model_type_registry() { return model_type_registry_; } |
| 126 return model_type_registry_; | |
| 127 } | |
| 128 | 115 |
| 129 bool cookie_jar_mismatch() const { | 116 bool cookie_jar_mismatch() const { return cookie_jar_mismatch_; } |
| 130 return cookie_jar_mismatch_; | |
| 131 } | |
| 132 | 117 |
| 133 void set_cookie_jar_mismatch(bool cookie_jar_mismatch) { | 118 void set_cookie_jar_mismatch(bool cookie_jar_mismatch) { |
| 134 cookie_jar_mismatch_ = cookie_jar_mismatch; | 119 cookie_jar_mismatch_ = cookie_jar_mismatch; |
| 135 } | 120 } |
| 136 | 121 |
| 137 bool cookie_jar_empty() const { return cookie_jar_empty_; } | 122 bool cookie_jar_empty() const { return cookie_jar_empty_; } |
| 138 | 123 |
| 139 void set_cookie_jar_empty(bool empty_jar) { cookie_jar_empty_ = empty_jar; } | 124 void set_cookie_jar_empty(bool empty_jar) { cookie_jar_empty_ = empty_jar; } |
| 140 | 125 |
| 141 private: | 126 private: |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 | 170 |
| 186 // Flag to enable or disable the no pre-commit GetUpdates experiment. When | 171 // Flag to enable or disable the no pre-commit GetUpdates experiment. When |
| 187 // this flag is set to false, the syncer has the option of not performing at | 172 // this flag is set to false, the syncer has the option of not performing at |
| 188 // GetUpdates request when there is nothing to fetch. | 173 // GetUpdates request when there is nothing to fetch. |
| 189 bool server_enabled_pre_commit_update_avoidance_; | 174 bool server_enabled_pre_commit_update_avoidance_; |
| 190 | 175 |
| 191 // If true, indicates that we've been passed a command-line flag to force | 176 // If true, indicates that we've been passed a command-line flag to force |
| 192 // enable the pre-commit update avoidance experiment described above. | 177 // enable the pre-commit update avoidance experiment described above. |
| 193 const bool client_enabled_pre_commit_update_avoidance_; | 178 const bool client_enabled_pre_commit_update_avoidance_; |
| 194 | 179 |
| 195 // Whether the account(s) present in the content area's cookie jar match the | 180 // Whether the account(s) present in the content area's cookie jar match the |
| 196 // chrome account. If multiple accounts are present in the cookie jar, a | 181 // chrome account. If multiple accounts are present in the cookie jar, a |
| 197 // mismatch implies all of them are different from the chrome account. | 182 // mismatch implies all of them are different from the chrome account. |
| 198 bool cookie_jar_mismatch_; | 183 bool cookie_jar_mismatch_; |
| 199 | 184 |
| 200 // If there's a cookie jar mismatch, whether the cookie jar was empty or not. | 185 // If there's a cookie jar mismatch, whether the cookie jar was empty or not. |
| 201 bool cookie_jar_empty_; | 186 bool cookie_jar_empty_; |
| 202 | 187 |
| 203 DISALLOW_COPY_AND_ASSIGN(SyncSessionContext); | 188 DISALLOW_COPY_AND_ASSIGN(SyncSessionContext); |
| 204 }; | 189 }; |
| 205 | 190 |
| 206 } // namespace sessions | 191 } // namespace sessions |
| 207 } // namespace syncer | 192 } // namespace syncer |
| 208 | 193 |
| 209 #endif // SYNC_SESSIONS_SYNC_SESSION_CONTEXT_H_ | 194 #endif // COMPONENTS_SYNC_SESSIONS_IMPL_SYNC_SESSION_CONTEXT_H_ |
| OLD | NEW |