Chromium Code Reviews| Index: chrome/browser/chromeos/extensions/file_manager/private_api_drive.cc |
| diff --git a/chrome/browser/chromeos/extensions/file_manager/private_api_drive.cc b/chrome/browser/chromeos/extensions/file_manager/private_api_drive.cc |
| index 2b1b9c3301c9f888e3f08e85c858f707bf7277e2..aaf570f8e56af16bd5247d8aceb1f3432e6c0f87 100644 |
| --- a/chrome/browser/chromeos/extensions/file_manager/private_api_drive.cc |
| +++ b/chrome/browser/chromeos/extensions/file_manager/private_api_drive.cc |
| @@ -571,41 +571,37 @@ bool FileManagerPrivateCancelFileTransfersFunction::RunAsync() { |
| DCHECK(job_list); |
| std::vector<drive::JobInfo> jobs = job_list->GetJobInfoList(); |
| - typedef std::map<base::FilePath, std::vector<drive::JobID> > PathToIdMap; |
| - PathToIdMap path_to_id_map; |
| - for (size_t i = 0; i < jobs.size(); ++i) { |
| - if (drive::IsActiveFileTransferJobInfo(jobs[i])) |
| - path_to_id_map[jobs[i].file_path].push_back(jobs[i].job_id); |
| - } |
| + // If params->file_urls are empty, cancel all jobs. |
| + if (params->file_urls.size() == 0) { |
| + for (size_t i = 0; i < jobs.size(); ++i) { |
| + if (drive::IsActiveFileTransferJobInfo(jobs[i])) |
| + job_list->CancelJob(jobs[i].job_id); |
| + } |
| + } else { |
|
kinaba
2014/09/18 05:39:16
The "// Create the mapping from file path to job I
iseki
2014/09/18 05:45:44
Done.
|
| + typedef std::map<base::FilePath, std::vector<drive::JobID> > PathToIdMap; |
| + PathToIdMap path_to_id_map; |
| + for (size_t i = 0; i < jobs.size(); ++i) { |
| + if (drive::IsActiveFileTransferJobInfo(jobs[i])) |
| + path_to_id_map[jobs[i].file_path].push_back(jobs[i].job_id); |
| + } |
| - // Cancel by Job ID. |
| - std::vector<linked_ptr<api::file_manager_private:: |
| - FileTransferCancelStatus> > responses; |
| - for (size_t i = 0; i < params->file_urls.size(); ++i) { |
| - base::FilePath file_path = file_manager::util::GetLocalPathFromURL( |
| - render_view_host(), GetProfile(), GURL(params->file_urls[i])); |
| - if (file_path.empty()) |
| - continue; |
| - |
| - DCHECK(drive::util::IsUnderDriveMountPoint(file_path)); |
| - file_path = drive::util::ExtractDrivePath(file_path); |
| - |
| - // Cancel all the jobs for the file. |
| - PathToIdMap::iterator it = path_to_id_map.find(file_path); |
| - if (it != path_to_id_map.end()) { |
| - for (size_t i = 0; i < it->second.size(); ++i) |
| - job_list->CancelJob(it->second[i]); |
| + for (size_t i = 0; i < params->file_urls.size(); ++i) { |
| + base::FilePath file_path = file_manager::util::GetLocalPathFromURL( |
| + render_view_host(), GetProfile(), GURL(params->file_urls[i])); |
| + if (file_path.empty()) |
| + continue; |
| + |
| + DCHECK(drive::util::IsUnderDriveMountPoint(file_path)); |
| + file_path = drive::util::ExtractDrivePath(file_path); |
| + |
| + // Cancel all the jobs for the file. |
| + PathToIdMap::iterator it = path_to_id_map.find(file_path); |
| + if (it != path_to_id_map.end()) { |
| + for (size_t i = 0; i < it->second.size(); ++i) |
| + job_list->CancelJob(it->second[i]); |
| + } |
| } |
| - linked_ptr<api::file_manager_private::FileTransferCancelStatus> result( |
| - new api::file_manager_private::FileTransferCancelStatus); |
| - result->canceled = it != path_to_id_map.end(); |
| - // TODO(kinaba): simplify cancelFileTransfer() to take single URL each time, |
| - // and eliminate this field; it is just returning a copy of the argument. |
| - result->file_url = params->file_urls[i]; |
| - responses.push_back(result); |
| } |
| - results_ = api::file_manager_private::CancelFileTransfers::Results::Create( |
| - responses); |
| SendResponse(true); |
| return true; |
| } |