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

Unified Diff: chrome/browser/chromeos/extensions/file_manager/private_api_drive.cc

Issue 576063002: Modify the behavior of cancel button in syncing status to cancel all jobs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/common/extensions/api/file_manager_private.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..53acd495ddb6af56cac923094a241d2eaa3a3305 100644
--- a/chrome/browser/chromeos/extensions/file_manager/private_api_drive.cc
+++ b/chrome/browser/chromeos/extensions/file_manager/private_api_drive.cc
@@ -566,46 +566,43 @@ bool FileManagerPrivateCancelFileTransfersFunction::RunAsync() {
if (!integration_service || !integration_service->IsMounted())
return false;
- // Create the mapping from file path to job ID.
drive::JobListInterface* job_list = integration_service->job_list();
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 file_urls are empty, cancel all jobs.
+ if (!params->file_urls.get()) {
+ for (size_t i = 0; i < jobs.size(); ++i) {
+ if (drive::IsActiveFileTransferJobInfo(jobs[i]))
+ job_list->CancelJob(jobs[i].job_id);
+ }
+ } else {
+ // Create the mapping from file path to job ID.
+ std::vector<std::string> file_urls(*params->file_urls.get());
+ 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 < file_urls.size(); ++i) {
+ base::FilePath file_path = file_manager::util::GetLocalPathFromURL(
+ render_view_host(), GetProfile(), GURL(file_urls[i]));
+ if (file_path.empty())
+ continue;
+
+ file_path = drive::util::ExtractDrivePath(file_path);
+ DCHECK(file_path.empty());
+
+ // 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;
}
« no previous file with comments | « no previous file | chrome/common/extensions/api/file_manager_private.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698