OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 SYNC_API_MODEL_TYPE_SERVICE_H_ | 5 #ifndef SYNC_API_MODEL_TYPE_SERVICE_H_ |
6 #define SYNC_API_MODEL_TYPE_SERVICE_H_ | 6 #define SYNC_API_MODEL_TYPE_SERVICE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "sync/api/entity_change.h" | 13 #include "sync/api/entity_change.h" |
14 #include "sync/api/entity_data.h" | 14 #include "sync/api/entity_data.h" |
15 #include "sync/api/model_type_change_processor.h" | 15 #include "sync/api/model_type_change_processor.h" |
16 #include "sync/api/sync_error.h" | 16 #include "sync/api/sync_error.h" |
17 #include "sync/base/sync_export.h" | 17 #include "sync/base/sync_export.h" |
18 | 18 |
19 namespace syncer_v2 { | 19 namespace syncer_v2 { |
20 | 20 |
21 class DataBatch; | 21 class DataBatch; |
22 class MetadataChangeList; | 22 class MetadataChangeList; |
23 class SharedModelTypeProcessor; | |
23 | 24 |
24 // Interface implemented by model types to receive updates from sync via the | 25 // Interface implemented by model types to receive updates from sync via the |
25 // SharedModelTypeProcessor. Provides a way for sync to update the data and | 26 // SharedModelTypeProcessor. Provides a way for sync to update the data and |
26 // metadata for entities, as well as the model type state. | 27 // metadata for entities, as well as the model type state. |
27 class SYNC_EXPORT ModelTypeService { | 28 class SYNC_EXPORT ModelTypeService { |
28 public: | 29 public: |
29 typedef base::Callback<void(syncer::SyncError, scoped_ptr<DataBatch>)> | 30 typedef base::Callback<void(syncer::SyncError, scoped_ptr<DataBatch>)> |
30 DataCallback; | 31 DataCallback; |
31 typedef std::vector<std::string> ClientTagList; | 32 typedef std::vector<std::string> ClientTagList; |
33 typedef base::Callback<scoped_ptr<ModelTypeChangeProcessor>( | |
34 ModelTypeService* service)> | |
35 SharedProcessorFactory; | |
32 | 36 |
33 ModelTypeService(); | 37 ModelTypeService(); |
34 | 38 |
35 virtual ~ModelTypeService(); | 39 virtual ~ModelTypeService(); |
36 | 40 |
37 // Creates an object used to communicate changes in the sync metadata to the | 41 // Creates an object used to communicate changes in the sync metadata to the |
38 // model type store. | 42 // model type store. |
39 virtual scoped_ptr<MetadataChangeList> CreateMetadataChangeList() = 0; | 43 virtual scoped_ptr<MetadataChangeList> CreateMetadataChangeList() = 0; |
40 | 44 |
41 // Perform the initial merge between local and sync data. This should only be | 45 // Perform the initial merge between local and sync data. This should only be |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
74 virtual std::string GetClientTag(const EntityData& entity_data) = 0; | 78 virtual std::string GetClientTag(const EntityData& entity_data) = 0; |
75 | 79 |
76 // Overridable notification for when the processor is set. This is typically | 80 // Overridable notification for when the processor is set. This is typically |
77 // when the service should start loading metadata and then subsequently giving | 81 // when the service should start loading metadata and then subsequently giving |
78 // it to the processor. | 82 // it to the processor. |
79 virtual void OnChangeProcessorSet() = 0; | 83 virtual void OnChangeProcessorSet() = 0; |
80 | 84 |
81 // TODO(skym): See crbug/547087, do we need all these accessors? | 85 // TODO(skym): See crbug/547087, do we need all these accessors? |
82 ModelTypeChangeProcessor* change_processor() const; | 86 ModelTypeChangeProcessor* change_processor() const; |
83 | 87 |
84 void set_change_processor( | 88 // The function will create SharedModelTypeProcessor and send |
85 scoped_ptr<ModelTypeChangeProcessor> change_processor); | 89 // notification(OnChangeProcessorSet). |
90 ModelTypeChangeProcessor* InitializeProcessor( | |
maxbogue
2016/03/15 17:37:33
The service might need to create the processor bef
| |
91 const SharedProcessorFactory& shared_processor_factory); | |
86 | 92 |
87 void clear_change_processor(); | 93 void clear_change_processor(); |
88 | 94 |
89 private: | 95 private: |
90 // Recieves ownership in set_change_processor(...). | |
91 scoped_ptr<ModelTypeChangeProcessor> change_processor_; | 96 scoped_ptr<ModelTypeChangeProcessor> change_processor_; |
92 }; | 97 }; |
93 | 98 |
94 } // namespace syncer_v2 | 99 } // namespace syncer_v2 |
95 | 100 |
96 #endif // SYNC_API_MODEL_TYPE_SERVICE_H_ | 101 #endif // SYNC_API_MODEL_TYPE_SERVICE_H_ |
OLD | NEW |