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/syncable/directory_change_delegate.h" | |
15 #include "sync/syncable/transaction_observer.h" | |
16 | |
17 namespace syncer { | |
18 | |
19 class WriteTransaction; | |
20 | |
21 // Base class of sync managers used for backup and rollback. Two major | |
22 // functions are: | |
23 // * Init(): load backup DB into sync directory. | |
24 // * ConfigureSyncer(): initialize permanent sync nodes (root, bookmark | |
25 // permanent folders) for configured type as needed. | |
26 // | |
27 // Most of other functions are no ops. | |
28 class SyncRollbackManagerBase : | |
29 public SyncManager, | |
30 public syncable::DirectoryChangeDelegate, | |
31 public syncable::TransactionObserver { | |
32 public: | |
33 SyncRollbackManagerBase(); | |
34 virtual ~SyncRollbackManagerBase(); | |
35 | |
36 // SyncManager implementation. | |
37 virtual void Init( | |
38 const base::FilePath& database_location, | |
39 const WeakHandle<JsEventHandler>& event_handler, | |
40 const std::string& sync_server_and_path, | |
41 int sync_server_port, | |
42 bool use_ssl, | |
43 scoped_ptr<HttpPostProviderFactory> post_factory, | |
44 const std::vector<scoped_refptr<ModelSafeWorker> >& workers, | |
45 ExtensionsActivity* extensions_activity, | |
46 SyncManager::ChangeDelegate* change_delegate, | |
47 const SyncCredentials& credentials, | |
48 const std::string& invalidator_client_id, | |
49 const std::string& restored_key_for_bootstrapping, | |
50 const std::string& restored_keystore_key_for_bootstrapping, | |
51 InternalComponentsFactory* internal_components_factory, | |
52 Encryptor* encryptor, | |
53 scoped_ptr<UnrecoverableErrorHandler> unrecoverable_error_handler, | |
54 ReportUnrecoverableErrorFunction | |
55 report_unrecoverable_error_function, | |
56 CancelationSignal* cancelation_signal) OVERRIDE; | |
57 virtual void ThrowUnrecoverableError() OVERRIDE; | |
58 virtual ModelTypeSet InitialSyncEndedTypes() OVERRIDE; | |
59 virtual ModelTypeSet GetTypesWithEmptyProgressMarkerToken( | |
60 ModelTypeSet types) OVERRIDE; | |
61 virtual bool PurgePartiallySyncedTypes() OVERRIDE; | |
62 virtual void UpdateCredentials(const SyncCredentials& credentials) OVERRIDE; | |
63 virtual void StartSyncingNormally(const ModelSafeRoutingInfo& routing_info) | |
64 OVERRIDE; | |
65 virtual void ConfigureSyncer( | |
66 ConfigureReason reason, | |
67 ModelTypeSet to_download, | |
68 ModelTypeSet to_purge, | |
69 ModelTypeSet to_journal, | |
70 ModelTypeSet to_unapply, | |
71 const ModelSafeRoutingInfo& new_routing_info, | |
72 const base::Closure& ready_task, | |
73 const base::Closure& retry_task) OVERRIDE; | |
74 virtual void OnInvalidatorStateChange(InvalidatorState state) OVERRIDE; | |
75 virtual void OnIncomingInvalidation( | |
76 const ObjectIdInvalidationMap& invalidation_map) OVERRIDE; | |
77 virtual void AddObserver(SyncManager::Observer* observer) OVERRIDE; | |
78 virtual void RemoveObserver(SyncManager::Observer* observer) OVERRIDE; | |
79 virtual SyncStatus GetDetailedStatus() const OVERRIDE; | |
80 virtual void SaveChanges() OVERRIDE; | |
81 virtual void ShutdownOnSyncThread() OVERRIDE; | |
82 virtual UserShare* GetUserShare() OVERRIDE; | |
83 virtual const std::string cache_guid() OVERRIDE; | |
84 virtual bool ReceivedExperiment(Experiments* experiments) OVERRIDE; | |
85 virtual bool HasUnsyncedItems() OVERRIDE; | |
86 virtual SyncEncryptionHandler* GetEncryptionHandler() OVERRIDE; | |
87 virtual void RefreshTypes(ModelTypeSet types) OVERRIDE; | |
88 virtual std::string GetOwnerName() const OVERRIDE; | |
89 virtual SyncCoreProxy* GetSyncCoreProxy() OVERRIDE; | |
90 virtual ScopedVector<ProtocolEvent> GetBufferedProtocolEvents() | |
91 OVERRIDE; | |
92 virtual scoped_ptr<base::ListValue> GetAllNodesForType( | |
93 syncer::ModelType type) OVERRIDE; | |
94 | |
95 // DirectoryChangeDelegate implementation. | |
96 virtual void HandleTransactionCompleteChangeEvent( | |
97 ModelTypeSet models_with_changes) OVERRIDE; | |
98 virtual ModelTypeSet HandleTransactionEndingChangeEvent( | |
99 const syncable::ImmutableWriteTransactionInfo& write_transaction_info, | |
100 syncable::BaseTransaction* trans) OVERRIDE; | |
101 virtual void HandleCalculateChangesChangeEventFromSyncApi( | |
102 const syncable::ImmutableWriteTransactionInfo& write_transaction_info, | |
103 syncable::BaseTransaction* trans, | |
104 std::vector<int64>* entries_changed) OVERRIDE; | |
105 virtual void HandleCalculateChangesChangeEventFromSyncer( | |
106 const syncable::ImmutableWriteTransactionInfo& write_transaction_info, | |
107 syncable::BaseTransaction* trans, | |
108 std::vector<int64>* entries_changed) OVERRIDE; | |
109 | |
110 // syncable::TransactionObserver implementation. | |
111 virtual void OnTransactionWrite( | |
112 const syncable::ImmutableWriteTransactionInfo& write_transaction_info, | |
113 ModelTypeSet models_with_changes) OVERRIDE; | |
114 | |
115 protected: | |
116 void UpdateNewEntryStats(ModelType type); | |
Nicolas Zea
2014/04/17 18:22:56
do these two methods need to be part of the parent
haitaol1
2014/04/17 19:30:38
Added to access private status_
On 2014/04/17 18:
Nicolas Zea
2014/04/17 20:26:44
I think it's cleaner to have the implementations o
haitaol1
2014/04/17 22:21:18
Done.
| |
117 void UpdateDeletedEntryStats(ModelType type); | |
118 | |
119 private: | |
120 void NotifyInitializationSuccess(); | |
121 void NotifyInitializationFailure(); | |
122 | |
123 bool InitBackupDB( | |
124 const base::FilePath& sync_folder, | |
125 InternalComponentsFactory* internal_components_factory); | |
126 | |
127 bool InitTypeRootNode(ModelType type); | |
128 void InitBookmarkFolder(const std::string& folder); | |
129 | |
130 UserShare share_; | |
131 SyncStatus status_; | |
132 ObserverList<SyncManager::Observer> observers_; | |
133 | |
134 scoped_ptr<UnrecoverableErrorHandler> unrecoverable_error_handler_; | |
135 ReportUnrecoverableErrorFunction report_unrecoverable_error_function_; | |
136 | |
137 base::WeakPtrFactory<SyncRollbackManagerBase> weak_ptr_factory_; | |
138 }; | |
139 | |
140 } // namespace syncer | |
141 | |
142 #endif // SYNC_INTERNAL_API_SYNC_ROLLBACK_MANAGER_BASE_H_ | |
OLD | NEW |