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

Unified Diff: chrome/browser/chromeos/drive/drive_job_list_interface.h

Issue 14148006: Add an observer interface for DriveScheduler. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Split DriveJobListInterface. Created 7 years, 8 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
Index: chrome/browser/chromeos/drive/drive_job_list_interface.h
diff --git a/chrome/browser/chromeos/drive/drive_job_list_interface.h b/chrome/browser/chromeos/drive/drive_job_list_interface.h
new file mode 100644
index 0000000000000000000000000000000000000000..5f0e7a874677a7092a8da4be0fd62070d67d895a
--- /dev/null
+++ b/chrome/browser/chromeos/drive/drive_job_list_interface.h
@@ -0,0 +1,109 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_JOB_LIST_INTERFACE_H_
+#define CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_JOB_LIST_INTERFACE_H_
+
+#include "base/basictypes.h"
+#include "base/files/file_path.h"
+
+namespace drive {
+
+// Enum representing the type of job.
+enum JobType {
+ TYPE_GET_ABOUT_RESOURCE,
+ TYPE_GET_ACCOUNT_METADATA,
+ TYPE_GET_APP_LIST,
+ TYPE_GET_ALL_RESOURCE_LIST,
+ TYPE_GET_RESOURCE_LIST_IN_DIRECTORY,
+ TYPE_SEARCH,
+ TYPE_GET_CHANGE_LIST,
+ TYPE_CONTINUE_GET_RESOURCE_LIST,
+ TYPE_GET_RESOURCE_ENTRY,
+ TYPE_DELETE_RESOURCE,
+ TYPE_COPY_HOSTED_DOCUMENT,
+ TYPE_RENAME_RESOURCE,
+ TYPE_ADD_RESOURCE_TO_DIRECTORY,
+ TYPE_REMOVE_RESOURCE_FROM_DIRECTORY,
+ TYPE_ADD_NEW_DIRECTORY,
+ TYPE_DOWNLOAD_FILE,
+ TYPE_UPLOAD_NEW_FILE,
+ TYPE_UPLOAD_EXISTING_FILE,
+};
+
+// Current state of the job.
+enum JobState {
+ // The job is queued, but not yet executed.
+ STATE_NONE,
+
+ // The job is in the process of being handled.
+ STATE_RUNNING,
+
+ // The job failed, but has been re-added to the queue.
+ STATE_RETRY,
+};
+
+// Unique ID assigned to each job.
+typedef int32 JobID;
+
+// Information about a specific job that is visible to other systems.
+struct JobInfo {
+ explicit JobInfo(JobType in_job_type)
+ : job_type(in_job_type),
+ job_id(-1),
+ completed_bytes(0),
+ total_bytes(0),
+ state(STATE_NONE) {
+ }
+
+ // Type of the job.
+ JobType job_type;
+
+ // Id of the job, which can be used to query or modify it.
+ JobID job_id;
+
+ // Number of bytes completed, if applicable.
+ int completed_bytes;
satorux1 2013/04/17 00:11:29 maybe num_completed_bytes
kinaba 2013/04/17 00:51:42 Done. Along the way changed the type to int64.
+
+ // Total bytes of this operation, if applicable.
+ int total_bytes;
satorux1 2013/04/17 00:11:29 add num_ ?
kinaba 2013/04/17 00:51:42 Done.
+
+ // Drive path of the file that this job acts on.
+ base::FilePath file_path;
+
+ // Current state of the operation.
+ JobState state;
+};
+
+// The interface for observing DriveJobListInterface.
+class DriveJobListObserver {
tfarina 2013/04/16 14:07:28 does this needs a protected virtual destructor?
satorux1 2013/04/17 00:11:29 Let's drop 'Drive' prefix
kinaba 2013/04/17 00:51:42 Done.
kinaba 2013/04/17 00:51:42 Done. Thanks.
+ public:
+ // Called when a new job id added.
+ virtual void OnJobAdded(const JobInfo& job_info) = 0;
+
+ // Called when a job id finished.
+ virtual void OnJobDone(const JobInfo& job_info) = 0;
+
+ // Called when a job status is updated.
+ virtual void OnJobUpdated(const JobInfo& job_info) = 0;
satorux1 2013/04/17 00:11:29 Not sure if all of these should be pure virtual. A
kinaba 2013/04/17 00:51:42 Not sure but there may be a case that some of them
+};
+
+// The interface to expose the list of issued Drive jobs.
+class DriveJobListInterface {
satorux1 2013/04/17 00:11:29 Ditto. Drop 'Drive'. Please change the file names
kinaba 2013/04/17 00:51:42 Done.
+ public:
+ virtual ~DriveJobListInterface() {}
+
+ // Returns the list of jobs currently managed by the scheduler.
+ virtual std::vector<JobInfo> GetJobInfoList() = 0;
+
+ // Adds an observer.
+ virtual void AddObserver(DriveJobListObserver* observer) = 0;
+
+ // Removes an observer.
+ virtual void RemoveObserver(DriveJobListObserver* observer) = 0;
+};
+
+} // namespace drive
+
+#endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_JOB_LIST_INTERFACE_H_
« no previous file with comments | « no previous file | chrome/browser/chromeos/drive/drive_scheduler.h » ('j') | chrome/browser/chromeos/drive/drive_scheduler.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698