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_ |