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.
5 #ifndef COMPONENTS_SYNC_DRIVER_SYNC_FRONTEND_H_
6 #define COMPONENTS_SYNC_DRIVER_SYNC_FRONTEND_H_
8 #include "base/basictypes.h"
9 #include "sync/internal_api/public/base/model_type.h"
10 #include "sync/internal_api/public/sync_encryption_handler.h"
11 #include "sync/internal_api/public/sync_manager.h"
12 #include "sync/internal_api/public/util/weak_handle.h"
13 #include "sync/protocol/sync_protocol_error.h"
16 class DataTypeDebugInfoListener;
22 } // namespace sync_pb
24 namespace browser_sync {
26 // SyncFrontend is the interface used by SyncBackendHost to communicate with
27 // the entity that created it and, presumably, is interested in sync-related
29 // NOTE: All methods will be invoked by a SyncBackendHost on the same thread
30 // used to create that SyncBackendHost.
34 virtual ~SyncFrontend();
36 // The backend has completed initialization and it is now ready to
37 // accept and process changes. If success is false, initialization
38 // wasn't able to be completed and should be retried.
40 // |js_backend| is what about:sync interacts with; it's different
41 // from the 'Backend' in 'OnBackendInitialized' (unfortunately). It
42 // is initialized only if |success| is true.
43 virtual void OnBackendInitialized(
44 const syncer::WeakHandle<syncer::JsBackend>& js_backend,
45 const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>&
49 // The backend queried the server recently and received some updates.
50 virtual void OnSyncCycleCompleted() = 0;
52 // Configure ran into some kind of error. But it is scheduled to be
54 virtual void OnSyncConfigureRetry() = 0;
56 // The status of the connection to the sync server has changed.
57 virtual void OnConnectionStatusChange(
58 syncer::ConnectionStatus status) = 0;
60 // The syncer requires a passphrase to decrypt sensitive updates. This is
61 // called when the first sensitive data type is setup by the user and anytime
62 // the passphrase is changed by another synced client. |reason| denotes why
63 // the passphrase was required. |pending_keys| is a copy of the
64 // cryptographer's pending keys to be passed on to the frontend in order to
66 virtual void OnPassphraseRequired(
67 syncer::PassphraseRequiredReason reason,
68 const sync_pb::EncryptedData& pending_keys) = 0;
70 // Called when the passphrase provided by the user is
71 // accepted. After this is called, updates to sensitive nodes are
72 // encrypted using the accepted passphrase.
73 virtual void OnPassphraseAccepted() = 0;
75 // Called when the set of encrypted types or the encrypt everything
76 // flag has been changed. Note that encryption isn't complete until
77 // the OnEncryptionComplete() notification has been sent (see
80 // |encrypted_types| will always be a superset of
81 // syncer::Cryptographer::SensitiveTypes(). If |encrypt_everything| is
82 // true, |encrypted_types| will be the set of all known types.
84 // Until this function is called, observers can assume that the set
85 // of encrypted types is syncer::Cryptographer::SensitiveTypes() and that
86 // the encrypt everything flag is false.
87 virtual void OnEncryptedTypesChanged(
88 syncer::ModelTypeSet encrypted_types,
89 bool encrypt_everything) = 0;
91 // Called after we finish encrypting the current set of encrypted
93 virtual void OnEncryptionComplete() = 0;
95 // Called to perform migration of |types|.
96 virtual void OnMigrationNeededForTypes(syncer::ModelTypeSet types) = 0;
98 // Inform the Frontend that new datatypes are available for registration.
99 virtual void OnExperimentsChanged(
100 const syncer::Experiments& experiments) = 0;
102 // Called when the sync cycle returns there is an user actionable error.
103 virtual void OnActionableError(const syncer::SyncProtocolError& error) = 0;
106 } // namespace browser_sync
108 #endif // COMPONENTS_SYNC_DRIVER_SYNC_FRONTEND_H_