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

Side by Side Diff: chrome/browser/chromeos/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: Review fix/ 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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_JOB_LIST_INTERFACE_H_
6 #define CHROME_BROWSER_CHROMEOS_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 num_completed_bytes(0),
56 num_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 int64 num_completed_bytes;
68
69 // Total bytes of this operation, if applicable.
70 int64 num_total_bytes;
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 JobListInterface.
80 // All events are notified in the UI thread.
81 class JobListObserver {
82 public:
83 // Called when a new job id added.
84 virtual void OnJobAdded(const JobInfo& job_info) {}
85
86 // Called when a job id finished.
87 virtual void OnJobDone(const JobInfo& job_info) {}
88
89 // Called when a job status is updated.
90 virtual void OnJobUpdated(const JobInfo& job_info) {}
91
92 protected:
93 virtual ~JobListObserver() {}
94 };
95
96 // The interface to expose the list of issued Drive jobs.
97 class JobListInterface {
98 public:
99 virtual ~JobListInterface() {}
100
101 // Returns the list of jobs currently managed by the scheduler.
102 virtual std::vector<JobInfo> GetJobInfoList() = 0;
103
104 // Adds an observer.
105 virtual void AddObserver(JobListObserver* observer) = 0;
106
107 // Removes an observer.
108 virtual void RemoveObserver(JobListObserver* observer) = 0;
109 };
110
111 } // namespace drive
112
113 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_JOB_LIST_INTERFACE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698