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

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: 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
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;
24 class SharedModelTypeProcessor;
23 25
24 // Interface implemented by model types to receive updates from sync via the 26 // Interface implemented by model types to receive updates from sync via the
25 // SharedModelTypeProcessor. Provides a way for sync to update the data and 27 // SharedModelTypeProcessor. Provides a way for sync to update the data and
26 // metadata for entities, as well as the model type state. 28 // metadata for entities, as well as the model type state.
27 class SYNC_EXPORT ModelTypeService { 29 class SYNC_EXPORT ModelTypeService {
28 public: 30 public:
29 typedef base::Callback<void(syncer::SyncError, scoped_ptr<DataBatch>)> 31 typedef base::Callback<void(syncer::SyncError, scoped_ptr<DataBatch>)>
30 DataCallback; 32 DataCallback;
31 typedef std::vector<std::string> ClientTagList; 33 typedef std::vector<std::string> ClientTagList;
34 typedef base::Callback<scoped_ptr<ModelTypeChangeProcessor>(
35 syncer::ModelType,
36 ModelTypeService* service)>
37 SharedProcessorFactory;
maxbogue 2016/03/22 21:40:12 Please call this ChangeProcessorFactory. ModelType
Gang Wu 2016/03/24 15:56:26 Done.
38 typedef base::Callback<void(syncer::SyncError, scoped_ptr<ActivationContext>)>
39 StartCallback;
32 40
33 ModelTypeService(); 41 ModelTypeService(const SharedProcessorFactory& shared_processor_factory);
34 42
35 virtual ~ModelTypeService(); 43 virtual ~ModelTypeService();
36 44
37 // Creates an object used to communicate changes in the sync metadata to the 45 // Creates an object used to communicate changes in the sync metadata to the
38 // model type store. 46 // model type store.
39 virtual scoped_ptr<MetadataChangeList> CreateMetadataChangeList() = 0; 47 virtual scoped_ptr<MetadataChangeList> CreateMetadataChangeList() = 0;
40 48
41 // Perform the initial merge between local and sync data. This should only be 49 // 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 50 // 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 51 // 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; 79 virtual void GetAllData(DataCallback callback) = 0;
72 80
73 // Get or generate a client tag for |entity_data|. 81 // Get or generate a client tag for |entity_data|.
74 virtual std::string GetClientTag(const EntityData& entity_data) = 0; 82 virtual std::string GetClientTag(const EntityData& entity_data) = 0;
75 83
76 // Overridable notification for when the processor is set. This is typically 84 // Overridable notification for when the processor is set. This is typically
77 // when the service should start loading metadata and then subsequently giving 85 // when the service should start loading metadata and then subsequently giving
78 // it to the processor. 86 // it to the processor.
79 virtual void OnChangeProcessorSet() = 0; 87 virtual void OnChangeProcessorSet() = 0;
80 88
89 // Model type for this service.
90 virtual syncer::ModelType type() const = 0;
91
81 // TODO(skym): See crbug/547087, do we need all these accessors? 92 // TODO(skym): See crbug/547087, do we need all these accessors?
82 ModelTypeChangeProcessor* change_processor() const; 93 ModelTypeChangeProcessor* change_processor() const;
83 94
84 void set_change_processor(
85 scoped_ptr<ModelTypeChangeProcessor> change_processor);
86
87 void clear_change_processor(); 95 void clear_change_processor();
88 96
97 void OnSyncStarting(const StartCallback& callback);
maxbogue 2016/03/22 21:40:12 I think you should be returning ModelTypeChangePro
Gang Wu 2016/03/24 15:56:26 Done.
98
99 protected:
100 ModelTypeChangeProcessor* create_change_processor();
101
89 private: 102 private:
90 // Recieves ownership in set_change_processor(...).
91 scoped_ptr<ModelTypeChangeProcessor> change_processor_; 103 scoped_ptr<ModelTypeChangeProcessor> change_processor_;
104
105 SharedProcessorFactory shared_processor_factory_;
92 }; 106 };
93 107
94 } // namespace syncer_v2 108 } // namespace syncer_v2
95 109
96 #endif // SYNC_API_MODEL_TYPE_SERVICE_H_ 110 #endif // SYNC_API_MODEL_TYPE_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698