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

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

Issue 272043002: Invoke AttachmentUploader and update AttachmentIds. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Initialize through SyncApiComponentFactory Created 6 years, 7 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 10 matching lines...) Expand all
21 namespace syncer { 21 namespace syncer {
22 class SyncData; 22 class SyncData;
23 class SyncableService; 23 class SyncableService;
24 class WriteNode; 24 class WriteNode;
25 class WriteTransaction; 25 class WriteTransaction;
26 26
27 typedef std::vector<syncer::SyncData> SyncDataList; 27 typedef std::vector<syncer::SyncData> SyncDataList;
28 } // namespace syncer 28 } // namespace syncer
29 29
30 namespace browser_sync { 30 namespace browser_sync {
31 class SyncApiComponentFactory;
31 32
32 // Datatype agnostic change processor. One instance of GenericChangeProcessor 33 // Datatype agnostic change processor. One instance of GenericChangeProcessor
33 // is created for each datatype and lives on the datatype's thread. It then 34 // is created for each datatype and lives on the datatype's thread. It then
34 // handles all interaction with the sync api, both translating pushes from the 35 // handles all interaction with the sync api, both translating pushes from the
35 // local service into transactions and receiving changes from the sync model, 36 // local service into transactions and receiving changes from the sync model,
36 // which then get converted into SyncChange's and sent to the local service. 37 // which then get converted into SyncChange's and sent to the local service.
37 // 38 //
38 // As a rule, the GenericChangeProcessor is not thread safe, and should only 39 // As a rule, the GenericChangeProcessor is not thread safe, and should only
39 // be used on the same thread in which it was created. 40 // be used on the same thread in which it was created.
40 class GenericChangeProcessor : public ChangeProcessor, 41 class GenericChangeProcessor : public ChangeProcessor,
41 public syncer::SyncChangeProcessor, 42 public syncer::SyncChangeProcessor,
43 public syncer::AttachmentService::Delegate,
42 public base::NonThreadSafe { 44 public base::NonThreadSafe {
43 public: 45 public:
44 // Create a change processor and connect it to the syncer. 46 // Create a change processor and connect it to the syncer.
45 GenericChangeProcessor( 47 GenericChangeProcessor(
46 DataTypeErrorHandler* error_handler, 48 DataTypeErrorHandler* error_handler,
47 const base::WeakPtr<syncer::SyncableService>& local_service, 49 const base::WeakPtr<syncer::SyncableService>& local_service,
48 const base::WeakPtr<syncer::SyncMergeResult>& merge_result, 50 const base::WeakPtr<syncer::SyncMergeResult>& merge_result,
49 syncer::UserShare* user_share, 51 syncer::UserShare* user_share,
50 scoped_ptr<syncer::AttachmentService> attachment_service); 52 SyncApiComponentFactory* sync_factory);
pavely 2014/05/15 19:26:52 The problem with this approach is that now FakeGen
maniscalco 2014/05/15 20:09:28 I think I see what you mean. Creating a mock Sync
51 virtual ~GenericChangeProcessor(); 53 virtual ~GenericChangeProcessor();
52 54
53 // ChangeProcessor interface. 55 // ChangeProcessor interface.
54 // Build and store a list of all changes into |syncer_changes_|. 56 // Build and store a list of all changes into |syncer_changes_|.
55 virtual void ApplyChangesFromSyncModel( 57 virtual void ApplyChangesFromSyncModel(
56 const syncer::BaseTransaction* trans, 58 const syncer::BaseTransaction* trans,
57 int64 version, 59 int64 version,
58 const syncer::ImmutableChangeRecordList& changes) OVERRIDE; 60 const syncer::ImmutableChangeRecordList& changes) OVERRIDE;
59 // Passes |syncer_changes_|, built in ApplyChangesFromSyncModel, onto 61 // Passes |syncer_changes_|, built in ApplyChangesFromSyncModel, onto
60 // |local_service_| by way of its ProcessSyncChanges method. 62 // |local_service_| by way of its ProcessSyncChanges method.
61 virtual void CommitChangesFromSyncModel() OVERRIDE; 63 virtual void CommitChangesFromSyncModel() OVERRIDE;
62 64
63 // syncer::SyncChangeProcessor implementation. 65 // syncer::SyncChangeProcessor implementation.
64 virtual syncer::SyncError ProcessSyncChanges( 66 virtual syncer::SyncError ProcessSyncChanges(
65 const tracked_objects::Location& from_here, 67 const tracked_objects::Location& from_here,
66 const syncer::SyncChangeList& change_list) OVERRIDE; 68 const syncer::SyncChangeList& change_list) OVERRIDE;
67 virtual syncer::SyncDataList GetAllSyncData(syncer::ModelType type) 69 virtual syncer::SyncDataList GetAllSyncData(syncer::ModelType type)
68 const OVERRIDE; 70 const OVERRIDE;
69 virtual syncer::SyncError UpdateDataTypeContext( 71 virtual syncer::SyncError UpdateDataTypeContext(
70 syncer::ModelType type, 72 syncer::ModelType type,
71 syncer::SyncChangeProcessor::ContextRefreshStatus refresh_status, 73 syncer::SyncChangeProcessor::ContextRefreshStatus refresh_status,
72 const std::string& context) OVERRIDE; 74 const std::string& context) OVERRIDE;
73 75
76 // syncer::AttachmentService::Delegate implementation.
77 virtual void OnAttachmentUploaded(
78 const syncer::AttachmentId& attachment_id) OVERRIDE;
79
74 // Similar to above, but returns a SyncError for use by direct clients 80 // Similar to above, but returns a SyncError for use by direct clients
75 // of GenericChangeProcessor that may need more error visibility. 81 // of GenericChangeProcessor that may need more error visibility.
76 virtual syncer::SyncError GetAllSyncDataReturnError( 82 virtual syncer::SyncError GetAllSyncDataReturnError(
77 syncer::ModelType type, 83 syncer::ModelType type,
78 syncer::SyncDataList* data) const; 84 syncer::SyncDataList* data) const;
79 85
80 // If a datatype context associated with |type| exists, fills |context| and 86 // If a datatype context associated with |type| exists, fills |context| and
81 // returns true. Otheriwse, if there has not been a context set, returns 87 // returns true. Otheriwse, if there has not been a context set, returns
82 // false. 88 // false.
83 virtual bool GetDataTypeContext(syncer::ModelType type, 89 virtual bool GetDataTypeContext(syncer::ModelType type,
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 base::WeakPtrFactory<syncer::AttachmentService> 154 base::WeakPtrFactory<syncer::AttachmentService>
149 attachment_service_weak_ptr_factory_; 155 attachment_service_weak_ptr_factory_;
150 syncer::AttachmentServiceProxy attachment_service_proxy_; 156 syncer::AttachmentServiceProxy attachment_service_proxy_;
151 157
152 DISALLOW_COPY_AND_ASSIGN(GenericChangeProcessor); 158 DISALLOW_COPY_AND_ASSIGN(GenericChangeProcessor);
153 }; 159 };
154 160
155 } // namespace browser_sync 161 } // namespace browser_sync
156 162
157 #endif // COMPONENTS_SYNC_DRIVER_GENERIC_CHANGE_PROCESSOR_H_ 163 #endif // COMPONENTS_SYNC_DRIVER_GENERIC_CHANGE_PROCESSOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698