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

Side by Side Diff: chrome/browser/chromeos/drive/file_system/download_operation.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/file_system/download_operation.h" 5 #include "chrome/browser/chromeos/drive/file_system/download_operation.h"
6 6
7 #include "base/callback_helpers.h" 7 #include "base/callback_helpers.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 353
354 DownloadOperation::~DownloadOperation() { 354 DownloadOperation::~DownloadOperation() {
355 } 355 }
356 356
357 base::Closure DownloadOperation::EnsureFileDownloadedByLocalId( 357 base::Closure DownloadOperation::EnsureFileDownloadedByLocalId(
358 const std::string& local_id, 358 const std::string& local_id,
359 const ClientContext& context, 359 const ClientContext& context,
360 const GetFileContentInitializedCallback& initialized_callback, 360 const GetFileContentInitializedCallback& initialized_callback,
361 const google_apis::GetContentCallback& get_content_callback, 361 const google_apis::GetContentCallback& get_content_callback,
362 const GetFileCallback& completion_callback) { 362 const GetFileCallback& completion_callback) {
363 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 363 DCHECK_CURRENTLY_ON(BrowserThread::UI);
364 DCHECK(!completion_callback.is_null()); 364 DCHECK(!completion_callback.is_null());
365 365
366 CheckPreconditionForEnsureFileDownloadedParams params; 366 CheckPreconditionForEnsureFileDownloadedParams params;
367 params.metadata = metadata_; 367 params.metadata = metadata_;
368 params.cache = cache_; 368 params.cache = cache_;
369 params.temporary_file_directory = temporary_file_directory_; 369 params.temporary_file_directory = temporary_file_directory_;
370 base::FilePath* drive_file_path = new base::FilePath; 370 base::FilePath* drive_file_path = new base::FilePath;
371 base::FilePath* cache_file_path = new base::FilePath; 371 base::FilePath* cache_file_path = new base::FilePath;
372 base::FilePath* temp_download_file_path = new base::FilePath; 372 base::FilePath* temp_download_file_path = new base::FilePath;
373 ResourceEntry* entry = new ResourceEntry; 373 ResourceEntry* entry = new ResourceEntry;
(...skipping 20 matching lines...) Expand all
394 base::Owned(temp_download_file_path))); 394 base::Owned(temp_download_file_path)));
395 return cancel_closure; 395 return cancel_closure;
396 } 396 }
397 397
398 base::Closure DownloadOperation::EnsureFileDownloadedByPath( 398 base::Closure DownloadOperation::EnsureFileDownloadedByPath(
399 const base::FilePath& file_path, 399 const base::FilePath& file_path,
400 const ClientContext& context, 400 const ClientContext& context,
401 const GetFileContentInitializedCallback& initialized_callback, 401 const GetFileContentInitializedCallback& initialized_callback,
402 const google_apis::GetContentCallback& get_content_callback, 402 const google_apis::GetContentCallback& get_content_callback,
403 const GetFileCallback& completion_callback) { 403 const GetFileCallback& completion_callback) {
404 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 404 DCHECK_CURRENTLY_ON(BrowserThread::UI);
405 DCHECK(!completion_callback.is_null()); 405 DCHECK(!completion_callback.is_null());
406 406
407 CheckPreconditionForEnsureFileDownloadedParams params; 407 CheckPreconditionForEnsureFileDownloadedParams params;
408 params.metadata = metadata_; 408 params.metadata = metadata_;
409 params.cache = cache_; 409 params.cache = cache_;
410 params.temporary_file_directory = temporary_file_directory_; 410 params.temporary_file_directory = temporary_file_directory_;
411 base::FilePath* drive_file_path = new base::FilePath(file_path); 411 base::FilePath* drive_file_path = new base::FilePath(file_path);
412 base::FilePath* cache_file_path = new base::FilePath; 412 base::FilePath* cache_file_path = new base::FilePath;
413 base::FilePath* temp_download_file_path = new base::FilePath; 413 base::FilePath* temp_download_file_path = new base::FilePath;
414 ResourceEntry* entry = new ResourceEntry; 414 ResourceEntry* entry = new ResourceEntry;
(...skipping 20 matching lines...) Expand all
435 return cancel_closure; 435 return cancel_closure;
436 } 436 }
437 437
438 void DownloadOperation::EnsureFileDownloadedAfterCheckPreCondition( 438 void DownloadOperation::EnsureFileDownloadedAfterCheckPreCondition(
439 scoped_ptr<DownloadParams> params, 439 scoped_ptr<DownloadParams> params,
440 const ClientContext& context, 440 const ClientContext& context,
441 base::FilePath* drive_file_path, 441 base::FilePath* drive_file_path,
442 base::FilePath* cache_file_path, 442 base::FilePath* cache_file_path,
443 base::FilePath* temp_download_file_path, 443 base::FilePath* temp_download_file_path,
444 FileError error) { 444 FileError error) {
445 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 445 DCHECK_CURRENTLY_ON(BrowserThread::UI);
446 DCHECK(params); 446 DCHECK(params);
447 DCHECK(drive_file_path); 447 DCHECK(drive_file_path);
448 DCHECK(cache_file_path); 448 DCHECK(cache_file_path);
449 449
450 if (error != FILE_ERROR_OK) { 450 if (error != FILE_ERROR_OK) {
451 // During precondition check, an error is found. 451 // During precondition check, an error is found.
452 params->OnError(error); 452 params->OnError(error);
453 return; 453 return;
454 } 454 }
455 455
(...skipping 26 matching lines...) Expand all
482 params_ptr->OnStartDownloading( 482 params_ptr->OnStartDownloading(
483 base::Bind(&DownloadOperation::CancelJob, 483 base::Bind(&DownloadOperation::CancelJob,
484 weak_ptr_factory_.GetWeakPtr(), id)); 484 weak_ptr_factory_.GetWeakPtr(), id));
485 } 485 }
486 486
487 void DownloadOperation::EnsureFileDownloadedAfterDownloadFile( 487 void DownloadOperation::EnsureFileDownloadedAfterDownloadFile(
488 const base::FilePath& drive_file_path, 488 const base::FilePath& drive_file_path,
489 scoped_ptr<DownloadParams> params, 489 scoped_ptr<DownloadParams> params,
490 google_apis::DriveApiErrorCode gdata_error, 490 google_apis::DriveApiErrorCode gdata_error,
491 const base::FilePath& downloaded_file_path) { 491 const base::FilePath& downloaded_file_path) {
492 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 492 DCHECK_CURRENTLY_ON(BrowserThread::UI);
493 493
494 DownloadParams* params_ptr = params.get(); 494 DownloadParams* params_ptr = params.get();
495 ResourceEntry* entry_after_update = new ResourceEntry; 495 ResourceEntry* entry_after_update = new ResourceEntry;
496 base::FilePath* cache_file_path = new base::FilePath; 496 base::FilePath* cache_file_path = new base::FilePath;
497 base::PostTaskAndReplyWithResult( 497 base::PostTaskAndReplyWithResult(
498 blocking_task_runner_.get(), 498 blocking_task_runner_.get(),
499 FROM_HERE, 499 FROM_HERE,
500 base::Bind(&UpdateLocalStateForDownloadFile, 500 base::Bind(&UpdateLocalStateForDownloadFile,
501 metadata_, 501 metadata_,
502 cache_, 502 cache_,
503 params_ptr->entry(), 503 params_ptr->entry(),
504 gdata_error, 504 gdata_error,
505 downloaded_file_path, 505 downloaded_file_path,
506 entry_after_update, 506 entry_after_update,
507 cache_file_path), 507 cache_file_path),
508 base::Bind(&DownloadOperation::EnsureFileDownloadedAfterUpdateLocalState, 508 base::Bind(&DownloadOperation::EnsureFileDownloadedAfterUpdateLocalState,
509 weak_ptr_factory_.GetWeakPtr(), 509 weak_ptr_factory_.GetWeakPtr(),
510 drive_file_path, 510 drive_file_path,
511 base::Passed(&params), 511 base::Passed(&params),
512 base::Passed(make_scoped_ptr(entry_after_update)), 512 base::Passed(make_scoped_ptr(entry_after_update)),
513 base::Owned(cache_file_path))); 513 base::Owned(cache_file_path)));
514 } 514 }
515 515
516 void DownloadOperation::EnsureFileDownloadedAfterUpdateLocalState( 516 void DownloadOperation::EnsureFileDownloadedAfterUpdateLocalState(
517 const base::FilePath& file_path, 517 const base::FilePath& file_path,
518 scoped_ptr<DownloadParams> params, 518 scoped_ptr<DownloadParams> params,
519 scoped_ptr<ResourceEntry> entry_after_update, 519 scoped_ptr<ResourceEntry> entry_after_update,
520 base::FilePath* cache_file_path, 520 base::FilePath* cache_file_path,
521 FileError error) { 521 FileError error) {
522 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 522 DCHECK_CURRENTLY_ON(BrowserThread::UI);
523 523
524 if (error != FILE_ERROR_OK) { 524 if (error != FILE_ERROR_OK) {
525 params->OnError(error); 525 params->OnError(error);
526 return; 526 return;
527 } 527 }
528 DCHECK(!entry_after_update->file_info().is_directory()); 528 DCHECK(!entry_after_update->file_info().is_directory());
529 529
530 FileChange changed_files; 530 FileChange changed_files;
531 changed_files.Update( 531 changed_files.Update(
532 file_path, FileChange::FILE_TYPE_FILE, FileChange::ADD_OR_UPDATE); 532 file_path, FileChange::FILE_TYPE_FILE, FileChange::ADD_OR_UPDATE);
533 // Storing to cache changes the "offline available" status, hence notify. 533 // Storing to cache changes the "offline available" status, hence notify.
534 delegate_->OnFileChangedByOperation(changed_files); 534 delegate_->OnFileChangedByOperation(changed_files);
535 params->OnDownloadCompleted(*cache_file_path, entry_after_update.Pass()); 535 params->OnDownloadCompleted(*cache_file_path, entry_after_update.Pass());
536 } 536 }
537 537
538 void DownloadOperation::CancelJob(JobID job_id) { 538 void DownloadOperation::CancelJob(JobID job_id) {
539 scheduler_->CancelJob(job_id); 539 scheduler_->CancelJob(job_id);
540 } 540 }
541 541
542 } // namespace file_system 542 } // namespace file_system
543 } // namespace drive 543 } // namespace drive
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698