OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CHROME_BROWSER_SYNC_GLUE_GENERIC_CHANGE_PROCESSOR_H_ | 5 #ifndef CHROME_BROWSER_SYNC_GLUE_GENERIC_CHANGE_PROCESSOR_H_ |
6 #define CHROME_BROWSER_SYNC_GLUE_GENERIC_CHANGE_PROCESSOR_H_ | 6 #define CHROME_BROWSER_SYNC_GLUE_GENERIC_CHANGE_PROCESSOR_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
| 9 #include <vector> |
| 10 |
| 11 #include "base/compiler_specific.h" |
| 12 #include "chrome/browser/sync/api/sync_event_processor.h" |
9 #include "chrome/browser/sync/glue/change_processor.h" | 13 #include "chrome/browser/sync/glue/change_processor.h" |
10 | 14 |
| 15 class SyncData; |
11 class SyncableService; | 16 class SyncableService; |
12 | 17 |
| 18 typedef std::vector<SyncData> SyncDataList; |
| 19 |
13 namespace browser_sync { | 20 namespace browser_sync { |
14 | 21 |
15 // TODO(sync): Have this become a SyncableService implementation and deprecate | 22 // TODO(sync): deprecate all change processors and have them replaced by |
16 // ChangeProcessor. | 23 // instances of this. |
17 // For now, it acts as a dummy change processor that just passes all | 24 // Datatype agnostic change processor. One instance of GenericChangeProcessor |
18 // ApplySyncChanges commands onto the local SyncableService.. | 25 // is created for each datatype and lives on the datatype's thread. It then |
19 class GenericChangeProcessor : public ChangeProcessor { | 26 // handles all interaction with the sync api, both translating pushes from the |
| 27 // local service into transactions and receiving changes from the sync model, |
| 28 // which then get converted into SyncEvent's and sent to the local service. |
| 29 class GenericChangeProcessor : public ChangeProcessor, |
| 30 public SyncEventProcessor { |
20 public: | 31 public: |
21 GenericChangeProcessor(SyncableService* local_service, | 32 GenericChangeProcessor(SyncableService* local_service, |
22 UnrecoverableErrorHandler* error_handler); | 33 UnrecoverableErrorHandler* error_handler, |
| 34 sync_api::UserShare* user_share); |
23 ~GenericChangeProcessor(); | 35 ~GenericChangeProcessor(); |
24 | 36 |
25 // ChangeProcessor interface. | 37 // ChangeProcessor interface. |
26 // Just passes all arguments onto the |local_service_| | 38 // Just passes all arguments onto |local_service_| by way of it's |
| 39 // ProcessSyncEvents method. |
27 virtual void ApplyChangesFromSyncModel( | 40 virtual void ApplyChangesFromSyncModel( |
28 const sync_api::BaseTransaction* trans, | 41 const sync_api::BaseTransaction* trans, |
29 const sync_api::SyncManager::ChangeRecord* changes, | 42 const sync_api::SyncManager::ChangeRecord* changes, |
30 int change_count); | 43 int change_count) OVERRIDE; |
| 44 |
| 45 // SyncEventProcessor implementation. |
| 46 virtual void ProcessSyncEvents(const SyncEventList& event_list) OVERRIDE; |
| 47 |
| 48 // Fills |current_sync_data| with all the syncer data for the specified type. |
| 49 virtual bool GetSyncDataForType(syncable::ModelType type, |
| 50 SyncDataList* current_sync_data); |
| 51 |
| 52 // Generic versions of AssociatorInterface methods. Called by |
| 53 // SyncableServiceAdapter. |
| 54 bool SyncModelHasUserCreatedNodes(syncable::ModelType type, |
| 55 bool* has_nodes); |
| 56 bool CryptoReadyIfNecessary(syncable::ModelType type); |
31 protected: | 57 protected: |
32 // ChangeProcessor interface. | 58 // ChangeProcessor interface. |
33 virtual void StartImpl(Profile* profile); // Not implemented. | 59 virtual void StartImpl(Profile* profile) OVERRIDE; // Not implemented. |
34 virtual void StopImpl(); // Not implemented. | 60 virtual void StopImpl() OVERRIDE; // Not implemented. |
| 61 virtual sync_api::UserShare* share_handle() OVERRIDE; |
35 private: | 62 private: |
| 63 // The SyncableService this change processor will forward changes on to. |
36 SyncableService* local_service_; | 64 SyncableService* local_service_; |
| 65 |
| 66 // Our handle to the sync model. Unlike normal ChangeProcessors, we need to |
| 67 // be able to access the sync model before the change processor begins |
| 68 // listening to changes (the local_service_ will be interacting with us |
| 69 // when it starts up). As such we can't wait until Start(_) has been called, |
| 70 // and have to keep a local pointer to the user_share. |
| 71 sync_api::UserShare* user_share_; |
37 }; | 72 }; |
38 | 73 |
39 } // namespace browser_sync | 74 } // namespace browser_sync |
40 | 75 |
41 #endif // CHROME_BROWSER_SYNC_GLUE_GENERIC_CHANGE_PROCESSOR_H_ | 76 #endif // CHROME_BROWSER_SYNC_GLUE_GENERIC_CHANGE_PROCESSOR_H_ |
OLD | NEW |