| OLD | NEW |
| 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/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
| 12 #include "base/task_runner_util.h" | 12 #include "base/task_runner_util.h" |
| 13 #include "chrome/browser/chromeos/drive/drive.pb.h" | 13 #include "chrome/browser/chromeos/drive/drive.pb.h" |
| 14 #include "chrome/browser/chromeos/drive/file_cache.h" | 14 #include "chrome/browser/chromeos/drive/file_cache.h" |
| 15 #include "chrome/browser/chromeos/drive/file_change.h" | 15 #include "chrome/browser/chromeos/drive/file_change.h" |
| 16 #include "chrome/browser/chromeos/drive/file_errors.h" | 16 #include "chrome/browser/chromeos/drive/file_errors.h" |
| 17 #include "chrome/browser/chromeos/drive/file_system/operation_observer.h" | 17 #include "chrome/browser/chromeos/drive/file_system/operation_delegate.h" |
| 18 #include "chrome/browser/chromeos/drive/file_system_util.h" | 18 #include "chrome/browser/chromeos/drive/file_system_util.h" |
| 19 #include "chrome/browser/chromeos/drive/job_scheduler.h" | 19 #include "chrome/browser/chromeos/drive/job_scheduler.h" |
| 20 #include "chrome/browser/chromeos/drive/resource_entry_conversion.h" | 20 #include "chrome/browser/chromeos/drive/resource_entry_conversion.h" |
| 21 #include "chrome/browser/chromeos/drive/resource_metadata.h" | 21 #include "chrome/browser/chromeos/drive/resource_metadata.h" |
| 22 #include "content/public/browser/browser_thread.h" | 22 #include "content/public/browser/browser_thread.h" |
| 23 #include "google_apis/drive/gdata_errorcode.h" | 23 #include "google_apis/drive/gdata_errorcode.h" |
| 24 | 24 |
| 25 using content::BrowserThread; | 25 using content::BrowserThread; |
| 26 | 26 |
| 27 namespace drive { | 27 namespace drive { |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 scoped_ptr<ResourceEntry> entry_; | 333 scoped_ptr<ResourceEntry> entry_; |
| 334 base::Closure cancel_download_closure_; | 334 base::Closure cancel_download_closure_; |
| 335 bool was_cancelled_; | 335 bool was_cancelled_; |
| 336 | 336 |
| 337 base::WeakPtrFactory<DownloadParams> weak_ptr_factory_; | 337 base::WeakPtrFactory<DownloadParams> weak_ptr_factory_; |
| 338 DISALLOW_COPY_AND_ASSIGN(DownloadParams); | 338 DISALLOW_COPY_AND_ASSIGN(DownloadParams); |
| 339 }; | 339 }; |
| 340 | 340 |
| 341 DownloadOperation::DownloadOperation( | 341 DownloadOperation::DownloadOperation( |
| 342 base::SequencedTaskRunner* blocking_task_runner, | 342 base::SequencedTaskRunner* blocking_task_runner, |
| 343 OperationObserver* observer, | 343 OperationDelegate* delegate, |
| 344 JobScheduler* scheduler, | 344 JobScheduler* scheduler, |
| 345 internal::ResourceMetadata* metadata, | 345 internal::ResourceMetadata* metadata, |
| 346 internal::FileCache* cache, | 346 internal::FileCache* cache, |
| 347 const base::FilePath& temporary_file_directory) | 347 const base::FilePath& temporary_file_directory) |
| 348 : blocking_task_runner_(blocking_task_runner), | 348 : blocking_task_runner_(blocking_task_runner), |
| 349 observer_(observer), | 349 delegate_(delegate), |
| 350 scheduler_(scheduler), | 350 scheduler_(scheduler), |
| 351 metadata_(metadata), | 351 metadata_(metadata), |
| 352 cache_(cache), | 352 cache_(cache), |
| 353 temporary_file_directory_(temporary_file_directory), | 353 temporary_file_directory_(temporary_file_directory), |
| 354 weak_ptr_factory_(this) { | 354 weak_ptr_factory_(this) { |
| 355 } | 355 } |
| 356 | 356 |
| 357 DownloadOperation::~DownloadOperation() { | 357 DownloadOperation::~DownloadOperation() { |
| 358 } | 358 } |
| 359 | 359 |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 if (error != FILE_ERROR_OK) { | 527 if (error != FILE_ERROR_OK) { |
| 528 params->OnError(error); | 528 params->OnError(error); |
| 529 return; | 529 return; |
| 530 } | 530 } |
| 531 DCHECK(!entry_after_update->file_info().is_directory()); | 531 DCHECK(!entry_after_update->file_info().is_directory()); |
| 532 | 532 |
| 533 FileChange changed_files; | 533 FileChange changed_files; |
| 534 changed_files.Update( | 534 changed_files.Update( |
| 535 file_path, FileChange::FILE_TYPE_FILE, FileChange::ADD_OR_UPDATE); | 535 file_path, FileChange::FILE_TYPE_FILE, FileChange::ADD_OR_UPDATE); |
| 536 // Storing to cache changes the "offline available" status, hence notify. | 536 // Storing to cache changes the "offline available" status, hence notify. |
| 537 observer_->OnFileChangedByOperation(changed_files); | 537 delegate_->OnFileChangedByOperation(changed_files); |
| 538 params->OnDownloadCompleted(*cache_file_path, entry_after_update.Pass()); | 538 params->OnDownloadCompleted(*cache_file_path, entry_after_update.Pass()); |
| 539 } | 539 } |
| 540 | 540 |
| 541 void DownloadOperation::CancelJob(JobID job_id) { | 541 void DownloadOperation::CancelJob(JobID job_id) { |
| 542 scheduler_->CancelJob(job_id); | 542 scheduler_->CancelJob(job_id); |
| 543 } | 543 } |
| 544 | 544 |
| 545 } // namespace file_system | 545 } // namespace file_system |
| 546 } // namespace drive | 546 } // namespace drive |
| OLD | NEW |