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

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

Issue 548533003: Replace AttachmentStore's StoreAttachments with UploadAttachments. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Call get() on scoped_refptr. 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
« no previous file with comments | « no previous file | components/sync_driver/generic_change_processor.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 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"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "base/threading/non_thread_safe.h" 12 #include "base/threading/non_thread_safe.h"
13 #include "components/sync_driver/change_processor.h" 13 #include "components/sync_driver/change_processor.h"
14 #include "components/sync_driver/data_type_controller.h" 14 #include "components/sync_driver/data_type_controller.h"
15 #include "components/sync_driver/data_type_error_handler.h" 15 #include "components/sync_driver/data_type_error_handler.h"
16 #include "sync/api/attachments/attachment_store.h"
16 #include "sync/api/sync_change_processor.h" 17 #include "sync/api/sync_change_processor.h"
17 #include "sync/api/sync_merge_result.h" 18 #include "sync/api/sync_merge_result.h"
18 #include "sync/internal_api/public/attachments/attachment_service.h" 19 #include "sync/internal_api/public/attachments/attachment_service.h"
19 #include "sync/internal_api/public/attachments/attachment_service_proxy.h" 20 #include "sync/internal_api/public/attachments/attachment_service_proxy.h"
20 21
21 namespace syncer { 22 namespace syncer {
22 class SyncData; 23 class SyncData;
23 class SyncableService; 24 class SyncableService;
24 class WriteNode; 25 class WriteNode;
25 class WriteTransaction; 26 class WriteTransaction;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 // 120 //
120 // |new_attachments| is an output parameter containing newly added attachments 121 // |new_attachments| is an output parameter containing newly added attachments
121 // that need to be stored. This method will append to it. 122 // that need to be stored. This method will append to it.
122 syncer::SyncError HandleActionUpdate(const syncer::SyncChange& change, 123 syncer::SyncError HandleActionUpdate(const syncer::SyncChange& change,
123 const std::string& type_str, 124 const std::string& type_str,
124 const syncer::ModelType& type, 125 const syncer::ModelType& type,
125 const syncer::WriteTransaction& trans, 126 const syncer::WriteTransaction& trans,
126 syncer::WriteNode* sync_node, 127 syncer::WriteNode* sync_node,
127 syncer::AttachmentList* new_attachments); 128 syncer::AttachmentList* new_attachments);
128 129
130 // Store |attachments| locally then upload them to the sync server.
131 //
132 // Store and uploading are asynchronous operations. |WriteAttachmentsDone|
133 // will be invoked once the attachments have been stored on the local device.
134 void StoreAndUploadAttachments(const syncer::AttachmentList& attachments);
135
136 // Invoked once attachments have been stored locally.
137 //
138 // See also AttachmentStore::WriteCallback.
139 void WriteAttachmentsDone(const syncer::AttachmentList& attachments,
140 const syncer::AttachmentStore::Result& result);
141
129 // The SyncableService this change processor will forward changes on to. 142 // The SyncableService this change processor will forward changes on to.
130 const base::WeakPtr<syncer::SyncableService> local_service_; 143 const base::WeakPtr<syncer::SyncableService> local_service_;
131 144
132 // A SyncMergeResult used to track the changes made during association. The 145 // A SyncMergeResult used to track the changes made during association. The
133 // owner will invalidate the weak pointer when association is complete. While 146 // owner will invalidate the weak pointer when association is complete. While
134 // the pointer is valid though, we increment it with any changes received 147 // the pointer is valid though, we increment it with any changes received
135 // via ProcessSyncChanges. 148 // via ProcessSyncChanges.
136 const base::WeakPtr<syncer::SyncMergeResult> merge_result_; 149 const base::WeakPtr<syncer::SyncMergeResult> merge_result_;
137 150
138 // The current list of changes received from the syncer. We buffer because 151 // The current list of changes received from the syncer. We buffer because
139 // we must ensure no syncapi transaction is held when we pass it on to 152 // we must ensure no syncapi transaction is held when we pass it on to
140 // |local_service_|. 153 // |local_service_|.
141 // Set in ApplyChangesFromSyncModel, consumed in CommitChangesFromSyncModel. 154 // Set in ApplyChangesFromSyncModel, consumed in CommitChangesFromSyncModel.
142 syncer::SyncChangeList syncer_changes_; 155 syncer::SyncChangeList syncer_changes_;
143 156
144 // Our handle to the sync model. Unlike normal ChangeProcessors, we need to 157 // Our handle to the sync model. Unlike normal ChangeProcessors, we need to
145 // be able to access the sync model before the change processor begins 158 // be able to access the sync model before the change processor begins
146 // listening to changes (the local_service_ will be interacting with us 159 // listening to changes (the local_service_ will be interacting with us
147 // when it starts up). As such we can't wait until Start(_) has been called, 160 // when it starts up). As such we can't wait until Start(_) has been called,
148 // and have to keep a local pointer to the user_share. 161 // and have to keep a local pointer to the user_share.
149 syncer::UserShare* const share_handle_; 162 syncer::UserShare* const share_handle_;
150 163
151 scoped_ptr<syncer::AttachmentService> attachment_service_; 164 scoped_ptr<syncer::AttachmentService> attachment_service_;
152 // Must be destroyed before attachment_service_ to ensure WeakPtrs are 165 // Must be destroyed before attachment_service_ to ensure WeakPtrs are
153 // invalidated before attachment_service_ is destroyed. 166 // invalidated before attachment_service_ is destroyed.
154 base::WeakPtrFactory<syncer::AttachmentService> 167 base::WeakPtrFactory<syncer::AttachmentService>
155 attachment_service_weak_ptr_factory_; 168 attachment_service_weak_ptr_factory_;
156 syncer::AttachmentServiceProxy attachment_service_proxy_; 169 syncer::AttachmentServiceProxy attachment_service_proxy_;
157 170
171 base::WeakPtrFactory<GenericChangeProcessor> weak_ptr_factory_;
172
158 DISALLOW_COPY_AND_ASSIGN(GenericChangeProcessor); 173 DISALLOW_COPY_AND_ASSIGN(GenericChangeProcessor);
159 }; 174 };
160 175
161 } // namespace sync_driver 176 } // namespace sync_driver
162 177
163 #endif // COMPONENTS_SYNC_DRIVER_GENERIC_CHANGE_PROCESSOR_H_ 178 #endif // COMPONENTS_SYNC_DRIVER_GENERIC_CHANGE_PROCESSOR_H_
OLDNEW
« no previous file with comments | « no previous file | components/sync_driver/generic_change_processor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698