Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(281)

Side by Side Diff: components/sync/engine/sync_engine_host.h

Issue 2533083002: [Sync] SyncEngine refactor part 1: interfaces. (Closed)
Patch Set: Rebase. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_ENGINE_SYNC_ENGINE_HOST_H_
6 #define COMPONENTS_SYNC_DRIVER_SYNC_FRONTEND_H_ 6 #define COMPONENTS_SYNC_ENGINE_SYNC_ENGINE_HOST_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/engine/sync_encryption_handler.h" 12 #include "components/sync/engine/sync_encryption_handler.h"
13 #include "components/sync/engine/sync_manager.h" 13 #include "components/sync/engine/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 { 16 namespace sync_pb {
17 class EncryptedData; 17 class EncryptedData;
18 } // namespace sync_pb 18 } // namespace sync_pb
19 19
20 namespace syncer { 20 namespace syncer {
21 21
22 class DataTypeDebugInfoListener; 22 class DataTypeDebugInfoListener;
23 class JsBackend; 23 class JsBackend;
24 class ProtocolEvent; 24 class ProtocolEvent;
25 struct CommitCounters; 25 struct CommitCounters;
26 struct StatusCounters; 26 struct StatusCounters;
27 struct UpdateCounters; 27 struct UpdateCounters;
28 28
29 // SyncFrontend is the interface used by SyncBackendHost to communicate with 29 // SyncEngineHost is the interface used by SyncEngine to communicate with the
30 // the entity that created it and, presumably, is interested in sync-related 30 // entity
skym 2016/12/02 20:54:55 Line breaks here should get cleaned up.
maxbogue 2016/12/02 23:59:28 Done.
31 // activity. 31 // that created it and, presumably, is interested in sync-related activity.
32 // NOTE: All methods will be invoked by a SyncBackendHost on the same thread 32 // NOTE: All methods will be invoked by a SyncEngine on the same thread used to
skym 2016/12/02 20:54:55 I worry that this comment is pretty confusing if y
maxbogue 2016/12/02 23:59:28 Changed it, PTAL.
33 // used to create that SyncBackendHost. 33 // create that SyncEngine.
34 class SyncFrontend { 34 class SyncEngineHost {
35 public: 35 public:
36 SyncFrontend(); 36 SyncEngineHost();
37 virtual ~SyncFrontend(); 37 virtual ~SyncEngineHost();
38 38
39 // The backend has completed initialization and it is now ready to 39 // The backend has completed initialization and it is now ready to
40 // accept and process changes. If success is false, initialization 40 // accept and process changes. If success is false, initialization
41 // wasn't able to be completed and should be retried. 41 // wasn't able to be completed and should be retried.
42 // 42 //
43 // |js_backend| is what about:sync interacts with; it's different 43 // |js_backend| is what about:sync interacts with; it's different
44 // from the 'Backend' in 'OnBackendInitialized' (unfortunately). It 44 // from the 'Backend' in 'OnBackendInitialized' (unfortunately). It
45 // is initialized only if |success| is true. 45 // is initialized only if |success| is true.
46 virtual void OnBackendInitialized( 46 virtual void OnBackendInitialized(
47 const WeakHandle<JsBackend>& js_backend, 47 const WeakHandle<JsBackend>& js_backend,
48 const WeakHandle<DataTypeDebugInfoListener>& debug_info_listener, 48 const WeakHandle<DataTypeDebugInfoListener>& debug_info_listener,
49 const std::string& cache_guid, 49 const std::string& cache_guid,
50 bool success) = 0; 50 bool success) = 0;
51 51
52 // The backend queried the server recently and received some updates. 52 // The backend queried the server recently and received some updates.
53 virtual void OnSyncCycleCompleted() = 0; 53 virtual void OnSyncCycleCompleted() = 0;
54 54
55 // Informs the frontned of some network event. These notifications are 55 // Informs the frontned of some network event. These notifications are
skym 2016/12/02 20:54:55 This misspelling evaded you!
maxbogue 2016/12/02 23:59:28 I'm personally offended by its audacity.
56 // 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
57 // SyncBackendHost. 57 // SyncEngine.
58 // 58 //
59 // 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
60 // is listening for it. 60 // is listening for it.
61 virtual void OnProtocolEvent(const ProtocolEvent& event) = 0; 61 virtual void OnProtocolEvent(const ProtocolEvent& event) = 0;
62 62
63 // 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.
64 // 64 //
65 // Disabled by default. Enable by calling 65 // Disabled by default. Enable by calling
66 // EnableDirectoryTypeDebugInfoForwarding() on the backend. 66 // EnableDirectoryTypeDebugInfoForwarding() on the backend.
67 virtual void OnDirectoryTypeCommitCounterUpdated( 67 virtual void OnDirectoryTypeCommitCounterUpdated(
(...skipping 16 matching lines...) Expand all
84 ModelType type, 84 ModelType type,
85 const StatusCounters& counters) = 0; 85 const StatusCounters& counters) = 0;
86 86
87 // The status of the connection to the sync server has changed. 87 // The status of the connection to the sync server has changed.
88 virtual void OnConnectionStatusChange(ConnectionStatus status) = 0; 88 virtual void OnConnectionStatusChange(ConnectionStatus status) = 0;
89 89
90 // The syncer requires a passphrase to decrypt sensitive updates. This is 90 // The syncer requires a passphrase to decrypt sensitive updates. This is
91 // 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
92 // the passphrase is changed by another synced client. |reason| denotes why 92 // the passphrase is changed by another synced client. |reason| denotes why
93 // the passphrase was required. |pending_keys| is a copy of the 93 // the passphrase was required. |pending_keys| is a copy of the
94 // 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 host in order to
95 // be cached. 95 // be cached.
96 virtual void OnPassphraseRequired( 96 virtual void OnPassphraseRequired(
97 PassphraseRequiredReason reason, 97 PassphraseRequiredReason reason,
98 const sync_pb::EncryptedData& pending_keys) = 0; 98 const sync_pb::EncryptedData& pending_keys) = 0;
99 99
100 // Called when the passphrase provided by the user is 100 // Called when the passphrase provided by the user is
101 // accepted. After this is called, updates to sensitive nodes are 101 // accepted. After this is called, updates to sensitive nodes are
102 // encrypted using the accepted passphrase. 102 // encrypted using the accepted passphrase.
103 virtual void OnPassphraseAccepted() = 0; 103 virtual void OnPassphraseAccepted() = 0;
104 104
(...skipping 12 matching lines...) Expand all
117 virtual void OnEncryptedTypesChanged(ModelTypeSet encrypted_types, 117 virtual void OnEncryptedTypesChanged(ModelTypeSet encrypted_types,
118 bool encrypt_everything) = 0; 118 bool encrypt_everything) = 0;
119 119
120 // Called after we finish encrypting the current set of encrypted 120 // Called after we finish encrypting the current set of encrypted
121 // types. 121 // types.
122 virtual void OnEncryptionComplete() = 0; 122 virtual void OnEncryptionComplete() = 0;
123 123
124 // Called to perform migration of |types|. 124 // Called to perform migration of |types|.
125 virtual void OnMigrationNeededForTypes(ModelTypeSet types) = 0; 125 virtual void OnMigrationNeededForTypes(ModelTypeSet types) = 0;
126 126
127 // Inform the Frontend that new datatypes are available for registration. 127 // Inform the host that new datatypes are available for registration.
skym 2016/12/02 20:54:55 I like the 'Called when...' phrasing more than thi
maxbogue 2016/12/02 23:59:28 Done.
128 virtual void OnExperimentsChanged(const Experiments& experiments) = 0; 128 virtual void OnExperimentsChanged(const Experiments& experiments) = 0;
129 129
130 // 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.
131 virtual void OnActionableError(const SyncProtocolError& error) = 0; 131 virtual void OnActionableError(const SyncProtocolError& error) = 0;
132 132
133 // Called when the user of this device enables passphrase encryption. 133 // Called when the user of this device enables passphrase encryption.
134 // 134 //
135 // |nigori_state| contains the new (post custom passphrase) encryption keys 135 // |nigori_state| contains the new (post custom passphrase) encryption keys
136 // and can be used to restore SyncEncryptionHandler's state across sync 136 // and can be used to restore SyncEncryptionHandler's state across sync
137 // backend instances. See also SyncEncryptionHandlerImpl::RestoreNigori. 137 // backend instances. See also SyncEncryptionHandlerImpl::RestoreNigori.
138 virtual void OnLocalSetPassphraseEncryption( 138 virtual void OnLocalSetPassphraseEncryption(
139 const SyncEncryptionHandler::NigoriState& nigori_state) = 0; 139 const SyncEncryptionHandler::NigoriState& nigori_state) = 0;
140 }; 140 };
141 141
142 } // namespace syncer 142 } // namespace syncer
143 143
144 #endif // COMPONENTS_SYNC_DRIVER_SYNC_FRONTEND_H_ 144 #endif // COMPONENTS_SYNC_ENGINE_SYNC_ENGINE_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698