| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/job_scheduler.h" | 5 #include "chrome/browser/chromeos/drive/job_scheduler.h" |
| 6 | 6 |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 9 #include "base/rand_util.h" | 9 #include "base/rand_util.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 weak_ptr_factory_.GetWeakPtr(), | 527 weak_ptr_factory_.GetWeakPtr(), |
| 528 new_job->job_info.job_id, | 528 new_job->job_info.job_id, |
| 529 callback)); | 529 callback)); |
| 530 new_job->abort_callback = CreateErrorRunCallback(callback); | 530 new_job->abort_callback = CreateErrorRunCallback(callback); |
| 531 StartJob(new_job); | 531 StartJob(new_job); |
| 532 } | 532 } |
| 533 | 533 |
| 534 JobID JobScheduler::DownloadFile( | 534 JobID JobScheduler::DownloadFile( |
| 535 const base::FilePath& virtual_path, | 535 const base::FilePath& virtual_path, |
| 536 const base::FilePath& local_cache_path, | 536 const base::FilePath& local_cache_path, |
| 537 const GURL& download_url, | 537 const std::string& resource_id, |
| 538 const ClientContext& context, | 538 const ClientContext& context, |
| 539 const google_apis::DownloadActionCallback& download_action_callback, | 539 const google_apis::DownloadActionCallback& download_action_callback, |
| 540 const google_apis::GetContentCallback& get_content_callback) { | 540 const google_apis::GetContentCallback& get_content_callback) { |
| 541 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 541 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 542 | 542 |
| 543 JobEntry* new_job = CreateNewJob(TYPE_DOWNLOAD_FILE); | 543 JobEntry* new_job = CreateNewJob(TYPE_DOWNLOAD_FILE); |
| 544 new_job->job_info.file_path = virtual_path; | 544 new_job->job_info.file_path = virtual_path; |
| 545 new_job->context = context; | 545 new_job->context = context; |
| 546 new_job->task = base::Bind( | 546 new_job->task = base::Bind( |
| 547 &DriveServiceInterface::DownloadFile, | 547 &DriveServiceInterface::DownloadFile, |
| 548 base::Unretained(drive_service_), | 548 base::Unretained(drive_service_), |
| 549 local_cache_path, | 549 local_cache_path, |
| 550 download_url, | 550 resource_id, |
| 551 base::Bind(&JobScheduler::OnDownloadActionJobDone, | 551 base::Bind(&JobScheduler::OnDownloadActionJobDone, |
| 552 weak_ptr_factory_.GetWeakPtr(), | 552 weak_ptr_factory_.GetWeakPtr(), |
| 553 new_job->job_info.job_id, | 553 new_job->job_info.job_id, |
| 554 download_action_callback), | 554 download_action_callback), |
| 555 get_content_callback, | 555 get_content_callback, |
| 556 base::Bind(&JobScheduler::UpdateProgress, | 556 base::Bind(&JobScheduler::UpdateProgress, |
| 557 weak_ptr_factory_.GetWeakPtr(), | 557 weak_ptr_factory_.GetWeakPtr(), |
| 558 new_job->job_info.job_id)); | 558 new_job->job_info.job_id)); |
| 559 new_job->abort_callback = CreateErrorRunCallback(download_action_callback); | 559 new_job->abort_callback = CreateErrorRunCallback(download_action_callback); |
| 560 StartJob(new_job); | 560 StartJob(new_job); |
| (...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1048 case FILE_QUEUE: | 1048 case FILE_QUEUE: |
| 1049 return "FILE_QUEUE"; | 1049 return "FILE_QUEUE"; |
| 1050 case NUM_QUEUES: | 1050 case NUM_QUEUES: |
| 1051 break; // This value is just a sentinel. Should never be used. | 1051 break; // This value is just a sentinel. Should never be used. |
| 1052 } | 1052 } |
| 1053 NOTREACHED(); | 1053 NOTREACHED(); |
| 1054 return ""; | 1054 return ""; |
| 1055 } | 1055 } |
| 1056 | 1056 |
| 1057 } // namespace drive | 1057 } // namespace drive |
| OLD | NEW |