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

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

Issue 1036723003: favor DCHECK_CURRENTLY_ON for better logs in chrome/browser/chromeos/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 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/entry_update_performer.h" 5 #include "chrome/browser/chromeos/drive/sync/entry_update_performer.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/callback_helpers.h" 9 #include "base/callback_helpers.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 loader_controller_(loader_controller), 233 loader_controller_(loader_controller),
234 remove_performer_(new RemovePerformer(blocking_task_runner, 234 remove_performer_(new RemovePerformer(blocking_task_runner,
235 delegate, 235 delegate,
236 scheduler, 236 scheduler,
237 metadata)), 237 metadata)),
238 entry_revert_performer_(new EntryRevertPerformer(blocking_task_runner, 238 entry_revert_performer_(new EntryRevertPerformer(blocking_task_runner,
239 delegate, 239 delegate,
240 scheduler, 240 scheduler,
241 metadata)), 241 metadata)),
242 weak_ptr_factory_(this) { 242 weak_ptr_factory_(this) {
243 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 243 DCHECK_CURRENTLY_ON(BrowserThread::UI);
244 } 244 }
245 245
246 EntryUpdatePerformer::~EntryUpdatePerformer() { 246 EntryUpdatePerformer::~EntryUpdatePerformer() {
247 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 247 DCHECK_CURRENTLY_ON(BrowserThread::UI);
248 } 248 }
249 249
250 void EntryUpdatePerformer::UpdateEntry(const std::string& local_id, 250 void EntryUpdatePerformer::UpdateEntry(const std::string& local_id,
251 const ClientContext& context, 251 const ClientContext& context,
252 const FileOperationCallback& callback) { 252 const FileOperationCallback& callback) {
253 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 253 DCHECK_CURRENTLY_ON(BrowserThread::UI);
254 DCHECK(!callback.is_null()); 254 DCHECK(!callback.is_null());
255 255
256 scoped_ptr<LocalState> local_state(new LocalState); 256 scoped_ptr<LocalState> local_state(new LocalState);
257 LocalState* const local_state_ptr = local_state.get(); 257 LocalState* const local_state_ptr = local_state.get();
258 base::PostTaskAndReplyWithResult( 258 base::PostTaskAndReplyWithResult(
259 blocking_task_runner_.get(), 259 blocking_task_runner_.get(),
260 FROM_HERE, 260 FROM_HERE,
261 base::Bind(&PrepareUpdate, metadata_, cache_, local_id, local_state_ptr), 261 base::Bind(&PrepareUpdate, metadata_, cache_, local_id, local_state_ptr),
262 base::Bind(&EntryUpdatePerformer::UpdateEntryAfterPrepare, 262 base::Bind(&EntryUpdatePerformer::UpdateEntryAfterPrepare,
263 weak_ptr_factory_.GetWeakPtr(), context, callback, 263 weak_ptr_factory_.GetWeakPtr(), context, callback,
264 base::Passed(&local_state))); 264 base::Passed(&local_state)));
265 } 265 }
266 266
267 void EntryUpdatePerformer::UpdateEntryAfterPrepare( 267 void EntryUpdatePerformer::UpdateEntryAfterPrepare(
268 const ClientContext& context, 268 const ClientContext& context,
269 const FileOperationCallback& callback, 269 const FileOperationCallback& callback,
270 scoped_ptr<LocalState> local_state, 270 scoped_ptr<LocalState> local_state,
271 FileError error) { 271 FileError error) {
272 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 272 DCHECK_CURRENTLY_ON(BrowserThread::UI);
273 DCHECK(!callback.is_null()); 273 DCHECK(!callback.is_null());
274 274
275 if (error != FILE_ERROR_OK) { 275 if (error != FILE_ERROR_OK) {
276 callback.Run(error); 276 callback.Run(error);
277 return; 277 return;
278 } 278 }
279 279
280 // Trashed entry should be removed. 280 // Trashed entry should be removed.
281 if (local_state->entry.parent_local_id() == util::kDriveTrashDirLocalId) { 281 if (local_state->entry.parent_local_id() == util::kDriveTrashDirLocalId) {
282 remove_performer_->Remove(local_state->entry.local_id(), context, callback); 282 remove_performer_->Remove(local_state->entry.local_id(), context, callback);
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 base::Passed(scoped_ptr<base::ScopedClosureRunner>()))); 400 base::Passed(scoped_ptr<base::ScopedClosureRunner>())));
401 } 401 }
402 402
403 void EntryUpdatePerformer::UpdateEntryAfterUpdateResource( 403 void EntryUpdatePerformer::UpdateEntryAfterUpdateResource(
404 const ClientContext& context, 404 const ClientContext& context,
405 const FileOperationCallback& callback, 405 const FileOperationCallback& callback,
406 scoped_ptr<LocalState> local_state, 406 scoped_ptr<LocalState> local_state,
407 scoped_ptr<base::ScopedClosureRunner> loader_lock, 407 scoped_ptr<base::ScopedClosureRunner> loader_lock,
408 google_apis::DriveApiErrorCode status, 408 google_apis::DriveApiErrorCode status,
409 scoped_ptr<google_apis::FileResource> entry) { 409 scoped_ptr<google_apis::FileResource> entry) {
410 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 410 DCHECK_CURRENTLY_ON(BrowserThread::UI);
411 DCHECK(!callback.is_null()); 411 DCHECK(!callback.is_null());
412 412
413 if (status == google_apis::HTTP_FORBIDDEN) { 413 if (status == google_apis::HTTP_FORBIDDEN) {
414 // Editing this entry is not allowed, revert local changes. 414 // Editing this entry is not allowed, revert local changes.
415 entry_revert_performer_->RevertEntry(local_state->entry.local_id(), context, 415 entry_revert_performer_->RevertEntry(local_state->entry.local_id(), context,
416 callback); 416 callback);
417 return; 417 return;
418 } 418 }
419 419
420 FileError error = GDataToFileError(status); 420 FileError error = GDataToFileError(status);
421 if (error != FILE_ERROR_OK) { 421 if (error != FILE_ERROR_OK) {
422 callback.Run(error); 422 callback.Run(error);
423 return; 423 return;
424 } 424 }
425 425
426 FileChange* changed_files = new FileChange; 426 FileChange* changed_files = new FileChange;
427 base::PostTaskAndReplyWithResult( 427 base::PostTaskAndReplyWithResult(
428 blocking_task_runner_.get(), FROM_HERE, 428 blocking_task_runner_.get(), FROM_HERE,
429 base::Bind(&FinishUpdate, metadata_, cache_, base::Passed(&local_state), 429 base::Bind(&FinishUpdate, metadata_, cache_, base::Passed(&local_state),
430 base::Passed(&entry), changed_files), 430 base::Passed(&entry), changed_files),
431 base::Bind(&EntryUpdatePerformer::UpdateEntryAfterFinish, 431 base::Bind(&EntryUpdatePerformer::UpdateEntryAfterFinish,
432 weak_ptr_factory_.GetWeakPtr(), callback, 432 weak_ptr_factory_.GetWeakPtr(), callback,
433 base::Owned(changed_files))); 433 base::Owned(changed_files)));
434 } 434 }
435 435
436 void EntryUpdatePerformer::UpdateEntryAfterFinish( 436 void EntryUpdatePerformer::UpdateEntryAfterFinish(
437 const FileOperationCallback& callback, 437 const FileOperationCallback& callback,
438 const FileChange* changed_files, 438 const FileChange* changed_files,
439 FileError error) { 439 FileError error) {
440 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 440 DCHECK_CURRENTLY_ON(BrowserThread::UI);
441 DCHECK(!callback.is_null()); 441 DCHECK(!callback.is_null());
442 442
443 delegate_->OnFileChangedByOperation(*changed_files); 443 delegate_->OnFileChangedByOperation(*changed_files);
444 callback.Run(error); 444 callback.Run(error);
445 } 445 }
446 446
447 } // namespace internal 447 } // namespace internal
448 } // namespace drive 448 } // namespace drive
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/sync/entry_revert_performer.cc ('k') | chrome/browser/chromeos/drive/sync/remove_performer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698