OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_JOB_SCHEDULER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_DRIVE_JOB_SCHEDULER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_DRIVE_JOB_SCHEDULER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_DRIVE_JOB_SCHEDULER_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/id_map.h" | 10 #include "base/id_map.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 const google_apis::GetResourceListCallback& callback); | 87 const google_apis::GetResourceListCallback& callback); |
88 | 88 |
89 // Adds ContinueGetResourceList operation to the queue. | 89 // Adds ContinueGetResourceList operation to the queue. |
90 // |callback| must not be null. | 90 // |callback| must not be null. |
91 void ContinueGetResourceList( | 91 void ContinueGetResourceList( |
92 const GURL& feed_url, | 92 const GURL& feed_url, |
93 const google_apis::GetResourceListCallback& callback); | 93 const google_apis::GetResourceListCallback& callback); |
94 | 94 |
95 // Adds a GetResourceEntry operation to the queue. | 95 // Adds a GetResourceEntry operation to the queue. |
96 void GetResourceEntry(const std::string& resource_id, | 96 void GetResourceEntry(const std::string& resource_id, |
97 const DriveClientContext& context, | 97 const ClientContext& context, |
98 const google_apis::GetResourceEntryCallback& callback); | 98 const google_apis::GetResourceEntryCallback& callback); |
99 | 99 |
100 | 100 |
101 // Adds a DeleteResource operation to the queue. | 101 // Adds a DeleteResource operation to the queue. |
102 void DeleteResource(const std::string& resource_id, | 102 void DeleteResource(const std::string& resource_id, |
103 const google_apis::EntryActionCallback& callback); | 103 const google_apis::EntryActionCallback& callback); |
104 | 104 |
105 // Adds a CopyResource operation to the queue. | 105 // Adds a CopyResource operation to the queue. |
106 void CopyResource( | 106 void CopyResource( |
107 const std::string& resource_id, | 107 const std::string& resource_id, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 // Adds a AddNewDirectory operation to the queue. | 140 // Adds a AddNewDirectory operation to the queue. |
141 void AddNewDirectory(const std::string& parent_resource_id, | 141 void AddNewDirectory(const std::string& parent_resource_id, |
142 const std::string& directory_name, | 142 const std::string& directory_name, |
143 const google_apis::GetResourceEntryCallback& callback); | 143 const google_apis::GetResourceEntryCallback& callback); |
144 | 144 |
145 // Adds a DownloadFile operation to the queue. | 145 // Adds a DownloadFile operation to the queue. |
146 JobID DownloadFile( | 146 JobID DownloadFile( |
147 const base::FilePath& virtual_path, | 147 const base::FilePath& virtual_path, |
148 const base::FilePath& local_cache_path, | 148 const base::FilePath& local_cache_path, |
149 const GURL& download_url, | 149 const GURL& download_url, |
150 const DriveClientContext& context, | 150 const ClientContext& context, |
151 const google_apis::DownloadActionCallback& download_action_callback, | 151 const google_apis::DownloadActionCallback& download_action_callback, |
152 const google_apis::GetContentCallback& get_content_callback); | 152 const google_apis::GetContentCallback& get_content_callback); |
153 | 153 |
154 // Adds an UploadNewFile operation to the queue. | 154 // Adds an UploadNewFile operation to the queue. |
155 void UploadNewFile(const std::string& parent_resource_id, | 155 void UploadNewFile(const std::string& parent_resource_id, |
156 const base::FilePath& drive_file_path, | 156 const base::FilePath& drive_file_path, |
157 const base::FilePath& local_file_path, | 157 const base::FilePath& local_file_path, |
158 const std::string& title, | 158 const std::string& title, |
159 const std::string& content_type, | 159 const std::string& content_type, |
160 const DriveClientContext& context, | 160 const ClientContext& context, |
161 const google_apis::GetResourceEntryCallback& callback); | 161 const google_apis::GetResourceEntryCallback& callback); |
162 | 162 |
163 // Adds an UploadExistingFile operation to the queue. | 163 // Adds an UploadExistingFile operation to the queue. |
164 void UploadExistingFile( | 164 void UploadExistingFile( |
165 const std::string& resource_id, | 165 const std::string& resource_id, |
166 const base::FilePath& drive_file_path, | 166 const base::FilePath& drive_file_path, |
167 const base::FilePath& local_file_path, | 167 const base::FilePath& local_file_path, |
168 const std::string& content_type, | 168 const std::string& content_type, |
169 const std::string& etag, | 169 const std::string& etag, |
170 const DriveClientContext& context, | 170 const ClientContext& context, |
171 const google_apis::GetResourceEntryCallback& callback); | 171 const google_apis::GetResourceEntryCallback& callback); |
172 | 172 |
173 // Adds a CreateFile operation to the queue. | 173 // Adds a CreateFile operation to the queue. |
174 void CreateFile(const std::string& parent_resource_id, | 174 void CreateFile(const std::string& parent_resource_id, |
175 const base::FilePath& drive_file_path, | 175 const base::FilePath& drive_file_path, |
176 const std::string& title, | 176 const std::string& title, |
177 const std::string& content_type, | 177 const std::string& content_type, |
178 const DriveClientContext& context, | 178 const ClientContext& context, |
179 const google_apis::GetResourceEntryCallback& callback); | 179 const google_apis::GetResourceEntryCallback& callback); |
180 | 180 |
181 private: | 181 private: |
182 friend class JobSchedulerTest; | 182 friend class JobSchedulerTest; |
183 | 183 |
184 enum QueueType { | 184 enum QueueType { |
185 METADATA_QUEUE, | 185 METADATA_QUEUE, |
186 FILE_QUEUE, | 186 FILE_QUEUE, |
187 NUM_QUEUES | 187 NUM_QUEUES |
188 }; | 188 }; |
189 | 189 |
190 static const int kMaxJobCount[NUM_QUEUES]; | 190 static const int kMaxJobCount[NUM_QUEUES]; |
191 | 191 |
192 // Represents a single entry in the job map. | 192 // Represents a single entry in the job map. |
193 struct JobEntry { | 193 struct JobEntry { |
194 explicit JobEntry(JobType type); | 194 explicit JobEntry(JobType type); |
195 ~JobEntry(); | 195 ~JobEntry(); |
196 | 196 |
197 JobInfo job_info; | 197 JobInfo job_info; |
198 | 198 |
199 // Context of the job. | 199 // Context of the job. |
200 DriveClientContext context; | 200 ClientContext context; |
201 | 201 |
202 int retry_count; | 202 int retry_count; |
203 | 203 |
204 base::Closure task; | 204 base::Closure task; |
205 }; | 205 }; |
206 | 206 |
207 // Parameters for DriveUploader::ResumeUploadFile. | 207 // Parameters for DriveUploader::ResumeUploadFile. |
208 struct ResumeUploadParams; | 208 struct ResumeUploadParams; |
209 | 209 |
210 // Creates a new job and add it to the job map. | 210 // Creates a new job and add it to the job map. |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 | 333 |
334 // Note: This should remain the last member so it'll be destroyed and | 334 // Note: This should remain the last member so it'll be destroyed and |
335 // invalidate its weak pointers before any other members are destroyed. | 335 // invalidate its weak pointers before any other members are destroyed. |
336 base::WeakPtrFactory<JobScheduler> weak_ptr_factory_; | 336 base::WeakPtrFactory<JobScheduler> weak_ptr_factory_; |
337 DISALLOW_COPY_AND_ASSIGN(JobScheduler); | 337 DISALLOW_COPY_AND_ASSIGN(JobScheduler); |
338 }; | 338 }; |
339 | 339 |
340 } // namespace drive | 340 } // namespace drive |
341 | 341 |
342 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_JOB_SCHEDULER_H_ | 342 #endif // CHROME_BROWSER_CHROMEOS_DRIVE_JOB_SCHEDULER_H_ |
OLD | NEW |