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

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 | no next file » | 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..231dbfd8a6effefceaa0fa0eaf72baf0856b91c4 100644
--- a/chrome/browser/chromeos/extensions/file_manager/private_api_drive.cc
+++ b/chrome/browser/chromeos/extensions/file_manager/private_api_drive.cc
@@ -557,10 +557,6 @@ void FileManagerPrivatePinDriveFileFunction::
}
bool FileManagerPrivateCancelFileTransfersFunction::RunAsync() {
- using extensions::api::file_manager_private::CancelFileTransfers::Params;
- const scoped_ptr<Params> params(Params::Create(*args_));
- EXTENSION_FUNCTION_VALIDATE(params);
kinaba 2014/09/18 02:15:54 I guess you are planning to update the IDL of this
iseki 2014/09/18 05:32:28 Done.
-
drive::DriveIntegrationService* integration_service =
drive::DriveIntegrationServiceFactory::FindForProfile(GetProfile());
if (!integration_service || !integration_service->IsMounted())
@@ -571,38 +567,18 @@ 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);
- }
-
// Cancel by Job ID.
kinaba 2014/09/18 02:15:54 Please update the comment.
iseki 2014/09/18 05:32:28 Done.
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 < jobs.size(); ++i) {
+ if (drive::IsActiveFileTransferJobInfo(jobs[i])) {
+ job_list->CancelJob(jobs[i].job_id);
+ linked_ptr<api::file_manager_private::FileTransferCancelStatus> result(
+ new api::file_manager_private::FileTransferCancelStatus);
+ result->canceled = true;
+ result->file_url = jobs[i].file_path.value();
kinaba 2014/09/18 02:15:54 These response values are not used at all in Files
iseki 2014/09/18 05:32:28 Done.
+ responses.push_back(result);
}
- 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);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698