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