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