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

Side by Side Diff: components/sync_driver/generic_change_processor.h

Issue 548373003: Move AttachmentStore ownership to datatype (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Changes after feedback. Created 6 years, 3 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 COMPONENTS_SYNC_DRIVER_GENERIC_CHANGE_PROCESSOR_H_ 5 #ifndef COMPONENTS_SYNC_DRIVER_GENERIC_CHANGE_PROCESSOR_H_
6 #define COMPONENTS_SYNC_DRIVER_GENERIC_CHANGE_PROCESSOR_H_ 6 #define COMPONENTS_SYNC_DRIVER_GENERIC_CHANGE_PROCESSOR_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 27 matching lines...) Expand all
38 // which then get converted into SyncChange's and sent to the local service. 38 // which then get converted into SyncChange's and sent to the local service.
39 // 39 //
40 // As a rule, the GenericChangeProcessor is not thread safe, and should only 40 // As a rule, the GenericChangeProcessor is not thread safe, and should only
41 // be used on the same thread in which it was created. 41 // be used on the same thread in which it was created.
42 class GenericChangeProcessor : public ChangeProcessor, 42 class GenericChangeProcessor : public ChangeProcessor,
43 public syncer::SyncChangeProcessor, 43 public syncer::SyncChangeProcessor,
44 public syncer::AttachmentService::Delegate, 44 public syncer::AttachmentService::Delegate,
45 public base::NonThreadSafe { 45 public base::NonThreadSafe {
46 public: 46 public:
47 // Create a change processor and connect it to the syncer. 47 // Create a change processor and connect it to the syncer.
48 // |attachment_store| can be NULL which means that datatype will not use sync
49 // attachments.
48 GenericChangeProcessor( 50 GenericChangeProcessor(
49 DataTypeErrorHandler* error_handler, 51 DataTypeErrorHandler* error_handler,
50 const base::WeakPtr<syncer::SyncableService>& local_service, 52 const base::WeakPtr<syncer::SyncableService>& local_service,
51 const base::WeakPtr<syncer::SyncMergeResult>& merge_result, 53 const base::WeakPtr<syncer::SyncMergeResult>& merge_result,
52 syncer::UserShare* user_share, 54 syncer::UserShare* user_share,
53 SyncApiComponentFactory* sync_factory); 55 SyncApiComponentFactory* sync_factory,
56 const scoped_refptr<syncer::AttachmentStore>& attachment_store);
54 virtual ~GenericChangeProcessor(); 57 virtual ~GenericChangeProcessor();
55 58
56 // ChangeProcessor interface. 59 // ChangeProcessor interface.
57 // Build and store a list of all changes into |syncer_changes_|. 60 // Build and store a list of all changes into |syncer_changes_|.
58 virtual void ApplyChangesFromSyncModel( 61 virtual void ApplyChangesFromSyncModel(
59 const syncer::BaseTransaction* trans, 62 const syncer::BaseTransaction* trans,
60 int64 version, 63 int64 version,
61 const syncer::ImmutableChangeRecordList& changes) OVERRIDE; 64 const syncer::ImmutableChangeRecordList& changes) OVERRIDE;
62 // Passes |syncer_changes_|, built in ApplyChangesFromSyncModel, onto 65 // Passes |syncer_changes_|, built in ApplyChangesFromSyncModel, onto
63 // |local_service_| by way of its ProcessSyncChanges method. 66 // |local_service_| by way of its ProcessSyncChanges method.
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 // Set in ApplyChangesFromSyncModel, consumed in CommitChangesFromSyncModel. 157 // Set in ApplyChangesFromSyncModel, consumed in CommitChangesFromSyncModel.
155 syncer::SyncChangeList syncer_changes_; 158 syncer::SyncChangeList syncer_changes_;
156 159
157 // Our handle to the sync model. Unlike normal ChangeProcessors, we need to 160 // Our handle to the sync model. Unlike normal ChangeProcessors, we need to
158 // be able to access the sync model before the change processor begins 161 // be able to access the sync model before the change processor begins
159 // listening to changes (the local_service_ will be interacting with us 162 // listening to changes (the local_service_ will be interacting with us
160 // when it starts up). As such we can't wait until Start(_) has been called, 163 // when it starts up). As such we can't wait until Start(_) has been called,
161 // and have to keep a local pointer to the user_share. 164 // and have to keep a local pointer to the user_share.
162 syncer::UserShare* const share_handle_; 165 syncer::UserShare* const share_handle_;
163 166
167 // AttachmentService for datatype. Can be NULL if datatype doesn't use
168 // attachments.
164 scoped_ptr<syncer::AttachmentService> attachment_service_; 169 scoped_ptr<syncer::AttachmentService> attachment_service_;
170
165 // Must be destroyed before attachment_service_ to ensure WeakPtrs are 171 // Must be destroyed before attachment_service_ to ensure WeakPtrs are
166 // invalidated before attachment_service_ is destroyed. 172 // invalidated before attachment_service_ is destroyed.
167 base::WeakPtrFactory<syncer::AttachmentService> 173 // Can be NULL if attachment_service_ is NULL;
174 scoped_ptr<base::WeakPtrFactory<syncer::AttachmentService> >
168 attachment_service_weak_ptr_factory_; 175 attachment_service_weak_ptr_factory_;
169 syncer::AttachmentServiceProxy attachment_service_proxy_; 176 scoped_ptr<syncer::AttachmentServiceProxy> attachment_service_proxy_;
170 177
171 base::WeakPtrFactory<GenericChangeProcessor> weak_ptr_factory_; 178 base::WeakPtrFactory<GenericChangeProcessor> weak_ptr_factory_;
172 179
173 DISALLOW_COPY_AND_ASSIGN(GenericChangeProcessor); 180 DISALLOW_COPY_AND_ASSIGN(GenericChangeProcessor);
174 }; 181 };
175 182
176 } // namespace sync_driver 183 } // namespace sync_driver
177 184
178 #endif // COMPONENTS_SYNC_DRIVER_GENERIC_CHANGE_PROCESSOR_H_ 185 #endif // COMPONENTS_SYNC_DRIVER_GENERIC_CHANGE_PROCESSOR_H_
OLDNEW
« no previous file with comments | « components/sync_driver/fake_generic_change_processor.cc ('k') | components/sync_driver/generic_change_processor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698