Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / components / sync_driver / sync_frontend.h
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 "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"
14
15 namespace syncer {
16 class DataTypeDebugInfoListener;
17 class JsBackend;
18 }  // namespace syncer
19
20 namespace sync_pb {
21 class EncryptedData;
22 }  // namespace sync_pb
23
24 namespace browser_sync {
25
26 // SyncFrontend is the interface used by SyncBackendHost to communicate with
27 // the entity that created it and, presumably, is interested in sync-related
28 // activity.
29 // NOTE: All methods will be invoked by a SyncBackendHost on the same thread
30 // used to create that SyncBackendHost.
31 class SyncFrontend {
32  public:
33   SyncFrontend();
34   virtual ~SyncFrontend();
35
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.
39   //
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>&
46           debug_info_listener,
47       bool success) = 0;
48
49   // The backend queried the server recently and received some updates.
50   virtual void OnSyncCycleCompleted() = 0;
51
52   // Configure ran into some kind of error. But it is scheduled to be
53   // retried.
54   virtual void OnSyncConfigureRetry() = 0;
55
56   // The status of the connection to the sync server has changed.
57   virtual void OnConnectionStatusChange(
58       syncer::ConnectionStatus status) = 0;
59
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
65   // be cached.
66   virtual void OnPassphraseRequired(
67       syncer::PassphraseRequiredReason reason,
68       const sync_pb::EncryptedData& pending_keys) = 0;
69
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;
74
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
78   // below).
79   //
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.
83   //
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;
90
91   // Called after we finish encrypting the current set of encrypted
92   // types.
93   virtual void OnEncryptionComplete() = 0;
94
95   // Called to perform migration of |types|.
96   virtual void OnMigrationNeededForTypes(syncer::ModelTypeSet types) = 0;
97
98   // Inform the Frontend that new datatypes are available for registration.
99   virtual void OnExperimentsChanged(
100       const syncer::Experiments& experiments) = 0;
101
102   // Called when the sync cycle returns there is an user actionable error.
103   virtual void OnActionableError(const syncer::SyncProtocolError& error) = 0;
104 };
105
106 }  // namespace browser_sync
107
108 #endif  // COMPONENTS_SYNC_DRIVER_SYNC_FRONTEND_H_