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

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

Issue 305913002: drive: Replace GetResourceListCallback in DriveServiceInterface with FileListCallback (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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/dummy_drive_service.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 "chrome/browser/drive/drive_service_interface.h" 9 #include "chrome/browser/drive/drive_service_interface.h"
10 10
(...skipping 20 matching lines...) Expand all
31 FakeDriveService(); 31 FakeDriveService();
32 virtual ~FakeDriveService(); 32 virtual ~FakeDriveService();
33 33
34 // Loads the app list for Drive API. Returns true on success. 34 // Loads the app list for Drive API. Returns true on success.
35 bool LoadAppListForDriveApi(const std::string& relative_path); 35 bool LoadAppListForDriveApi(const std::string& relative_path);
36 36
37 // Changes the offline state. All functions fail with GDATA_NO_CONNECTION 37 // Changes the offline state. All functions fail with GDATA_NO_CONNECTION
38 // when offline. By default the offline state is false. 38 // when offline. By default the offline state is false.
39 void set_offline(bool offline) { offline_ = offline; } 39 void set_offline(bool offline) { offline_ = offline; }
40 40
41 // GetAllResourceList never returns result when this is set to true. 41 // GetAllFileList never returns result when this is set to true.
42 // Used to emulate the real server's slowness. 42 // Used to emulate the real server's slowness.
43 void set_never_return_all_resource_list(bool value) { 43 void set_never_return_all_file_list(bool value) {
44 never_return_all_resource_list_ = value; 44 never_return_all_file_list_ = value;
45 } 45 }
46 46
47 // Changes the default max results returned from GetResourceList(). 47 // Changes the default max results returned from GetAllFileList().
48 // By default, it's set to 0, which is unlimited. 48 // By default, it's set to 0, which is unlimited.
49 void set_default_max_results(int default_max_results) { 49 void set_default_max_results(int default_max_results) {
50 default_max_results_ = default_max_results; 50 default_max_results_ = default_max_results;
51 } 51 }
52 52
53 // Sets the url to the test server to be used as a base for generated share 53 // Sets the url to the test server to be used as a base for generated share
54 // urls to the share dialog. 54 // urls to the share dialog.
55 void set_share_url_base(const GURL& share_url_base) { 55 void set_share_url_base(const GURL& share_url_base) {
56 share_url_base_ = share_url_base; 56 share_url_base_ = share_url_base;
57 } 57 }
58 58
59 // Changes the quota fields returned from GetAboutResource(). 59 // Changes the quota fields returned from GetAboutResource().
60 void SetQuotaValue(int64 used, int64 total); 60 void SetQuotaValue(int64 used, int64 total);
61 61
62 // Returns the AboutResource. 62 // Returns the AboutResource.
63 const google_apis::AboutResource& about_resource() const { 63 const google_apis::AboutResource& about_resource() const {
64 return *about_resource_; 64 return *about_resource_;
65 } 65 }
66 66
67 // Returns the number of times the resource list is successfully loaded by 67 // Returns the number of times the file list is successfully loaded by
68 // GetAllResourceList(). 68 // GetAllFileList().
69 int resource_list_load_count() const { return resource_list_load_count_; } 69 int file_list_load_count() const { return file_list_load_count_; }
70 70
71 // Returns the number of times the resource list is successfully loaded by 71 // Returns the number of times the resource list is successfully loaded by
72 // GetChangeList(). 72 // GetChangeList().
73 int change_list_load_count() const { return change_list_load_count_; } 73 int change_list_load_count() const { return change_list_load_count_; }
74 74
75 // Returns the number of times the resource list is successfully loaded by 75 // Returns the number of times the resource list is successfully loaded by
76 // GetResourceListInDirectory(). 76 // GetFileListInDirectory().
77 int directory_load_count() const { return directory_load_count_; } 77 int directory_load_count() const { return directory_load_count_; }
78 78
79 // Returns the number of times the about resource is successfully loaded 79 // Returns the number of times the about resource is successfully loaded
80 // by GetAboutResource(). 80 // by GetAboutResource().
81 int about_resource_load_count() const { 81 int about_resource_load_count() const {
82 return about_resource_load_count_; 82 return about_resource_load_count_;
83 } 83 }
84 84
85 // Returns the number of times the app list is successfully loaded by 85 // Returns the number of times the app list is successfully loaded by
86 // GetAppList(). 86 // GetAppList().
87 int app_list_load_count() const { return app_list_load_count_; } 87 int app_list_load_count() const { return app_list_load_count_; }
88 88
89 // Returns the number of times GetAllResourceList are blocked due to 89 // Returns the number of times GetAllFileList are blocked due to
90 // set_never_return_all_resource_list(). 90 // set_never_return_all_file_list().
91 int blocked_resource_list_load_count() const { 91 int blocked_file_list_load_count() const {
92 return blocked_resource_list_load_count_; 92 return blocked_file_list_load_count_;
93 } 93 }
94 94
95 // Returns the file path whose request is cancelled just before this method 95 // Returns the file path whose request is cancelled just before this method
96 // invocation. 96 // invocation.
97 const base::FilePath& last_cancelled_file() const { 97 const base::FilePath& last_cancelled_file() const {
98 return last_cancelled_file_; 98 return last_cancelled_file_;
99 } 99 }
100 100
101 // Returns the (fake) URL for the link. 101 // Returns the (fake) URL for the link.
102 static GURL GetFakeLinkUrl(const std::string& resource_id); 102 static GURL GetFakeLinkUrl(const std::string& resource_id);
103 103
104 // DriveServiceInterface Overrides 104 // DriveServiceInterface Overrides
105 virtual void Initialize(const std::string& account_id) OVERRIDE; 105 virtual void Initialize(const std::string& account_id) OVERRIDE;
106 virtual void AddObserver(DriveServiceObserver* observer) OVERRIDE; 106 virtual void AddObserver(DriveServiceObserver* observer) OVERRIDE;
107 virtual void RemoveObserver(DriveServiceObserver* observer) OVERRIDE; 107 virtual void RemoveObserver(DriveServiceObserver* observer) OVERRIDE;
108 virtual bool CanSendRequest() const OVERRIDE; 108 virtual bool CanSendRequest() const OVERRIDE;
109 virtual ResourceIdCanonicalizer GetResourceIdCanonicalizer() const OVERRIDE; 109 virtual ResourceIdCanonicalizer GetResourceIdCanonicalizer() const OVERRIDE;
110 virtual std::string GetRootResourceId() const OVERRIDE; 110 virtual std::string GetRootResourceId() const OVERRIDE;
111 virtual bool HasAccessToken() const OVERRIDE; 111 virtual bool HasAccessToken() const OVERRIDE;
112 virtual void RequestAccessToken( 112 virtual void RequestAccessToken(
113 const google_apis::AuthStatusCallback& callback) OVERRIDE; 113 const google_apis::AuthStatusCallback& callback) OVERRIDE;
114 virtual bool HasRefreshToken() const OVERRIDE; 114 virtual bool HasRefreshToken() const OVERRIDE;
115 virtual void ClearAccessToken() OVERRIDE; 115 virtual void ClearAccessToken() OVERRIDE;
116 virtual void ClearRefreshToken() OVERRIDE; 116 virtual void ClearRefreshToken() OVERRIDE;
117 virtual google_apis::CancelCallback GetAllResourceList( 117 virtual google_apis::CancelCallback GetAllFileList(
118 const google_apis::GetResourceListCallback& callback) OVERRIDE; 118 const google_apis::FileListCallback& callback) OVERRIDE;
119 virtual google_apis::CancelCallback GetResourceListInDirectory( 119 virtual google_apis::CancelCallback GetFileListInDirectory(
120 const std::string& directory_resource_id, 120 const std::string& directory_resource_id,
121 const google_apis::GetResourceListCallback& callback) OVERRIDE; 121 const google_apis::FileListCallback& callback) OVERRIDE;
122 // See the comment for EntryMatchWidthQuery() in .cc file for details about 122 // See the comment for EntryMatchWidthQuery() in .cc file for details about
123 // the supported search query types. 123 // the supported search query types.
124 virtual google_apis::CancelCallback Search( 124 virtual google_apis::CancelCallback Search(
125 const std::string& search_query, 125 const std::string& search_query,
126 const google_apis::GetResourceListCallback& callback) OVERRIDE; 126 const google_apis::FileListCallback& callback) OVERRIDE;
127 virtual google_apis::CancelCallback SearchByTitle( 127 virtual google_apis::CancelCallback SearchByTitle(
128 const std::string& title, 128 const std::string& title,
129 const std::string& directory_resource_id, 129 const std::string& directory_resource_id,
130 const google_apis::GetResourceListCallback& callback) OVERRIDE; 130 const google_apis::FileListCallback& callback) OVERRIDE;
131 virtual google_apis::CancelCallback GetChangeList( 131 virtual google_apis::CancelCallback GetChangeList(
132 int64 start_changestamp, 132 int64 start_changestamp,
133 const google_apis::ChangeListCallback& callback) OVERRIDE; 133 const google_apis::ChangeListCallback& callback) OVERRIDE;
134 virtual google_apis::CancelCallback GetRemainingChangeList( 134 virtual google_apis::CancelCallback GetRemainingChangeList(
135 const GURL& next_link, 135 const GURL& next_link,
136 const google_apis::ChangeListCallback& callback) OVERRIDE; 136 const google_apis::ChangeListCallback& callback) OVERRIDE;
137 virtual google_apis::CancelCallback GetRemainingFileList( 137 virtual google_apis::CancelCallback GetRemainingFileList(
138 const GURL& next_link, 138 const GURL& next_link,
139 const google_apis::GetResourceListCallback& callback) OVERRIDE; 139 const google_apis::FileListCallback& callback) OVERRIDE;
140 virtual google_apis::CancelCallback GetResourceEntry( 140 virtual google_apis::CancelCallback GetResourceEntry(
141 const std::string& resource_id, 141 const std::string& resource_id,
142 const google_apis::GetResourceEntryCallback& callback) OVERRIDE; 142 const google_apis::GetResourceEntryCallback& callback) OVERRIDE;
143 virtual google_apis::CancelCallback GetShareUrl( 143 virtual google_apis::CancelCallback GetShareUrl(
144 const std::string& resource_id, 144 const std::string& resource_id,
145 const GURL& embed_origin, 145 const GURL& embed_origin,
146 const google_apis::GetShareUrlCallback& callback) OVERRIDE; 146 const google_apis::GetShareUrlCallback& callback) OVERRIDE;
147 virtual google_apis::CancelCallback GetAboutResource( 147 virtual google_apis::CancelCallback GetAboutResource(
148 const google_apis::AboutResourceCallback& callback) OVERRIDE; 148 const google_apis::AboutResourceCallback& callback) OVERRIDE;
149 virtual google_apis::CancelCallback GetAppList( 149 virtual google_apis::CancelCallback GetAppList(
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 // |resource_id| can be empty, in the case, the id is automatically generated. 292 // |resource_id| can be empty, in the case, the id is automatically generated.
293 // Returns a pointer to the newly added entry, or NULL if failed. 293 // Returns a pointer to the newly added entry, or NULL if failed.
294 const EntryInfo* AddNewEntry( 294 const EntryInfo* AddNewEntry(
295 const std::string& resource_id, 295 const std::string& resource_id,
296 const std::string& content_type, 296 const std::string& content_type,
297 const std::string& content_data, 297 const std::string& content_data,
298 const std::string& parent_resource_id, 298 const std::string& parent_resource_id,
299 const std::string& title, 299 const std::string& title,
300 bool shared_with_me); 300 bool shared_with_me);
301 301
302 // Core implementation of GetResourceList. 302 // Core implementation of GetChangeList.
303 // This method returns the slice of the all matched entries, and its range 303 // This method returns the slice of the all matched entries, and its range
304 // is between |start_offset| (inclusive) and |start_offset| + |max_results| 304 // is between |start_offset| (inclusive) and |start_offset| + |max_results|
305 // (exclusive). 305 // (exclusive).
306 // Increments *load_counter by 1 before it returns successfully. 306 // Increments *load_counter by 1 before it returns successfully.
307 void GetResourceListInternal( 307 void GetChangeListInternal(
308 int64 start_changestamp, 308 int64 start_changestamp,
309 const std::string& search_query, 309 const std::string& search_query,
310 const std::string& directory_resource_id, 310 const std::string& directory_resource_id,
311 int start_offset, 311 int start_offset,
312 int max_results, 312 int max_results,
313 int* load_counter, 313 int* load_counter,
314 const google_apis::ChangeListCallback& callback); 314 const google_apis::ChangeListCallback& callback);
315 315
316 // Returns new upload session URL. 316 // Returns new upload session URL.
317 GURL GetNewUploadSessionUrl(); 317 GURL GetNewUploadSessionUrl();
318 318
319 typedef std::map<std::string, EntryInfo*> EntryInfoMap; 319 typedef std::map<std::string, EntryInfo*> EntryInfoMap;
320 EntryInfoMap entries_; 320 EntryInfoMap entries_;
321 scoped_ptr<google_apis::AboutResource> about_resource_; 321 scoped_ptr<google_apis::AboutResource> about_resource_;
322 scoped_ptr<base::DictionaryValue> app_info_value_; 322 scoped_ptr<base::DictionaryValue> app_info_value_;
323 std::map<GURL, UploadSession> upload_sessions_; 323 std::map<GURL, UploadSession> upload_sessions_;
324 int64 published_date_seq_; 324 int64 published_date_seq_;
325 int64 next_upload_sequence_number_; 325 int64 next_upload_sequence_number_;
326 int default_max_results_; 326 int default_max_results_;
327 int resource_id_count_; 327 int resource_id_count_;
328 int resource_list_load_count_; 328 int file_list_load_count_;
329 int change_list_load_count_; 329 int change_list_load_count_;
330 int directory_load_count_; 330 int directory_load_count_;
331 int about_resource_load_count_; 331 int about_resource_load_count_;
332 int app_list_load_count_; 332 int app_list_load_count_;
333 int blocked_resource_list_load_count_; 333 int blocked_file_list_load_count_;
334 bool offline_; 334 bool offline_;
335 bool never_return_all_resource_list_; 335 bool never_return_all_file_list_;
336 base::FilePath last_cancelled_file_; 336 base::FilePath last_cancelled_file_;
337 GURL share_url_base_; 337 GURL share_url_base_;
338 338
339 DISALLOW_COPY_AND_ASSIGN(FakeDriveService); 339 DISALLOW_COPY_AND_ASSIGN(FakeDriveService);
340 }; 340 };
341 341
342 } // namespace drive 342 } // namespace drive
343 343
344 #endif // CHROME_BROWSER_DRIVE_FAKE_DRIVE_SERVICE_H_ 344 #endif // CHROME_BROWSER_DRIVE_FAKE_DRIVE_SERVICE_H_
OLDNEW
« no previous file with comments | « chrome/browser/drive/dummy_drive_service.cc ('k') | chrome/browser/drive/fake_drive_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698