OLD | NEW |
---|---|
(Empty) | |
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 SYNC_INTERNAL_API_SYNC_ROLLBACK_MANAGER_BASE_H_ | |
6 #define SYNC_INTERNAL_API_SYNC_ROLLBACK_MANAGER_BASE_H_ | |
7 | |
8 #include <string> | |
9 #include <vector> | |
10 | |
11 #include "sync/internal_api/public/http_post_provider_factory.h" | |
12 #include "sync/internal_api/public/sync_manager.h" | |
13 #include "sync/internal_api/public/user_share.h" | |
14 #include "sync/js/js_backend.h" | |
15 #include "sync/syncable/directory_change_delegate.h" | |
16 #include "sync/syncable/transaction_observer.h" | |
17 | |
18 namespace syncer { | |
19 | |
20 class WriteTransaction; | |
21 | |
22 // Base class of sync managers used for backup and rollback. Initialize sync | |
23 // DB for backup types as needed. Most of functions are no ops. | |
Nicolas Zea
2014/04/14 21:36:31
I think this would be a good place to go into more
haitaol1
2014/04/15 00:19:06
Done.
| |
24 class SyncRollbackManagerBase : | |
25 public SyncManager, | |
26 public JsBackend, | |
Nicolas Zea
2014/04/14 21:36:31
Why do we need the JsBackend?
haitaol1
2014/04/15 00:19:06
This was used to query directory stats, but it may
| |
27 public syncable::DirectoryChangeDelegate, | |
28 public syncable::TransactionObserver { | |
Nicolas Zea
2014/04/14 21:36:31
transaction observer doesn't seem necessary either
haitaol1
2014/04/15 00:19:06
There's a DCHECK(transaction_observer.IsInitialize
| |
29 public: | |
30 SyncRollbackManagerBase(); | |
31 virtual ~SyncRollbackManagerBase(); | |
32 | |
33 // SyncManager implementation. | |
34 virtual void Init( | |
35 const base::FilePath& database_location, | |
36 const WeakHandle<JsEventHandler>& event_handler, | |
37 const std::string& sync_server_and_path, | |
38 int sync_server_port, | |
39 bool use_ssl, | |
40 scoped_ptr<HttpPostProviderFactory> post_factory, | |
41 const std::vector<scoped_refptr<ModelSafeWorker> >& workers, | |
42 ExtensionsActivity* extensions_activity, | |
43 SyncManager::ChangeDelegate* change_delegate, | |
44 const SyncCredentials& credentials, | |
45 const std::string& invalidator_client_id, | |
46 const std::string& restored_key_for_bootstrapping, | |
47 const std::string& restored_keystore_key_for_bootstrapping, | |
48 InternalComponentsFactory* internal_components_factory, | |
49 Encryptor* encryptor, | |
50 scoped_ptr<UnrecoverableErrorHandler> unrecoverable_error_handler, | |
51 ReportUnrecoverableErrorFunction | |
52 report_unrecoverable_error_function, | |
53 CancelationSignal* cancelation_signal) OVERRIDE; | |
54 virtual void ThrowUnrecoverableError() OVERRIDE; | |
55 virtual ModelTypeSet InitialSyncEndedTypes() OVERRIDE; | |
56 virtual ModelTypeSet GetTypesWithEmptyProgressMarkerToken( | |
57 ModelTypeSet types) OVERRIDE; | |
58 virtual bool PurgePartiallySyncedTypes() OVERRIDE; | |
59 virtual void UpdateCredentials(const SyncCredentials& credentials) OVERRIDE; | |
60 virtual void StartSyncingNormally(const ModelSafeRoutingInfo& routing_info) | |
61 OVERRIDE; | |
62 virtual void ConfigureSyncer( | |
63 ConfigureReason reason, | |
64 ModelTypeSet to_download, | |
65 ModelTypeSet to_purge, | |
66 ModelTypeSet to_journal, | |
67 ModelTypeSet to_unapply, | |
68 const ModelSafeRoutingInfo& new_routing_info, | |
69 const base::Closure& ready_task, | |
70 const base::Closure& retry_task) OVERRIDE; | |
71 virtual void OnInvalidatorStateChange(InvalidatorState state) OVERRIDE; | |
72 virtual void OnIncomingInvalidation( | |
73 const ObjectIdInvalidationMap& invalidation_map) OVERRIDE; | |
74 virtual void AddObserver(SyncManager::Observer* observer) OVERRIDE; | |
75 virtual void RemoveObserver(SyncManager::Observer* observer) OVERRIDE; | |
76 virtual SyncStatus GetDetailedStatus() const OVERRIDE; | |
77 virtual void SaveChanges() OVERRIDE; | |
78 virtual void ShutdownOnSyncThread() OVERRIDE; | |
79 virtual UserShare* GetUserShare() OVERRIDE; | |
80 virtual const std::string cache_guid() OVERRIDE; | |
81 virtual bool ReceivedExperiment(Experiments* experiments) OVERRIDE; | |
82 virtual bool HasUnsyncedItems() OVERRIDE; | |
83 virtual SyncEncryptionHandler* GetEncryptionHandler() OVERRIDE; | |
84 virtual void RefreshTypes(ModelTypeSet types) OVERRIDE; | |
85 virtual std::string GetOwnerName() const OVERRIDE; | |
86 virtual base::WeakPtr<syncer::SyncCore> GetSyncCore() OVERRIDE; | |
87 virtual ScopedVector<syncer::ProtocolEvent> GetBufferedProtocolEvents() | |
88 OVERRIDE; | |
89 virtual scoped_ptr<base::ListValue> GetAllNodesForType( | |
90 syncer::ModelType type) OVERRIDE; | |
91 | |
92 // JsBackend implementation. | |
93 virtual void SetJsEventHandler( | |
94 const WeakHandle<JsEventHandler>& event_handler) OVERRIDE; | |
95 virtual void ProcessJsMessage( | |
96 const std::string& name, const JsArgList& args, | |
97 const WeakHandle<JsReplyHandler>& reply_handler) OVERRIDE; | |
98 | |
99 // DirectoryChangeDelegate implementation. | |
100 virtual void HandleTransactionCompleteChangeEvent( | |
101 ModelTypeSet models_with_changes) OVERRIDE; | |
102 virtual ModelTypeSet HandleTransactionEndingChangeEvent( | |
103 const syncable::ImmutableWriteTransactionInfo& write_transaction_info, | |
104 syncable::BaseTransaction* trans) OVERRIDE; | |
105 virtual void HandleCalculateChangesChangeEventFromSyncApi( | |
106 const syncable::ImmutableWriteTransactionInfo& write_transaction_info, | |
107 syncable::BaseTransaction* trans, | |
108 std::vector<int64>* entries_changed) OVERRIDE; | |
109 virtual void HandleCalculateChangesChangeEventFromSyncer( | |
110 const syncable::ImmutableWriteTransactionInfo& write_transaction_info, | |
111 syncable::BaseTransaction* trans, | |
112 std::vector<int64>* entries_changed) OVERRIDE; | |
113 | |
114 // syncable::TransactionObserver implementation. | |
115 virtual void OnTransactionWrite( | |
116 const syncable::ImmutableWriteTransactionInfo& write_transaction_info, | |
117 ModelTypeSet models_with_changes) OVERRIDE; | |
118 | |
119 protected: | |
120 UserShare share_; | |
121 SyncStatus status_; | |
122 ObserverList<SyncManager::Observer> observers_; | |
123 | |
124 private: | |
125 void NotifyInitializationSuccess(); | |
126 void NotifyInitializationFailure(); | |
127 | |
128 bool InitBackupDB( | |
129 const base::FilePath& sync_folder, | |
130 InternalComponentsFactory* internal_components_factory); | |
131 | |
132 bool InitTypeRootNode(ModelType type); | |
133 void InitBookmarkFolder(const std::string& folder); | |
134 | |
135 scoped_ptr<UnrecoverableErrorHandler> unrecoverable_error_handler_; | |
136 ReportUnrecoverableErrorFunction report_unrecoverable_error_function_; | |
137 | |
138 base::WeakPtrFactory<SyncRollbackManagerBase> weak_ptr_factory_; | |
139 }; | |
140 | |
141 } // namespace syncer | |
142 | |
143 #endif // SYNC_INTERNAL_API_SYNC_ROLLBACK_MANAGER_BASE_H_ | |
OLD | NEW |