summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkinaba@chromium.org <kinaba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-23 05:16:08 +0000
committerkinaba@chromium.org <kinaba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-23 05:16:08 +0000
commit370510366821ee1daac12a3baae689a25c38b074 (patch)
tree439a3f648ab8e7f55f0cf199c453f951b0719538
parent8da4d260e9ed12d6232d6c329f8869614082d962 (diff)
downloadchromium_src-370510366821ee1daac12a3baae689a25c38b074.zip
chromium_src-370510366821ee1daac12a3baae689a25c38b074.tar.gz
chromium_src-370510366821ee1daac12a3baae689a25c38b074.tar.bz2
Add methods for canceling jobs in drive::JobListInterface.
This is a preparation for adding job ID-based cancellation rather than file path based one. Currently we resort the implementation to the existing file path based one, but will migrate in the future. Along the way, consolidate the point of CancelAll() call at DriveSystemService::RemoveMountPoint(). BUG=231209 Review URL: https://chromiumcodereview.appspot.com/14120005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@195717 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/chromeos/drive/drive_file_system.cc4
-rw-r--r--chrome/browser/chromeos/drive/drive_scheduler.cc19
-rw-r--r--chrome/browser/chromeos/drive/drive_scheduler.h2
-rw-r--r--chrome/browser/chromeos/drive/drive_system_service.cc4
-rw-r--r--chrome/browser/chromeos/drive/job_list_interface.h6
5 files changed, 29 insertions, 6 deletions
diff --git a/chrome/browser/chromeos/drive/drive_file_system.cc b/chrome/browser/chromeos/drive/drive_file_system.cc
index ed4728b4..e899eda 100644
--- a/chrome/browser/chromeos/drive/drive_file_system.cc
+++ b/chrome/browser/chromeos/drive/drive_file_system.cc
@@ -290,10 +290,6 @@ DriveFileSystem::~DriveFileSystem() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
change_list_loader_->RemoveObserver(this);
-
- // Cancel all the in-flight operations.
- // This asynchronously cancels the URL fetch operations.
- drive_service_->CancelAll();
}
void DriveFileSystem::AddObserver(DriveFileSystemObserver* observer) {
diff --git a/chrome/browser/chromeos/drive/drive_scheduler.cc b/chrome/browser/chromeos/drive/drive_scheduler.cc
index 3f2cd46..9c0bbd0 100644
--- a/chrome/browser/chromeos/drive/drive_scheduler.cc
+++ b/chrome/browser/chromeos/drive/drive_scheduler.cc
@@ -97,6 +97,25 @@ void DriveScheduler::RemoveObserver(JobListObserver* observer) {
observer_list_.RemoveObserver(observer);
}
+void DriveScheduler::CancelJob(JobID job_id) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ // TODO(kinaba): Move the cancellation feature from DriveService
+ // to DriveScheduler. In particular, implement cancel based on job_id.
+ // crbug.com/231029
+ JobInfo* info = job_map_.Lookup(job_id);
+ if (info)
+ drive_service_->CancelForFilePath(info->file_path);
+}
+
+void DriveScheduler::CancelAllJobs() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+ // TODO(kinaba): Move the cancellation feature from DriveService
+ // to DriveScheduler.
+ drive_service_->CancelAll();
+}
+
void DriveScheduler::GetAccountMetadata(
const google_apis::GetAccountMetadataCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
diff --git a/chrome/browser/chromeos/drive/drive_scheduler.h b/chrome/browser/chromeos/drive/drive_scheduler.h
index f6a3230..c165de4 100644
--- a/chrome/browser/chromeos/drive/drive_scheduler.h
+++ b/chrome/browser/chromeos/drive/drive_scheduler.h
@@ -36,6 +36,8 @@ class DriveScheduler
virtual std::vector<JobInfo> GetJobInfoList() OVERRIDE;
virtual void AddObserver(JobListObserver* observer) OVERRIDE;
virtual void RemoveObserver(JobListObserver* observer) OVERRIDE;
+ virtual void CancelJob(JobID job_id) OVERRIDE;
+ virtual void CancelAllJobs() OVERRIDE;
// Adds a GetAccountMetadata operation to the queue.
// |callback| must not be null.
diff --git a/chrome/browser/chromeos/drive/drive_system_service.cc b/chrome/browser/chromeos/drive/drive_system_service.cc
index ae0d051..20b9c73 100644
--- a/chrome/browser/chromeos/drive/drive_system_service.cc
+++ b/chrome/browser/chromeos/drive/drive_system_service.cc
@@ -238,7 +238,6 @@ void DriveSystemService::ClearCacheAndRemountFileSystem(
DCHECK(!callback.is_null());
RemoveDriveMountPoint();
- drive_service()->CancelAll();
cache_->ClearAll(base::Bind(
&DriveSystemService::ReinitializeResourceMetadataAfterClearCache,
weak_ptr_factory_.GetWeakPtr(),
@@ -281,7 +280,6 @@ void DriveSystemService::ReloadAndRemountFileSystem() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
RemoveDriveMountPoint();
- drive_service()->CancelAll();
file_system_->Reload();
// Reload() is asynchronous. But we can add back the mount point right away
@@ -329,6 +327,8 @@ void DriveSystemService::AddDriveMountPoint() {
void DriveSystemService::RemoveDriveMountPoint() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ job_list()->CancelAllJobs();
+
FOR_EACH_OBSERVER(DriveSystemServiceObserver, observers_,
OnFileSystemBeingUnmounted());
diff --git a/chrome/browser/chromeos/drive/job_list_interface.h b/chrome/browser/chromeos/drive/job_list_interface.h
index f953fa6..186e1c5 100644
--- a/chrome/browser/chromeos/drive/job_list_interface.h
+++ b/chrome/browser/chromeos/drive/job_list_interface.h
@@ -113,6 +113,12 @@ class JobListInterface {
// Removes an observer.
virtual void RemoveObserver(JobListObserver* observer) = 0;
+
+ // Cancels the job.
+ virtual void CancelJob(JobID job_id) = 0;
+
+ // Cancels all the jobs.
+ virtual void CancelAllJobs() = 0;
};
} // namespace drive