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

Side by Side Diff: chrome/browser/google_apis/drive_api_requests.h

Issue 23549003: Refactor GetChangelistRequest. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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
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_GOOGLE_APIS_DRIVE_API_REQUESTS_H_ 5 #ifndef CHROME_BROWSER_GOOGLE_APIS_DRIVE_API_REQUESTS_H_
6 #define CHROME_BROWSER_GOOGLE_APIS_DRIVE_API_REQUESTS_H_ 6 #define CHROME_BROWSER_GOOGLE_APIS_DRIVE_API_REQUESTS_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/callback_forward.h" 10 #include "base/callback_forward.h"
11 #include "chrome/browser/google_apis/base_requests.h" 11 #include "chrome/browser/google_apis/base_requests.h"
12 #include "chrome/browser/google_apis/drive_api_url_generator.h" 12 #include "chrome/browser/google_apis/drive_api_url_generator.h"
13 #include "chrome/browser/google_apis/drive_common_callbacks.h" 13 #include "chrome/browser/google_apis/drive_common_callbacks.h"
14 14
15 namespace google_apis { 15 namespace google_apis {
16 16
17 class ChangeList;
17 class FileResource; 18 class FileResource;
18 class FileList; 19 class FileList;
19 20
20 // Callback used for requests that the server returns FileResource data 21 // Callback used for requests that the server returns FileResource data
21 // formatted into JSON value. 22 // formatted into JSON value.
22 typedef base::Callback<void(GDataErrorCode error, 23 typedef base::Callback<void(GDataErrorCode error,
23 scoped_ptr<FileResource> entry)> 24 scoped_ptr<FileResource> entry)>
24 FileResourceCallback; 25 FileResourceCallback;
25 26
26 // Callback used for requests that the server returns FileList data 27 // Callback used for requests that the server returns FileList data
27 // formatted into JSON value. 28 // formatted into JSON value.
28 typedef base::Callback<void(GDataErrorCode error, 29 typedef base::Callback<void(GDataErrorCode error,
29 scoped_ptr<FileList> entry)> FileListCallback; 30 scoped_ptr<FileList> entry)> FileListCallback;
30 31
31 //============================ GetChangelistRequest ========================== 32 // Callback used for requests that the server returns ChangeList data
32 33 // formatted into JSON value.
33 // This class performs the request for fetching changelist. 34 typedef base::Callback<void(GDataErrorCode error,
34 // The result may contain only first part of the result. The remaining result 35 scoped_ptr<ChangeList> entry)> ChangeListCallback;
35 // should be able to be fetched by ContinueGetFileListRequest defined below.
36 class GetChangelistRequest : public GetDataRequest {
37 public:
38 // |include_deleted| specifies if the response should contain the changes
39 // for deleted entries or not.
40 // |start_changestamp| specifies the starting point of change list or 0 if
41 // all changes are necessary.
42 // |max_results| specifies the max of the number of files resource in the
43 // response.
44 GetChangelistRequest(RequestSender* sender,
45 const DriveApiUrlGenerator& url_generator,
46 bool include_deleted,
47 int64 start_changestamp,
48 int max_results,
49 const GetDataCallback& callback);
50 virtual ~GetChangelistRequest();
51
52 protected:
53 // Overridden from GetDataRequest.
54 virtual GURL GetURL() const OVERRIDE;
55
56 private:
57 const DriveApiUrlGenerator url_generator_;
58 const bool include_deleted_;
59 const int64 start_changestamp_;
60 const int max_results_;
61
62 DISALLOW_COPY_AND_ASSIGN(GetChangelistRequest);
63 };
64 36
65 namespace drive { 37 namespace drive {
66 38
67 //=============================== FilesGetRequest ============================= 39 //=============================== FilesGetRequest =============================
68 40
69 // This class performs the request for fetching a file. 41 // This class performs the request for fetching a file.
70 // This request is mapped to 42 // This request is mapped to
71 // https://developers.google.com/drive/v2/reference/files/get 43 // https://developers.google.com/drive/v2/reference/files/get
72 class FilesGetRequest : public GetDataRequest { 44 class FilesGetRequest : public GetDataRequest {
73 public: 45 public:
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 protected: 190 protected:
219 // Overridden from GetDataRequest. 191 // Overridden from GetDataRequest.
220 virtual GURL GetURL() const OVERRIDE; 192 virtual GURL GetURL() const OVERRIDE;
221 193
222 private: 194 private:
223 const DriveApiUrlGenerator url_generator_; 195 const DriveApiUrlGenerator url_generator_;
224 196
225 DISALLOW_COPY_AND_ASSIGN(AboutGetRequest); 197 DISALLOW_COPY_AND_ASSIGN(AboutGetRequest);
226 }; 198 };
227 199
200 //============================ ChangesListRequest ============================
201
202 // This class performs the request for fetching ChangeList.
203 // The result may contain only first part of the result. The remaining result
204 // should be able to be fetched by ContinueGetFileListRequest defined below.
205 // or by ChangesListRequest with setting page token.
206 // This request is mapped to
207 // https://developers.google.com/drive/v2/reference/changes/list
208 class ChangesListRequest : public GetDataRequest {
209 public:
210 ChangesListRequest(RequestSender* sender,
211 const DriveApiUrlGenerator& url_generator,
212 const ChangeListCallback& callback);
213 virtual ~ChangesListRequest();
214
215 // Optional parameter
216 bool include_deleted() const { return include_deleted_; }
217 void set_include_deleted(bool include_deleted) {
218 include_deleted_ = include_deleted;
219 }
220
221 int max_results() const { return max_results_; }
222 void set_max_results(int max_results) { max_results_ = max_results; }
223
224 const std::string& page_token() const { return page_token_; }
225 void set_page_token(const std::string& page_token) {
226 page_token_ = page_token;
227 }
228
229 int64 start_change_id() const { return start_change_id_; }
230 void set_start_change_id(int64 start_change_id) {
231 start_change_id_ = start_change_id;
232 }
233
234 protected:
235 // Overridden from GetDataRequest.
236 virtual GURL GetURL() const OVERRIDE;
237
238 private:
239 const DriveApiUrlGenerator url_generator_;
240 bool include_deleted_;
241 int max_results_;
242 std::string page_token_;
243 int64 start_change_id_;
244
245 DISALLOW_COPY_AND_ASSIGN(ChangesListRequest);
246 };
247
228 //============================= AppsListRequest ============================ 248 //============================= AppsListRequest ============================
229 249
230 // This class performs the request for fetching AppList. 250 // This class performs the request for fetching AppList.
231 // This request is mapped to 251 // This request is mapped to
232 // https://developers.google.com/drive/v2/reference/apps/list 252 // https://developers.google.com/drive/v2/reference/apps/list
233 class AppsListRequest : public GetDataRequest { 253 class AppsListRequest : public GetDataRequest {
234 public: 254 public:
235 AppsListRequest(RequestSender* sender, 255 AppsListRequest(RequestSender* sender,
236 const DriveApiUrlGenerator& url_generator, 256 const DriveApiUrlGenerator& url_generator,
237 const AppListCallback& callback); 257 const AppListCallback& callback);
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 const ProgressCallback& progress_callback); 664 const ProgressCallback& progress_callback);
645 virtual ~DownloadFileRequest(); 665 virtual ~DownloadFileRequest();
646 666
647 DISALLOW_COPY_AND_ASSIGN(DownloadFileRequest); 667 DISALLOW_COPY_AND_ASSIGN(DownloadFileRequest);
648 }; 668 };
649 669
650 } // namespace drive 670 } // namespace drive
651 } // namespace google_apis 671 } // namespace google_apis
652 672
653 #endif // CHROME_BROWSER_GOOGLE_APIS_DRIVE_API_REQUESTS_H_ 673 #endif // CHROME_BROWSER_GOOGLE_APIS_DRIVE_API_REQUESTS_H_
OLDNEW
« no previous file with comments | « chrome/browser/drive/drive_api_service.cc ('k') | chrome/browser/google_apis/drive_api_requests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698