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_DRIVE_FAKE_DRIVE_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_DRIVE_FAKE_DRIVE_SERVICE_H_ |
6 #define CHROME_BROWSER_DRIVE_FAKE_DRIVE_SERVICE_H_ | 6 #define CHROME_BROWSER_DRIVE_FAKE_DRIVE_SERVICE_H_ |
7 | 7 |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/browser/drive/drive_service_interface.h" | 10 #include "chrome/browser/drive/drive_service_interface.h" |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 | 199 |
200 // Sets the last modified time for an entry specified by |resource_id|. | 200 // Sets the last modified time for an entry specified by |resource_id|. |
201 // On success, returns HTTP_SUCCESS with the parsed entry. | 201 // On success, returns HTTP_SUCCESS with the parsed entry. |
202 // |callback| must not be null. | 202 // |callback| must not be null. |
203 void SetLastModifiedTime( | 203 void SetLastModifiedTime( |
204 const std::string& resource_id, | 204 const std::string& resource_id, |
205 const base::Time& last_modified_time, | 205 const base::Time& last_modified_time, |
206 const google_apis::GetResourceEntryCallback& callback); | 206 const google_apis::GetResourceEntryCallback& callback); |
207 | 207 |
208 private: | 208 private: |
| 209 struct UploadSession; |
| 210 |
209 // Returns a pointer to the entry that matches |resource_id|, or NULL if | 211 // Returns a pointer to the entry that matches |resource_id|, or NULL if |
210 // not found. | 212 // not found. |
211 base::DictionaryValue* FindEntryByResourceId(const std::string& resource_id); | 213 base::DictionaryValue* FindEntryByResourceId(const std::string& resource_id); |
212 | 214 |
213 // Returns a pointer to the entry that matches |content_url|, or NULL if | 215 // Returns a pointer to the entry that matches |content_url|, or NULL if |
214 // not found. | 216 // not found. |
215 base::DictionaryValue* FindEntryByContentUrl(const GURL& content_url); | 217 base::DictionaryValue* FindEntryByContentUrl(const GURL& content_url); |
216 | 218 |
217 // Returns a pointer to the entry that matches |upload_url|, or NULL if | |
218 // not found. | |
219 base::DictionaryValue* FindEntryByUploadUrl(const GURL& upload_url); | |
220 | |
221 // Returns a new resource ID, which looks like "resource_id_<num>" where | 219 // Returns a new resource ID, which looks like "resource_id_<num>" where |
222 // <num> is a monotonically increasing number starting from 1. | 220 // <num> is a monotonically increasing number starting from 1. |
223 std::string GetNewResourceId(); | 221 std::string GetNewResourceId(); |
224 | 222 |
225 // Increments |largest_changestamp_| and adds the new changestamp to | 223 // Increments |largest_changestamp_| and adds the new changestamp and ETag to |
226 // |entry|. | 224 // |entry|. |
227 void AddNewChangestamp(base::DictionaryValue* entry); | 225 void AddNewChangestampAndETag(base::DictionaryValue* entry); |
228 | 226 |
229 // Adds a new entry based on the given parameters. |entry_kind| should be | 227 // Adds a new entry based on the given parameters. |entry_kind| should be |
230 // "file" or "folder". Returns a pointer to the newly added entry, or NULL | 228 // "file" or "folder". Returns a pointer to the newly added entry, or NULL |
231 // if failed. | 229 // if failed. |
232 const base::DictionaryValue* AddNewEntry( | 230 const base::DictionaryValue* AddNewEntry( |
233 const std::string& content_type, | 231 const std::string& content_type, |
234 const std::string& content_data, | 232 const std::string& content_data, |
235 const std::string& parent_resource_id, | 233 const std::string& parent_resource_id, |
236 const std::string& title, | 234 const std::string& title, |
237 bool shared_with_me, | 235 bool shared_with_me, |
238 const std::string& entry_kind); | 236 const std::string& entry_kind); |
239 | 237 |
240 // Core implementation of GetResourceList. | 238 // Core implementation of GetResourceList. |
241 // This method returns the slice of the all matched entries, and its range | 239 // This method returns the slice of the all matched entries, and its range |
242 // is between |start_offset| (inclusive) and |start_offset| + |max_results| | 240 // is between |start_offset| (inclusive) and |start_offset| + |max_results| |
243 // (exclusive). | 241 // (exclusive). |
244 // Increments *load_counter by 1 before it returns successfully. | 242 // Increments *load_counter by 1 before it returns successfully. |
245 void GetResourceListInternal( | 243 void GetResourceListInternal( |
246 int64 start_changestamp, | 244 int64 start_changestamp, |
247 const std::string& search_query, | 245 const std::string& search_query, |
248 const std::string& directory_resource_id, | 246 const std::string& directory_resource_id, |
249 int start_offset, | 247 int start_offset, |
250 int max_results, | 248 int max_results, |
251 int* load_counter, | 249 int* load_counter, |
252 const google_apis::GetResourceListCallback& callback); | 250 const google_apis::GetResourceListCallback& callback); |
253 | 251 |
| 252 // Returns new upload session URL. |
| 253 GURL GetNewUploadSessionUrl(); |
| 254 |
254 scoped_ptr<base::DictionaryValue> resource_list_value_; | 255 scoped_ptr<base::DictionaryValue> resource_list_value_; |
255 scoped_ptr<base::Value> account_metadata_value_; | 256 scoped_ptr<base::Value> account_metadata_value_; |
256 scoped_ptr<base::Value> app_info_value_; | 257 scoped_ptr<base::Value> app_info_value_; |
| 258 std::map<GURL, UploadSession> upload_sessions_; |
257 int64 largest_changestamp_; | 259 int64 largest_changestamp_; |
258 int64 published_date_seq_; | 260 int64 published_date_seq_; |
| 261 int64 next_upload_sequence_number_; |
259 int default_max_results_; | 262 int default_max_results_; |
260 int resource_id_count_; | 263 int resource_id_count_; |
261 int resource_list_load_count_; | 264 int resource_list_load_count_; |
262 int change_list_load_count_; | 265 int change_list_load_count_; |
263 int directory_load_count_; | 266 int directory_load_count_; |
264 int about_resource_load_count_; | 267 int about_resource_load_count_; |
265 bool offline_; | 268 bool offline_; |
266 base::FilePath last_cancelled_file_; | 269 base::FilePath last_cancelled_file_; |
267 | 270 |
268 DISALLOW_COPY_AND_ASSIGN(FakeDriveService); | 271 DISALLOW_COPY_AND_ASSIGN(FakeDriveService); |
269 }; | 272 }; |
270 | 273 |
271 } // namespace drive | 274 } // namespace drive |
272 | 275 |
273 #endif // CHROME_BROWSER_DRIVE_FAKE_DRIVE_SERVICE_H_ | 276 #endif // CHROME_BROWSER_DRIVE_FAKE_DRIVE_SERVICE_H_ |
OLD | NEW |