| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef COMPONENTS_SYNC_DRIVER_SYNC_FRONTEND_H_ | 5 #ifndef COMPONENTS_SYNC_ENGINE_SYNC_ENGINE_HOST_H_ |
| 6 #define COMPONENTS_SYNC_DRIVER_SYNC_FRONTEND_H_ | 6 #define COMPONENTS_SYNC_ENGINE_SYNC_ENGINE_HOST_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "components/sync/base/model_type.h" | 10 #include "components/sync/base/model_type.h" |
| 11 #include "components/sync/base/weak_handle.h" | 11 #include "components/sync/base/weak_handle.h" |
| 12 #include "components/sync/engine/sync_encryption_handler.h" | 12 #include "components/sync/engine/sync_encryption_handler.h" |
| 13 #include "components/sync/engine/sync_manager.h" | 13 #include "components/sync/engine/sync_manager.h" |
| 14 #include "components/sync/protocol/sync_protocol_error.h" | 14 #include "components/sync/protocol/sync_protocol_error.h" |
| 15 | 15 |
| 16 namespace sync_pb { | 16 namespace sync_pb { |
| 17 class EncryptedData; | 17 class EncryptedData; |
| 18 } // namespace sync_pb | 18 } // namespace sync_pb |
| 19 | 19 |
| 20 namespace syncer { | 20 namespace syncer { |
| 21 | 21 |
| 22 class DataTypeDebugInfoListener; | 22 class DataTypeDebugInfoListener; |
| 23 class JsBackend; | 23 class JsBackend; |
| 24 class ProtocolEvent; | 24 class ProtocolEvent; |
| 25 struct CommitCounters; | 25 struct CommitCounters; |
| 26 struct StatusCounters; | 26 struct StatusCounters; |
| 27 struct UpdateCounters; | 27 struct UpdateCounters; |
| 28 | 28 |
| 29 // SyncFrontend is the interface used by SyncBackendHost to communicate with | 29 // SyncEngineHost is the interface used by SyncEngine to communicate with the |
| 30 // the entity that created it and, presumably, is interested in sync-related | 30 // entity that created it. It's essentially an observer interface except the |
| 31 // activity. | 31 // SyncEngine always has exactly one. |
| 32 // NOTE: All methods will be invoked by a SyncBackendHost on the same thread | 32 class SyncEngineHost { |
| 33 // used to create that SyncBackendHost. | |
| 34 class SyncFrontend { | |
| 35 public: | 33 public: |
| 36 SyncFrontend(); | 34 SyncEngineHost(); |
| 37 virtual ~SyncFrontend(); | 35 virtual ~SyncEngineHost(); |
| 38 | 36 |
| 39 // The backend has completed initialization and it is now ready to | 37 // The backend has completed initialization and it is now ready to |
| 40 // accept and process changes. If success is false, initialization | 38 // accept and process changes. If success is false, initialization |
| 41 // wasn't able to be completed and should be retried. | 39 // wasn't able to be completed and should be retried. |
| 42 // | 40 // |
| 43 // |js_backend| is what about:sync interacts with; it's different | 41 // |js_backend| is what about:sync interacts with; it's different |
| 44 // from the 'Backend' in 'OnBackendInitialized' (unfortunately). It | 42 // from the 'Backend' in 'OnBackendInitialized' (unfortunately). It |
| 45 // is initialized only if |success| is true. | 43 // is initialized only if |success| is true. |
| 46 virtual void OnBackendInitialized( | 44 virtual void OnBackendInitialized( |
| 47 const WeakHandle<JsBackend>& js_backend, | 45 const WeakHandle<JsBackend>& js_backend, |
| 48 const WeakHandle<DataTypeDebugInfoListener>& debug_info_listener, | 46 const WeakHandle<DataTypeDebugInfoListener>& debug_info_listener, |
| 49 const std::string& cache_guid, | 47 const std::string& cache_guid, |
| 50 bool success) = 0; | 48 bool success) = 0; |
| 51 | 49 |
| 52 // The backend queried the server recently and received some updates. | 50 // The backend queried the server recently and received some updates. |
| 53 virtual void OnSyncCycleCompleted() = 0; | 51 virtual void OnSyncCycleCompleted() = 0; |
| 54 | 52 |
| 55 // Informs the frontned of some network event. These notifications are | 53 // Informs the host of some network event. These notifications are disabled by |
| 56 // disabled by default and must be enabled through an explicit request to the | 54 // default and must be enabled through an explicit request to the SyncEngine. |
| 57 // SyncBackendHost. | |
| 58 // | 55 // |
| 59 // It's disabld by default to avoid copying data across threads when no one | 56 // It's disabled by default to avoid copying data across threads when no one |
| 60 // is listening for it. | 57 // is listening for it. |
| 61 virtual void OnProtocolEvent(const ProtocolEvent& event) = 0; | 58 virtual void OnProtocolEvent(const ProtocolEvent& event) = 0; |
| 62 | 59 |
| 63 // Called when we receive an updated commit counter for a directory type. | 60 // Called when we receive an updated commit counter for a directory type. |
| 64 // | 61 // |
| 65 // Disabled by default. Enable by calling | 62 // Disabled by default. Enable by calling |
| 66 // EnableDirectoryTypeDebugInfoForwarding() on the backend. | 63 // EnableDirectoryTypeDebugInfoForwarding() on the backend. |
| 67 virtual void OnDirectoryTypeCommitCounterUpdated( | 64 virtual void OnDirectoryTypeCommitCounterUpdated( |
| 68 ModelType type, | 65 ModelType type, |
| 69 const CommitCounters& counters) = 0; | 66 const CommitCounters& counters) = 0; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 84 ModelType type, | 81 ModelType type, |
| 85 const StatusCounters& counters) = 0; | 82 const StatusCounters& counters) = 0; |
| 86 | 83 |
| 87 // The status of the connection to the sync server has changed. | 84 // The status of the connection to the sync server has changed. |
| 88 virtual void OnConnectionStatusChange(ConnectionStatus status) = 0; | 85 virtual void OnConnectionStatusChange(ConnectionStatus status) = 0; |
| 89 | 86 |
| 90 // The syncer requires a passphrase to decrypt sensitive updates. This is | 87 // The syncer requires a passphrase to decrypt sensitive updates. This is |
| 91 // called when the first sensitive data type is setup by the user and anytime | 88 // called when the first sensitive data type is setup by the user and anytime |
| 92 // the passphrase is changed by another synced client. |reason| denotes why | 89 // the passphrase is changed by another synced client. |reason| denotes why |
| 93 // the passphrase was required. |pending_keys| is a copy of the | 90 // the passphrase was required. |pending_keys| is a copy of the |
| 94 // cryptographer's pending keys to be passed on to the frontend in order to | 91 // cryptographer's pending keys to be passed on to the host in order to |
| 95 // be cached. | 92 // be cached. |
| 96 virtual void OnPassphraseRequired( | 93 virtual void OnPassphraseRequired( |
| 97 PassphraseRequiredReason reason, | 94 PassphraseRequiredReason reason, |
| 98 const sync_pb::EncryptedData& pending_keys) = 0; | 95 const sync_pb::EncryptedData& pending_keys) = 0; |
| 99 | 96 |
| 100 // Called when the passphrase provided by the user is | 97 // Called when the passphrase provided by the user is |
| 101 // accepted. After this is called, updates to sensitive nodes are | 98 // accepted. After this is called, updates to sensitive nodes are |
| 102 // encrypted using the accepted passphrase. | 99 // encrypted using the accepted passphrase. |
| 103 virtual void OnPassphraseAccepted() = 0; | 100 virtual void OnPassphraseAccepted() = 0; |
| 104 | 101 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 117 virtual void OnEncryptedTypesChanged(ModelTypeSet encrypted_types, | 114 virtual void OnEncryptedTypesChanged(ModelTypeSet encrypted_types, |
| 118 bool encrypt_everything) = 0; | 115 bool encrypt_everything) = 0; |
| 119 | 116 |
| 120 // Called after we finish encrypting the current set of encrypted | 117 // Called after we finish encrypting the current set of encrypted |
| 121 // types. | 118 // types. |
| 122 virtual void OnEncryptionComplete() = 0; | 119 virtual void OnEncryptionComplete() = 0; |
| 123 | 120 |
| 124 // Called to perform migration of |types|. | 121 // Called to perform migration of |types|. |
| 125 virtual void OnMigrationNeededForTypes(ModelTypeSet types) = 0; | 122 virtual void OnMigrationNeededForTypes(ModelTypeSet types) = 0; |
| 126 | 123 |
| 127 // Inform the Frontend that new datatypes are available for registration. | 124 // Called when new datatypes are available for registration. |
| 128 virtual void OnExperimentsChanged(const Experiments& experiments) = 0; | 125 virtual void OnExperimentsChanged(const Experiments& experiments) = 0; |
| 129 | 126 |
| 130 // Called when the sync cycle returns there is an user actionable error. | 127 // Called when the sync cycle returns there is an user actionable error. |
| 131 virtual void OnActionableError(const SyncProtocolError& error) = 0; | 128 virtual void OnActionableError(const SyncProtocolError& error) = 0; |
| 132 | 129 |
| 133 // Called when the user of this device enables passphrase encryption. | 130 // Called when the user of this device enables passphrase encryption. |
| 134 // | 131 // |
| 135 // |nigori_state| contains the new (post custom passphrase) encryption keys | 132 // |nigori_state| contains the new (post custom passphrase) encryption keys |
| 136 // and can be used to restore SyncEncryptionHandler's state across sync | 133 // and can be used to restore SyncEncryptionHandler's state across sync |
| 137 // backend instances. See also SyncEncryptionHandlerImpl::RestoreNigori. | 134 // backend instances. See also SyncEncryptionHandlerImpl::RestoreNigori. |
| 138 virtual void OnLocalSetPassphraseEncryption( | 135 virtual void OnLocalSetPassphraseEncryption( |
| 139 const SyncEncryptionHandler::NigoriState& nigori_state) = 0; | 136 const SyncEncryptionHandler::NigoriState& nigori_state) = 0; |
| 140 }; | 137 }; |
| 141 | 138 |
| 142 } // namespace syncer | 139 } // namespace syncer |
| 143 | 140 |
| 144 #endif // COMPONENTS_SYNC_DRIVER_SYNC_FRONTEND_H_ | 141 #endif // COMPONENTS_SYNC_ENGINE_SYNC_ENGINE_HOST_H_ |
| OLD | NEW |