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

Side by Side Diff: chrome/browser/drive/fake_drive_service.h

Issue 135643005: drive: Stop using DictionaryValue to store data in FakeDriveService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 11 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
« no previous file with comments | « chrome/browser/drive/drive_api_util.cc ('k') | chrome/browser/drive/fake_drive_service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "google_apis/drive/auth_service_interface.h" 11 #include "google_apis/drive/auth_service_interface.h"
12 12
13 namespace google_apis {
14 class ChangeResource;
15 class FileResource;
16 }
17
13 namespace drive { 18 namespace drive {
14 19
15 // This class implements a fake DriveService which acts like a real Drive 20 // This class implements a fake DriveService which acts like a real Drive
16 // service. The fake service works as follows: 21 // service. The fake service works as follows:
17 // 22 //
18 // 1) Load JSON files and construct the in-memory resource list. 23 // 1) Load JSON files and construct the in-memory resource list.
19 // 2) Return valid responses based on the the in-memory resource list. 24 // 2) Return valid responses based on the the in-memory resource list.
20 // 3) Update the in-memory resource list by requests like DeleteResource(). 25 // 3) Update the in-memory resource list by requests like DeleteResource().
21 class FakeDriveService : public DriveServiceInterface { 26 class FakeDriveService : public DriveServiceInterface {
22 public: 27 public:
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 247
243 // Sets the last modified time for an entry specified by |resource_id|. 248 // Sets the last modified time for an entry specified by |resource_id|.
244 // On success, returns HTTP_SUCCESS with the parsed entry. 249 // On success, returns HTTP_SUCCESS with the parsed entry.
245 // |callback| must not be null. 250 // |callback| must not be null.
246 void SetLastModifiedTime( 251 void SetLastModifiedTime(
247 const std::string& resource_id, 252 const std::string& resource_id,
248 const base::Time& last_modified_time, 253 const base::Time& last_modified_time,
249 const google_apis::GetResourceEntryCallback& callback); 254 const google_apis::GetResourceEntryCallback& callback);
250 255
251 private: 256 private:
257 struct EntryInfo;
252 struct UploadSession; 258 struct UploadSession;
253 259
254 // Returns a pointer to the entry that matches |resource_id|, or NULL if 260 // Returns a pointer to the entry that matches |resource_id|, or NULL if
255 // not found. 261 // not found.
256 base::DictionaryValue* FindEntryByResourceId(const std::string& resource_id); 262 EntryInfo* FindEntryByResourceId(const std::string& resource_id);
257
258 // Returns a pointer to the entry that matches |content_url|, or NULL if
259 // not found.
260 base::DictionaryValue* FindEntryByContentUrl(const GURL& content_url);
261 263
262 // Returns a new resource ID, which looks like "resource_id_<num>" where 264 // Returns a new resource ID, which looks like "resource_id_<num>" where
263 // <num> is a monotonically increasing number starting from 1. 265 // <num> is a monotonically increasing number starting from 1.
264 std::string GetNewResourceId(); 266 std::string GetNewResourceId();
265 267
266 // Increments |largest_changestamp_| and adds the new changestamp. 268 // Increments |largest_changestamp_| and adds the new changestamp.
267 void AddNewChangestamp(base::DictionaryValue* entry); 269 void AddNewChangestamp(google_apis::ChangeResource* change);
268 270
269 // Update ETag of |entry| based on |largest_changestamp_|. 271 // Update ETag of |file| based on |largest_changestamp_|.
270 void UpdateETag(base::DictionaryValue* entry); 272 void UpdateETag(google_apis::FileResource* file);
271 273
272 // Adds a new entry based on the given parameters. |entry_kind| should be 274 // Adds a new entry based on the given parameters.
273 // "file" or "folder". Returns a pointer to the newly added entry, or NULL 275 // Returns a pointer to the newly added entry, or NULL if failed.
274 // if failed. 276 const EntryInfo* AddNewEntry(
275 const base::DictionaryValue* AddNewEntry(
276 const std::string& content_type, 277 const std::string& content_type,
277 const std::string& content_data, 278 const std::string& content_data,
278 const std::string& parent_resource_id, 279 const std::string& parent_resource_id,
279 const std::string& title, 280 const std::string& title,
280 bool shared_with_me, 281 bool shared_with_me);
281 const std::string& entry_kind);
282 282
283 // Core implementation of GetResourceList. 283 // Core implementation of GetResourceList.
284 // This method returns the slice of the all matched entries, and its range 284 // This method returns the slice of the all matched entries, and its range
285 // is between |start_offset| (inclusive) and |start_offset| + |max_results| 285 // is between |start_offset| (inclusive) and |start_offset| + |max_results|
286 // (exclusive). 286 // (exclusive).
287 // Increments *load_counter by 1 before it returns successfully. 287 // Increments *load_counter by 1 before it returns successfully.
288 void GetResourceListInternal( 288 void GetResourceListInternal(
289 int64 start_changestamp, 289 int64 start_changestamp,
290 const std::string& search_query, 290 const std::string& search_query,
291 const std::string& directory_resource_id, 291 const std::string& directory_resource_id,
292 int start_offset, 292 int start_offset,
293 int max_results, 293 int max_results,
294 int* load_counter, 294 int* load_counter,
295 const google_apis::GetResourceListCallback& callback); 295 const google_apis::GetResourceListCallback& callback);
296 296
297 // Returns new upload session URL. 297 // Returns new upload session URL.
298 GURL GetNewUploadSessionUrl(); 298 GURL GetNewUploadSessionUrl();
299 299
300 scoped_ptr<base::DictionaryValue> resource_list_value_; 300 typedef std::map<std::string, EntryInfo*> EntryInfoMap;
301 EntryInfoMap entries_;
301 scoped_ptr<base::DictionaryValue> account_metadata_value_; 302 scoped_ptr<base::DictionaryValue> account_metadata_value_;
302 scoped_ptr<base::DictionaryValue> app_info_value_; 303 scoped_ptr<base::DictionaryValue> app_info_value_;
303 std::map<GURL, UploadSession> upload_sessions_; 304 std::map<GURL, UploadSession> upload_sessions_;
304 int64 largest_changestamp_; 305 int64 largest_changestamp_;
305 int64 published_date_seq_; 306 int64 published_date_seq_;
306 int64 next_upload_sequence_number_; 307 int64 next_upload_sequence_number_;
307 int default_max_results_; 308 int default_max_results_;
308 int resource_id_count_; 309 int resource_id_count_;
309 int resource_list_load_count_; 310 int resource_list_load_count_;
310 int change_list_load_count_; 311 int change_list_load_count_;
311 int directory_load_count_; 312 int directory_load_count_;
312 int about_resource_load_count_; 313 int about_resource_load_count_;
313 int app_list_load_count_; 314 int app_list_load_count_;
314 int blocked_resource_list_load_count_; 315 int blocked_resource_list_load_count_;
315 bool offline_; 316 bool offline_;
316 bool never_return_all_resource_list_; 317 bool never_return_all_resource_list_;
317 base::FilePath last_cancelled_file_; 318 base::FilePath last_cancelled_file_;
318 GURL share_url_base_; 319 GURL share_url_base_;
319 320
320 DISALLOW_COPY_AND_ASSIGN(FakeDriveService); 321 DISALLOW_COPY_AND_ASSIGN(FakeDriveService);
321 }; 322 };
322 323
323 } // namespace drive 324 } // namespace drive
324 325
325 #endif // CHROME_BROWSER_DRIVE_FAKE_DRIVE_SERVICE_H_ 326 #endif // CHROME_BROWSER_DRIVE_FAKE_DRIVE_SERVICE_H_
OLDNEW
« no previous file with comments | « chrome/browser/drive/drive_api_util.cc ('k') | chrome/browser/drive/fake_drive_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698