Revert of Add button to add new FSP services to Files app. (patchset #8 id:140001...
[chromium-blink-merge.git] / chrome / browser / chromeos / drive / job_list.h
blob82d599161c867fb24a31a52e3ae0af6605e4c7cd
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.
5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_JOB_LIST_H_
6 #define CHROME_BROWSER_CHROMEOS_DRIVE_JOB_LIST_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/files/file_path.h"
12 #include "chrome/browser/chromeos/drive/file_errors.h"
14 namespace drive {
16 // Enum representing the type of job.
17 enum JobType {
18 TYPE_GET_ABOUT_RESOURCE,
19 TYPE_GET_APP_LIST,
20 TYPE_GET_ALL_RESOURCE_LIST,
21 TYPE_GET_RESOURCE_LIST_IN_DIRECTORY,
22 TYPE_SEARCH,
23 TYPE_GET_CHANGE_LIST,
24 TYPE_GET_REMAINING_CHANGE_LIST,
25 TYPE_GET_REMAINING_FILE_LIST,
26 TYPE_GET_RESOURCE_ENTRY,
27 TYPE_GET_SHARE_URL,
28 TYPE_TRASH_RESOURCE,
29 TYPE_COPY_RESOURCE,
30 TYPE_UPDATE_RESOURCE,
31 TYPE_ADD_RESOURCE_TO_DIRECTORY,
32 TYPE_REMOVE_RESOURCE_FROM_DIRECTORY,
33 TYPE_ADD_NEW_DIRECTORY,
34 TYPE_DOWNLOAD_FILE,
35 TYPE_UPLOAD_NEW_FILE,
36 TYPE_UPLOAD_EXISTING_FILE,
37 TYPE_ADD_PERMISSION,
40 // Returns the string representation of |type|.
41 std::string JobTypeToString(JobType type);
43 // Current state of the job.
44 enum JobState {
45 // The job is queued, but not yet executed.
46 STATE_NONE,
48 // The job is in the process of being handled.
49 STATE_RUNNING,
51 // The job failed, but has been re-added to the queue.
52 STATE_RETRY,
55 // Returns the string representation of |state|.
56 std::string JobStateToString(JobState state);
58 // Unique ID assigned to each job.
59 typedef int32 JobID;
61 // Information about a specific job that is visible to other systems.
62 struct JobInfo {
63 explicit JobInfo(JobType job_type);
65 // Type of the job.
66 JobType job_type;
68 // Id of the job, which can be used to query or modify it.
69 JobID job_id;
71 // Current state of the operation.
72 JobState state;
74 // The fields below are available only for jobs with job_type:
75 // TYPE_DOWNLOAD_FILE, TYPE_UPLOAD_NEW_FILE, or TYPE_UPLOAD_EXISTING_FILE.
77 // Number of bytes completed.
78 int64 num_completed_bytes;
80 // Total bytes of this operation.
81 int64 num_total_bytes;
83 // Drive path of the file that this job acts on.
84 base::FilePath file_path;
86 // Time when the job is started (i.e. the request is sent to the server).
87 base::Time start_time;
89 // Returns the string representation of the job info.
90 std::string ToString() const;
93 // Checks if |job_info| represents a job for currently active file transfer.
94 bool IsActiveFileTransferJobInfo(const JobInfo& job_info);
96 // The interface for observing JobListInterface.
97 // All events are notified in the UI thread.
98 class JobListObserver {
99 public:
100 // Called when a new job id added.
101 virtual void OnJobAdded(const JobInfo& job_info) {}
103 // Called when a job id finished.
104 // |error| is FILE_ERROR_OK when the job successfully finished, and a value
105 // telling the reason of failure when the jobs is failed.
106 virtual void OnJobDone(const JobInfo& job_info,
107 FileError error) {}
109 // Called when a job status is updated.
110 virtual void OnJobUpdated(const JobInfo& job_info) {}
112 protected:
113 virtual ~JobListObserver() {}
116 // The interface to expose the list of issued Drive jobs.
117 class JobListInterface {
118 public:
119 virtual ~JobListInterface() {}
121 // Returns the list of jobs currently managed by the scheduler.
122 virtual std::vector<JobInfo> GetJobInfoList() = 0;
124 // Adds an observer.
125 virtual void AddObserver(JobListObserver* observer) = 0;
127 // Removes an observer.
128 virtual void RemoveObserver(JobListObserver* observer) = 0;
130 // Cancels the job.
131 virtual void CancelJob(JobID job_id) = 0;
133 // Cancels all the jobs.
134 virtual void CancelAllJobs() = 0;
137 } // namespace drive
139 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_JOB_LIST_H_