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

Side by Side Diff: chrome/browser/chromeos/drive/sync/remove_performer.cc

Issue 321753002: drive: Stop returning ResourceEntry from JobScheduler (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/chromeos/drive/sync/remove_performer.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #include "chrome/browser/chromeos/drive/sync/remove_performer.h" 5 #include "chrome/browser/chromeos/drive/sync/remove_performer.h"
6 6
7 #include "base/sequenced_task_runner.h" 7 #include "base/sequenced_task_runner.h"
8 #include "chrome/browser/chromeos/drive/drive.pb.h" 8 #include "chrome/browser/chromeos/drive/drive.pb.h"
9 #include "chrome/browser/chromeos/drive/file_system/operation_observer.h" 9 #include "chrome/browser/chromeos/drive/file_system/operation_observer.h"
10 #include "chrome/browser/chromeos/drive/file_system_util.h" 10 #include "chrome/browser/chromeos/drive/file_system_util.h"
11 #include "chrome/browser/chromeos/drive/job_scheduler.h" 11 #include "chrome/browser/chromeos/drive/job_scheduler.h"
12 #include "chrome/browser/chromeos/drive/resource_entry_conversion.h" 12 #include "chrome/browser/chromeos/drive/resource_entry_conversion.h"
13 #include "chrome/browser/chromeos/drive/resource_metadata.h" 13 #include "chrome/browser/chromeos/drive/resource_metadata.h"
14 #include "chrome/browser/chromeos/drive/sync/entry_revert_performer.h" 14 #include "chrome/browser/chromeos/drive/sync/entry_revert_performer.h"
15 #include "chrome/browser/drive/drive_api_util.h"
15 #include "content/public/browser/browser_thread.h" 16 #include "content/public/browser/browser_thread.h"
17 #include "google_apis/drive/drive_api_parser.h"
16 #include "google_apis/drive/gdata_wapi_parser.h" 18 #include "google_apis/drive/gdata_wapi_parser.h"
17 19
18 using content::BrowserThread; 20 using content::BrowserThread;
19 21
20 namespace drive { 22 namespace drive {
21 namespace internal { 23 namespace internal {
22 24
23 namespace { 25 namespace {
24 26
25 // Updates local metadata and after remote unparenting. 27 // Updates local metadata and after remote unparenting.
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 callback.Run(error); 171 callback.Run(error);
170 } 172 }
171 173
172 void RemovePerformer::UnparentResource(const ClientContext& context, 174 void RemovePerformer::UnparentResource(const ClientContext& context,
173 const FileOperationCallback& callback, 175 const FileOperationCallback& callback,
174 const std::string& resource_id, 176 const std::string& resource_id,
175 const std::string& local_id) { 177 const std::string& local_id) {
176 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 178 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
177 DCHECK(!callback.is_null()); 179 DCHECK(!callback.is_null());
178 180
179 scheduler_->GetResourceEntry( 181 scheduler_->GetFileResource(
180 resource_id, 182 resource_id,
181 context, 183 context,
182 base::Bind(&RemovePerformer::UnparentResourceAfterGetResourceEntry, 184 base::Bind(&RemovePerformer::UnparentResourceAfterGetFileResource,
183 weak_ptr_factory_.GetWeakPtr(), context, callback, local_id)); 185 weak_ptr_factory_.GetWeakPtr(), context, callback, local_id));
184 } 186 }
185 187
186 void RemovePerformer::UnparentResourceAfterGetResourceEntry( 188 void RemovePerformer::UnparentResourceAfterGetFileResource(
187 const ClientContext& context, 189 const ClientContext& context,
188 const FileOperationCallback& callback, 190 const FileOperationCallback& callback,
189 const std::string& local_id, 191 const std::string& local_id,
190 google_apis::GDataErrorCode status, 192 google_apis::GDataErrorCode status,
191 scoped_ptr<google_apis::ResourceEntry> resource_entry) { 193 scoped_ptr<google_apis::FileResource> file_resource) {
192 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 194 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
193 DCHECK(!callback.is_null()); 195 DCHECK(!callback.is_null());
194 196
195 FileError error = GDataToFileError(status); 197 FileError error = GDataToFileError(status);
196 if (error == FILE_ERROR_NOT_FOUND) { // Remove local entry when not found. 198 if (error == FILE_ERROR_NOT_FOUND) { // Remove local entry when not found.
197 RemoveEntryOnUIThread(blocking_task_runner_.get(), metadata_, local_id, 199 RemoveEntryOnUIThread(blocking_task_runner_.get(), metadata_, local_id,
198 callback); 200 callback);
199 return; 201 return;
200 } 202 }
201 203
202 if (error != FILE_ERROR_OK) { 204 if (error != FILE_ERROR_OK) {
203 callback.Run(error); 205 callback.Run(error);
204 return; 206 return;
205 } 207 }
206 208
207 ResourceEntry entry; 209 ResourceEntry entry;
208 std::string parent_resource_id; 210 std::string parent_resource_id;
209 if (!ConvertToResourceEntry(*resource_entry, &entry, &parent_resource_id)) { 211 if (!ConvertToResourceEntry(
212 *util::ConvertFileResourceToResourceEntry(*file_resource),
213 &entry, &parent_resource_id)) {
210 callback.Run(FILE_ERROR_NOT_A_FILE); 214 callback.Run(FILE_ERROR_NOT_A_FILE);
211 return; 215 return;
212 } 216 }
213 217
214 if (!entry.shared_with_me()) { 218 if (!entry.shared_with_me()) {
215 // shared_with_me() has changed on the server. 219 // shared_with_me() has changed on the server.
216 UnparentResourceAfterUpdateRemoteState(callback, local_id, 220 UnparentResourceAfterUpdateRemoteState(callback, local_id,
217 google_apis::HTTP_CONFLICT); 221 google_apis::HTTP_CONFLICT);
218 return; 222 return;
219 } 223 }
(...skipping 28 matching lines...) Expand all
248 252
249 base::PostTaskAndReplyWithResult( 253 base::PostTaskAndReplyWithResult(
250 blocking_task_runner_.get(), 254 blocking_task_runner_.get(),
251 FROM_HERE, 255 FROM_HERE,
252 base::Bind(&UpdateLocalStateAfterUnparent, metadata_, local_id), 256 base::Bind(&UpdateLocalStateAfterUnparent, metadata_, local_id),
253 callback); 257 callback);
254 } 258 }
255 259
256 } // namespace internal 260 } // namespace internal
257 } // namespace drive 261 } // namespace drive
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/sync/remove_performer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698