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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/extensions/file_manager/private_api_drive.h" 5 #include "chrome/browser/chromeos/extensions/file_manager/private_api_drive.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "chrome/browser/browser_process.h" 8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/chromeos/drive/drive_integration_service.h" 9 #include "chrome/browser/chromeos/drive/drive_integration_service.h"
10 #include "chrome/browser/chromeos/extensions/file_manager/private_api_util.h" 10 #include "chrome/browser/chromeos/extensions/file_manager/private_api_util.h"
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 550
551 if (error == drive::FILE_ERROR_OK) { 551 if (error == drive::FILE_ERROR_OK) {
552 SendResponse(true); 552 SendResponse(true);
553 } else { 553 } else {
554 SetError(drive::FileErrorToString(error)); 554 SetError(drive::FileErrorToString(error));
555 SendResponse(false); 555 SendResponse(false);
556 } 556 }
557 } 557 }
558 558
559 bool FileManagerPrivateCancelFileTransfersFunction::RunAsync() { 559 bool FileManagerPrivateCancelFileTransfersFunction::RunAsync() {
560 using extensions::api::file_manager_private::CancelFileTransfers::Params;
561 const scoped_ptr<Params> params(Params::Create(*args_));
562 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.
563
564 drive::DriveIntegrationService* integration_service = 560 drive::DriveIntegrationService* integration_service =
565 drive::DriveIntegrationServiceFactory::FindForProfile(GetProfile()); 561 drive::DriveIntegrationServiceFactory::FindForProfile(GetProfile());
566 if (!integration_service || !integration_service->IsMounted()) 562 if (!integration_service || !integration_service->IsMounted())
567 return false; 563 return false;
568 564
569 // Create the mapping from file path to job ID. 565 // Create the mapping from file path to job ID.
kinaba 2014/09/18 02:15:54 Please update the comment.
iseki 2014/09/18 05:32:28 Done.
570 drive::JobListInterface* job_list = integration_service->job_list(); 566 drive::JobListInterface* job_list = integration_service->job_list();
571 DCHECK(job_list); 567 DCHECK(job_list);
572 std::vector<drive::JobInfo> jobs = job_list->GetJobInfoList(); 568 std::vector<drive::JobInfo> jobs = job_list->GetJobInfoList();
573 569
574 typedef std::map<base::FilePath, std::vector<drive::JobID> > PathToIdMap;
575 PathToIdMap path_to_id_map;
576 for (size_t i = 0; i < jobs.size(); ++i) {
577 if (drive::IsActiveFileTransferJobInfo(jobs[i]))
578 path_to_id_map[jobs[i].file_path].push_back(jobs[i].job_id);
579 }
580
581 // Cancel by Job ID. 570 // Cancel by Job ID.
kinaba 2014/09/18 02:15:54 Please update the comment.
iseki 2014/09/18 05:32:28 Done.
582 std::vector<linked_ptr<api::file_manager_private:: 571 std::vector<linked_ptr<api::file_manager_private::
583 FileTransferCancelStatus> > responses; 572 FileTransferCancelStatus> > responses;
584 for (size_t i = 0; i < params->file_urls.size(); ++i) { 573 for (size_t i = 0; i < jobs.size(); ++i) {
585 base::FilePath file_path = file_manager::util::GetLocalPathFromURL( 574 if (drive::IsActiveFileTransferJobInfo(jobs[i])) {
586 render_view_host(), GetProfile(), GURL(params->file_urls[i])); 575 job_list->CancelJob(jobs[i].job_id);
587 if (file_path.empty()) 576 linked_ptr<api::file_manager_private::FileTransferCancelStatus> result(
588 continue; 577 new api::file_manager_private::FileTransferCancelStatus);
589 578 result->canceled = true;
590 DCHECK(drive::util::IsUnderDriveMountPoint(file_path)); 579 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.
591 file_path = drive::util::ExtractDrivePath(file_path); 580 responses.push_back(result);
592
593 // Cancel all the jobs for the file.
594 PathToIdMap::iterator it = path_to_id_map.find(file_path);
595 if (it != path_to_id_map.end()) {
596 for (size_t i = 0; i < it->second.size(); ++i)
597 job_list->CancelJob(it->second[i]);
598 } 581 }
599 linked_ptr<api::file_manager_private::FileTransferCancelStatus> result(
600 new api::file_manager_private::FileTransferCancelStatus);
601 result->canceled = it != path_to_id_map.end();
602 // TODO(kinaba): simplify cancelFileTransfer() to take single URL each time,
603 // and eliminate this field; it is just returning a copy of the argument.
604 result->file_url = params->file_urls[i];
605 responses.push_back(result);
606 } 582 }
607 results_ = api::file_manager_private::CancelFileTransfers::Results::Create( 583 results_ = api::file_manager_private::CancelFileTransfers::Results::Create(
608 responses); 584 responses);
609 SendResponse(true); 585 SendResponse(true);
610 return true; 586 return true;
611 } 587 }
612 588
613 bool FileManagerPrivateSearchDriveFunction::RunAsync() { 589 bool FileManagerPrivateSearchDriveFunction::RunAsync() {
614 using extensions::api::file_manager_private::SearchDrive::Params; 590 using extensions::api::file_manager_private::SearchDrive::Params;
615 const scoped_ptr<Params> params(Params::Create(*args_)); 591 const scoped_ptr<Params> params(Params::Create(*args_));
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
1032 return; 1008 return;
1033 } 1009 }
1034 1010
1035 const std::string url = download_url_ + "?access_token=" + access_token; 1011 const std::string url = download_url_ + "?access_token=" + access_token;
1036 SetResult(new base::StringValue(url)); 1012 SetResult(new base::StringValue(url));
1037 1013
1038 SendResponse(true); 1014 SendResponse(true);
1039 } 1015 }
1040 1016
1041 } // namespace extensions 1017 } // namespace extensions
OLDNEW
« 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