Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_JOB_LIST_INTERFACE_H_ | |
| 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_JOB_LIST_INTERFACE_H_ | |
| 7 | |
| 8 #include "base/basictypes.h" | |
| 9 #include "base/files/file_path.h" | |
| 10 | |
| 11 namespace drive { | |
| 12 | |
| 13 // Enum representing the type of job. | |
| 14 enum JobType { | |
| 15 TYPE_GET_ABOUT_RESOURCE, | |
| 16 TYPE_GET_ACCOUNT_METADATA, | |
| 17 TYPE_GET_APP_LIST, | |
| 18 TYPE_GET_ALL_RESOURCE_LIST, | |
| 19 TYPE_GET_RESOURCE_LIST_IN_DIRECTORY, | |
| 20 TYPE_SEARCH, | |
| 21 TYPE_GET_CHANGE_LIST, | |
| 22 TYPE_CONTINUE_GET_RESOURCE_LIST, | |
| 23 TYPE_GET_RESOURCE_ENTRY, | |
| 24 TYPE_DELETE_RESOURCE, | |
| 25 TYPE_COPY_HOSTED_DOCUMENT, | |
| 26 TYPE_RENAME_RESOURCE, | |
| 27 TYPE_ADD_RESOURCE_TO_DIRECTORY, | |
| 28 TYPE_REMOVE_RESOURCE_FROM_DIRECTORY, | |
| 29 TYPE_ADD_NEW_DIRECTORY, | |
| 30 TYPE_DOWNLOAD_FILE, | |
| 31 TYPE_UPLOAD_NEW_FILE, | |
| 32 TYPE_UPLOAD_EXISTING_FILE, | |
| 33 }; | |
| 34 | |
| 35 // Current state of the job. | |
| 36 enum JobState { | |
| 37 // The job is queued, but not yet executed. | |
| 38 STATE_NONE, | |
| 39 | |
| 40 // The job is in the process of being handled. | |
| 41 STATE_RUNNING, | |
| 42 | |
| 43 // The job failed, but has been re-added to the queue. | |
| 44 STATE_RETRY, | |
| 45 }; | |
| 46 | |
| 47 // Unique ID assigned to each job. | |
| 48 typedef int32 JobID; | |
| 49 | |
| 50 // Information about a specific job that is visible to other systems. | |
| 51 struct JobInfo { | |
| 52 explicit JobInfo(JobType in_job_type) | |
| 53 : job_type(in_job_type), | |
| 54 job_id(-1), | |
| 55 completed_bytes(0), | |
| 56 total_bytes(0), | |
| 57 state(STATE_NONE) { | |
| 58 } | |
| 59 | |
| 60 // Type of the job. | |
| 61 JobType job_type; | |
| 62 | |
| 63 // Id of the job, which can be used to query or modify it. | |
| 64 JobID job_id; | |
| 65 | |
| 66 // Number of bytes completed, if applicable. | |
| 67 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.
| |
| 68 | |
| 69 // Total bytes of this operation, if applicable. | |
| 70 int total_bytes; | |
|
satorux1
2013/04/17 00:11:29
add num_ ?
kinaba
2013/04/17 00:51:42
Done.
| |
| 71 | |
| 72 // Drive path of the file that this job acts on. | |
| 73 base::FilePath file_path; | |
| 74 | |
| 75 // Current state of the operation. | |
| 76 JobState state; | |
| 77 }; | |
| 78 | |
| 79 // The interface for observing DriveJobListInterface. | |
| 80 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.
| |
| 81 public: | |
| 82 // Called when a new job id added. | |
| 83 virtual void OnJobAdded(const JobInfo& job_info) = 0; | |
| 84 | |
| 85 // Called when a job id finished. | |
| 86 virtual void OnJobDone(const JobInfo& job_info) = 0; | |
| 87 | |
| 88 // Called when a job status is updated. | |
| 89 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
| |
| 90 }; | |
| 91 | |
| 92 // The interface to expose the list of issued Drive jobs. | |
| 93 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.
| |
| 94 public: | |
| 95 virtual ~DriveJobListInterface() {} | |
| 96 | |
| 97 // Returns the list of jobs currently managed by the scheduler. | |
| 98 virtual std::vector<JobInfo> GetJobInfoList() = 0; | |
| 99 | |
| 100 // Adds an observer. | |
| 101 virtual void AddObserver(DriveJobListObserver* observer) = 0; | |
| 102 | |
| 103 // Removes an observer. | |
| 104 virtual void RemoveObserver(DriveJobListObserver* observer) = 0; | |
| 105 }; | |
| 106 | |
| 107 } // namespace drive | |
| 108 | |
| 109 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_DRIVE_JOB_LIST_INTERFACE_H_ | |
| OLD | NEW |