1 // Copyright 2013 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 CHROME_BROWSER_SYNC_GLUE_SYNC_FRONTEND_H_
6 #define CHROME_BROWSER_SYNC_GLUE_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 // We are no longer permitted to communicate with the server. Sync should
61 // be disabled and state cleaned up at once.
62 virtual void OnStopSyncingPermanently() = 0;
64 // The syncer requires a passphrase to decrypt sensitive updates. This is
65 // called when the first sensitive data type is setup by the user and anytime
66 // the passphrase is changed by another synced client. |reason| denotes why
67 // the passphrase was required. |pending_keys| is a copy of the
68 // cryptographer's pending keys to be passed on to the frontend in order to
70 virtual void OnPassphraseRequired(
71 syncer::PassphraseRequiredReason reason
,
72 const sync_pb::EncryptedData
& pending_keys
) = 0;
74 // Called when the passphrase provided by the user is
75 // accepted. After this is called, updates to sensitive nodes are
76 // encrypted using the accepted passphrase.
77 virtual void OnPassphraseAccepted() = 0;
79 // Called when the set of encrypted types or the encrypt everything
80 // flag has been changed. Note that encryption isn't complete until
81 // the OnEncryptionComplete() notification has been sent (see
84 // |encrypted_types| will always be a superset of
85 // syncer::Cryptographer::SensitiveTypes(). If |encrypt_everything| is
86 // true, |encrypted_types| will be the set of all known types.
88 // Until this function is called, observers can assume that the set
89 // of encrypted types is syncer::Cryptographer::SensitiveTypes() and that
90 // the encrypt everything flag is false.
91 virtual void OnEncryptedTypesChanged(
92 syncer::ModelTypeSet encrypted_types
,
93 bool encrypt_everything
) = 0;
95 // Called after we finish encrypting the current set of encrypted
97 virtual void OnEncryptionComplete() = 0;
99 // Called to perform migration of |types|.
100 virtual void OnMigrationNeededForTypes(syncer::ModelTypeSet types
) = 0;
102 // Inform the Frontend that new datatypes are available for registration.
103 virtual void OnExperimentsChanged(
104 const syncer::Experiments
& experiments
) = 0;
106 // Called when the sync cycle returns there is an user actionable error.
107 virtual void OnActionableError(const syncer::SyncProtocolError
& error
) = 0;
110 } // namespace browser_sync
112 #endif // CHROME_BROWSER_SYNC_GLUE_SYNC_FRONTEND_H_