Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(114)

Side by Side Diff: sync/api/model_type_service.h

Issue 1763953002: [USS] Change the place where SharedModelTypeProcessor got created (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sync/api/model_type_change_processor.h ('k') | sync/api/model_type_service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "sync/internal_api/public/activation_context.h"
18 19
19 namespace syncer_v2 { 20 namespace syncer_v2 {
20 21
21 class DataBatch; 22 class DataBatch;
22 class MetadataChangeList; 23 class MetadataChangeList;
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 syncer::ModelType,
35 ModelTypeService* service)>
36 ChangeProcessorFactory;
32 37
33 ModelTypeService(); 38 ModelTypeService(const ChangeProcessorFactory& change_processor_factory,
39 syncer::ModelType type);
34 40
35 virtual ~ModelTypeService(); 41 virtual ~ModelTypeService();
36 42
37 // Creates an object used to communicate changes in the sync metadata to the 43 // Creates an object used to communicate changes in the sync metadata to the
38 // model type store. 44 // model type store.
39 virtual scoped_ptr<MetadataChangeList> CreateMetadataChangeList() = 0; 45 virtual scoped_ptr<MetadataChangeList> CreateMetadataChangeList() = 0;
40 46
41 // Perform the initial merge between local and sync data. This should only be 47 // Perform the initial merge between local and sync data. This should only be
42 // called when a data type is first enabled to start syncing, and there is no 48 // called when a data type is first enabled to start syncing, and there is no
43 // sync metadata. Best effort should be made to match local and sync data. The 49 // sync metadata. Best effort should be made to match local and sync data. The
(...skipping 27 matching lines...) Expand all
71 virtual void GetAllData(DataCallback callback) = 0; 77 virtual void GetAllData(DataCallback callback) = 0;
72 78
73 // Get or generate a client tag for |entity_data|. 79 // Get or generate a client tag for |entity_data|.
74 virtual std::string GetClientTag(const EntityData& entity_data) = 0; 80 virtual std::string GetClientTag(const EntityData& entity_data) = 0;
75 81
76 // Overridable notification for when the processor is set. This is typically 82 // Overridable notification for when the processor is set. This is typically
77 // when the service should start loading metadata and then subsequently giving 83 // when the service should start loading metadata and then subsequently giving
78 // it to the processor. 84 // it to the processor.
79 virtual void OnChangeProcessorSet() = 0; 85 virtual void OnChangeProcessorSet() = 0;
80 86
87 void clear_change_processor();
88
89 ModelTypeChangeProcessor* OnSyncStarting(
90 const ModelTypeChangeProcessor::StartCallback& callback);
91
92 protected:
81 // TODO(skym): See crbug/547087, do we need all these accessors? 93 // TODO(skym): See crbug/547087, do we need all these accessors?
82 ModelTypeChangeProcessor* change_processor() const; 94 ModelTypeChangeProcessor* change_processor() const;
83 95
84 void set_change_processor( 96 ModelTypeChangeProcessor* GetOrCreateChangeProcessor();
85 scoped_ptr<ModelTypeChangeProcessor> change_processor);
86 97
87 void clear_change_processor(); 98 // Model type for this service.
99 syncer::ModelType type() const;
88 100
89 private: 101 private:
90 // Recieves ownership in set_change_processor(...).
91 scoped_ptr<ModelTypeChangeProcessor> change_processor_; 102 scoped_ptr<ModelTypeChangeProcessor> change_processor_;
103
104 ChangeProcessorFactory change_processor_factory_;
105
106 const syncer::ModelType type_;
92 }; 107 };
93 108
94 } // namespace syncer_v2 109 } // namespace syncer_v2
95 110
96 #endif // SYNC_API_MODEL_TYPE_SERVICE_H_ 111 #endif // SYNC_API_MODEL_TYPE_SERVICE_H_
OLDNEW
« no previous file with comments | « sync/api/model_type_change_processor.h ('k') | sync/api/model_type_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698