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_SYNCABLE_SERVICE_ADAPTER_H_ | 5 #ifndef CHROME_BROWSER_SYNC_GLUE_SYNCABLE_SERVICE_ADAPTER_H_ |
6 #define CHROME_BROWSER_SYNC_GLUE_SYNCABLE_SERVICE_ADAPTER_H_ | 6 #define CHROME_BROWSER_SYNC_GLUE_SYNCABLE_SERVICE_ADAPTER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "chrome/browser/sync/api/syncable_service.h" | 12 #include "chrome/browser/sync/api/syncable_service.h" |
13 #include "chrome/browser/sync/glue/model_associator.h" | 13 #include "chrome/browser/sync/glue/model_associator.h" |
14 | 14 |
15 class SyncableService; | 15 class SyncableService; |
16 | 16 |
17 namespace browser_sync { | 17 namespace browser_sync { |
18 | 18 |
19 class GenericChangeProcessor; | 19 class GenericChangeProcessor; |
20 | 20 |
21 // An adapter to handle transitioning from model associator's to syncable | 21 // An adapter to handle transitioning from model associator's to syncable |
22 // services. Implements the model associator interface, invoking the | 22 // services. Implements the model associator interface, invoking the |
23 // provided SyncableService as necessary. | 23 // provided SyncableService as necessary. |
24 class SyncableServiceAdapter : public AssociatorInterface { | 24 class SyncableServiceAdapter : public AssociatorInterface { |
25 public: | 25 public: |
26 explicit SyncableServiceAdapter(syncable::ModelType type, | 26 SyncableServiceAdapter(syncable::ModelType type, |
27 SyncableService* service, | 27 SyncableService* service, |
28 GenericChangeProcessor* sync_processor); | 28 GenericChangeProcessor* sync_processor); |
29 virtual ~SyncableServiceAdapter(); | 29 virtual ~SyncableServiceAdapter(); |
30 | 30 |
31 // AssociatorInterface implementation. | 31 // AssociatorInterface implementation. |
32 virtual bool AssociateModels() OVERRIDE; | 32 virtual bool AssociateModels() OVERRIDE; |
33 virtual bool DisassociateModels() OVERRIDE; | 33 virtual bool DisassociateModels() OVERRIDE; |
34 virtual bool SyncModelHasUserCreatedNodes(bool* has_nodes) OVERRIDE; | 34 virtual bool SyncModelHasUserCreatedNodes(bool* has_nodes) OVERRIDE; |
35 virtual void AbortAssociation() OVERRIDE; | 35 virtual void AbortAssociation() OVERRIDE; |
36 virtual bool CryptoReadyIfNecessary() OVERRIDE; | 36 virtual bool CryptoReadyIfNecessary() OVERRIDE; |
37 | 37 |
38 private: | 38 private: |
39 // Whether the SyncableService we wrap is currently syncing or not. | 39 // Whether the SyncableService we wrap is currently syncing or not. |
40 bool syncing_; | 40 bool syncing_; |
41 | 41 |
42 // The data type being provided by this service. | 42 // The data type being provided by this service. |
43 syncable::ModelType type_; | 43 syncable::ModelType type_; |
44 | 44 |
45 // A pointer to the actual local syncable service, which performs all the | 45 // A pointer to the actual local syncable service, which performs all the |
46 // real work. | 46 // real work. |
47 SyncableService* service_; | 47 SyncableService* service_; |
48 | 48 |
49 // The datatype's SyncChange handler that interacts with the sync db. | 49 // The datatype's SyncChange handler that interacts with the sync db. |
50 GenericChangeProcessor* sync_processor_; | 50 GenericChangeProcessor* sync_processor_; |
51 | 51 |
52 DISALLOW_COPY_AND_ASSIGN(SyncableServiceAdapter); | 52 DISALLOW_COPY_AND_ASSIGN(SyncableServiceAdapter); |
53 }; | 53 }; |
54 | 54 |
55 } // namespace browser_sync | 55 } // namespace browser_sync |
56 | 56 |
57 #endif // CHROME_BROWSER_SYNC_GLUE_SYNCABLE_SERVICE_ADAPTER_H_ | 57 #endif // CHROME_BROWSER_SYNC_GLUE_SYNCABLE_SERVICE_ADAPTER_H_ |
OLD | NEW |