Add a string for translation.
[chromium-blink-merge.git] / components / sync_driver / sync_frontend.h
blob47d76bead8a124122af0c073b5a8f4397f091a29
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"
15 namespace syncer {
16 class DataTypeDebugInfoListener;
17 class JsBackend;
18 class ProtocolEvent;
19 } // namespace syncer
21 namespace sync_pb {
22 class EncryptedData;
23 } // namespace sync_pb
25 namespace browser_sync {
27 // SyncFrontend is the interface used by SyncBackendHost to communicate with
28 // the entity that created it and, presumably, is interested in sync-related
29 // activity.
30 // NOTE: All methods will be invoked by a SyncBackendHost on the same thread
31 // used to create that SyncBackendHost.
32 class SyncFrontend {
33 public:
34 SyncFrontend();
35 virtual ~SyncFrontend();
37 // The backend has completed initialization and it is now ready to
38 // accept and process changes. If success is false, initialization
39 // wasn't able to be completed and should be retried.
41 // |js_backend| is what about:sync interacts with; it's different
42 // from the 'Backend' in 'OnBackendInitialized' (unfortunately). It
43 // is initialized only if |success| is true.
44 virtual void OnBackendInitialized(
45 const syncer::WeakHandle<syncer::JsBackend>& js_backend,
46 const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>&
47 debug_info_listener,
48 bool success) = 0;
50 // The backend queried the server recently and received some updates.
51 virtual void OnSyncCycleCompleted() = 0;
53 // Configure ran into some kind of error. But it is scheduled to be
54 // retried.
55 virtual void OnSyncConfigureRetry() = 0;
57 // Informs the frontned of some network event. These notifications are
58 // disabled by default and must be enabled through an explicit request to the
59 // SyncBackendHost.
61 // It's disabld by default to avoid copying data across threads when no one
62 // is listening for it.
63 virtual void OnProtocolEvent(const syncer::ProtocolEvent& event) = 0;
65 // The status of the connection to the sync server has changed.
66 virtual void OnConnectionStatusChange(
67 syncer::ConnectionStatus status) = 0;
69 // The syncer requires a passphrase to decrypt sensitive updates. This is
70 // called when the first sensitive data type is setup by the user and anytime
71 // the passphrase is changed by another synced client. |reason| denotes why
72 // the passphrase was required. |pending_keys| is a copy of the
73 // cryptographer's pending keys to be passed on to the frontend in order to
74 // be cached.
75 virtual void OnPassphraseRequired(
76 syncer::PassphraseRequiredReason reason,
77 const sync_pb::EncryptedData& pending_keys) = 0;
79 // Called when the passphrase provided by the user is
80 // accepted. After this is called, updates to sensitive nodes are
81 // encrypted using the accepted passphrase.
82 virtual void OnPassphraseAccepted() = 0;
84 // Called when the set of encrypted types or the encrypt everything
85 // flag has been changed. Note that encryption isn't complete until
86 // the OnEncryptionComplete() notification has been sent (see
87 // below).
89 // |encrypted_types| will always be a superset of
90 // syncer::Cryptographer::SensitiveTypes(). If |encrypt_everything| is
91 // true, |encrypted_types| will be the set of all known types.
93 // Until this function is called, observers can assume that the set
94 // of encrypted types is syncer::Cryptographer::SensitiveTypes() and that
95 // the encrypt everything flag is false.
96 virtual void OnEncryptedTypesChanged(
97 syncer::ModelTypeSet encrypted_types,
98 bool encrypt_everything) = 0;
100 // Called after we finish encrypting the current set of encrypted
101 // types.
102 virtual void OnEncryptionComplete() = 0;
104 // Called to perform migration of |types|.
105 virtual void OnMigrationNeededForTypes(syncer::ModelTypeSet types) = 0;
107 // Inform the Frontend that new datatypes are available for registration.
108 virtual void OnExperimentsChanged(
109 const syncer::Experiments& experiments) = 0;
111 // Called when the sync cycle returns there is an user actionable error.
112 virtual void OnActionableError(const syncer::SyncProtocolError& error) = 0;
115 } // namespace browser_sync
117 #endif // COMPONENTS_SYNC_DRIVER_SYNC_FRONTEND_H_