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 GOOGLE_APIS_DRIVE_DRIVE_API_REQUESTS_H_ | 5 #ifndef GOOGLE_APIS_DRIVE_DRIVE_API_REQUESTS_H_ |
6 #define GOOGLE_APIS_DRIVE_DRIVE_API_REQUESTS_H_ | 6 #define GOOGLE_APIS_DRIVE_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" |
(...skipping 29 matching lines...) Expand all Loading... |
40 | 40 |
41 //============================ DriveApiPartialFieldRequest ==================== | 41 //============================ DriveApiPartialFieldRequest ==================== |
42 | 42 |
43 // This is base class of the Drive API related requests. All Drive API requests | 43 // This is base class of the Drive API related requests. All Drive API requests |
44 // support partial request (to improve the performance). The function can be | 44 // support partial request (to improve the performance). The function can be |
45 // shared among the Drive API requests. | 45 // shared among the Drive API requests. |
46 // See also https://developers.google.com/drive/performance | 46 // See also https://developers.google.com/drive/performance |
47 class DriveApiPartialFieldRequest : public UrlFetchRequestBase { | 47 class DriveApiPartialFieldRequest : public UrlFetchRequestBase { |
48 public: | 48 public: |
49 explicit DriveApiPartialFieldRequest(RequestSender* sender); | 49 explicit DriveApiPartialFieldRequest(RequestSender* sender); |
50 virtual ~DriveApiPartialFieldRequest(); | 50 ~DriveApiPartialFieldRequest() override; |
51 | 51 |
52 // Optional parameter. | 52 // Optional parameter. |
53 const std::string& fields() const { return fields_; } | 53 const std::string& fields() const { return fields_; } |
54 void set_fields(const std::string& fields) { fields_ = fields; } | 54 void set_fields(const std::string& fields) { fields_ = fields; } |
55 | 55 |
56 protected: | 56 protected: |
57 // UrlFetchRequestBase overrides. | 57 // UrlFetchRequestBase overrides. |
58 virtual GURL GetURL() const override; | 58 GURL GetURL() const override; |
59 | 59 |
60 // Derived classes should override GetURLInternal instead of GetURL() | 60 // Derived classes should override GetURLInternal instead of GetURL() |
61 // directly. | 61 // directly. |
62 virtual GURL GetURLInternal() const = 0; | 62 virtual GURL GetURLInternal() const = 0; |
63 | 63 |
64 private: | 64 private: |
65 std::string fields_; | 65 std::string fields_; |
66 | 66 |
67 DISALLOW_COPY_AND_ASSIGN(DriveApiPartialFieldRequest); | 67 DISALLOW_COPY_AND_ASSIGN(DriveApiPartialFieldRequest); |
68 }; | 68 }; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 //=============================== FilesGetRequest ============================= | 139 //=============================== FilesGetRequest ============================= |
140 | 140 |
141 // This class performs the request for fetching a file. | 141 // This class performs the request for fetching a file. |
142 // This request is mapped to | 142 // This request is mapped to |
143 // https://developers.google.com/drive/v2/reference/files/get | 143 // https://developers.google.com/drive/v2/reference/files/get |
144 class FilesGetRequest : public DriveApiDataRequest<FileResource> { | 144 class FilesGetRequest : public DriveApiDataRequest<FileResource> { |
145 public: | 145 public: |
146 FilesGetRequest(RequestSender* sender, | 146 FilesGetRequest(RequestSender* sender, |
147 const DriveApiUrlGenerator& url_generator, | 147 const DriveApiUrlGenerator& url_generator, |
148 const FileResourceCallback& callback); | 148 const FileResourceCallback& callback); |
149 virtual ~FilesGetRequest(); | 149 ~FilesGetRequest() override; |
150 | 150 |
151 // Required parameter. | 151 // Required parameter. |
152 const std::string& file_id() const { return file_id_; } | 152 const std::string& file_id() const { return file_id_; } |
153 void set_file_id(const std::string& file_id) { file_id_ = file_id; } | 153 void set_file_id(const std::string& file_id) { file_id_ = file_id; } |
154 | 154 |
155 protected: | 155 protected: |
156 // Overridden from DriveApiDataRequest. | 156 // Overridden from DriveApiDataRequest. |
157 virtual GURL GetURLInternal() const override; | 157 GURL GetURLInternal() const override; |
158 | 158 |
159 private: | 159 private: |
160 const DriveApiUrlGenerator url_generator_; | 160 const DriveApiUrlGenerator url_generator_; |
161 std::string file_id_; | 161 std::string file_id_; |
162 | 162 |
163 DISALLOW_COPY_AND_ASSIGN(FilesGetRequest); | 163 DISALLOW_COPY_AND_ASSIGN(FilesGetRequest); |
164 }; | 164 }; |
165 | 165 |
166 //============================ FilesAuthorizeRequest =========================== | 166 //============================ FilesAuthorizeRequest =========================== |
167 | 167 |
168 // This class performs request for authorizing an app to access a file. | 168 // This class performs request for authorizing an app to access a file. |
169 // This request is mapped to /drive/v2internal/file/authorize internal endpoint. | 169 // This request is mapped to /drive/v2internal/file/authorize internal endpoint. |
170 class FilesAuthorizeRequest : public DriveApiDataRequest<FileResource> { | 170 class FilesAuthorizeRequest : public DriveApiDataRequest<FileResource> { |
171 public: | 171 public: |
172 FilesAuthorizeRequest(RequestSender* sender, | 172 FilesAuthorizeRequest(RequestSender* sender, |
173 const DriveApiUrlGenerator& url_generator, | 173 const DriveApiUrlGenerator& url_generator, |
174 const FileResourceCallback& callback); | 174 const FileResourceCallback& callback); |
175 virtual ~FilesAuthorizeRequest(); | 175 ~FilesAuthorizeRequest() override; |
176 | 176 |
177 // Required parameter. | 177 // Required parameter. |
178 const std::string& file_id() const { return file_id_; } | 178 const std::string& file_id() const { return file_id_; } |
179 void set_file_id(const std::string& file_id) { file_id_ = file_id; } | 179 void set_file_id(const std::string& file_id) { file_id_ = file_id; } |
180 const std::string& app_id() const { return app_id_; } | 180 const std::string& app_id() const { return app_id_; } |
181 void set_app_id(const std::string& app_id) { app_id_ = app_id; } | 181 void set_app_id(const std::string& app_id) { app_id_ = app_id; } |
182 | 182 |
183 protected: | 183 protected: |
184 // Overridden from GetDataRequest. | 184 // Overridden from GetDataRequest. |
185 virtual net::URLFetcher::RequestType GetRequestType() const override; | 185 net::URLFetcher::RequestType GetRequestType() const override; |
186 | 186 |
187 // Overridden from DriveApiDataRequest. | 187 // Overridden from DriveApiDataRequest. |
188 virtual GURL GetURLInternal() const override; | 188 GURL GetURLInternal() const override; |
189 | 189 |
190 private: | 190 private: |
191 const DriveApiUrlGenerator url_generator_; | 191 const DriveApiUrlGenerator url_generator_; |
192 std::string file_id_; | 192 std::string file_id_; |
193 std::string app_id_; | 193 std::string app_id_; |
194 | 194 |
195 DISALLOW_COPY_AND_ASSIGN(FilesAuthorizeRequest); | 195 DISALLOW_COPY_AND_ASSIGN(FilesAuthorizeRequest); |
196 }; | 196 }; |
197 | 197 |
198 //============================ FilesInsertRequest ============================= | 198 //============================ FilesInsertRequest ============================= |
199 | 199 |
200 // This class performs the request for creating a resource. | 200 // This class performs the request for creating a resource. |
201 // This request is mapped to | 201 // This request is mapped to |
202 // https://developers.google.com/drive/v2/reference/files/insert | 202 // https://developers.google.com/drive/v2/reference/files/insert |
203 // See also https://developers.google.com/drive/manage-uploads and | 203 // See also https://developers.google.com/drive/manage-uploads and |
204 // https://developers.google.com/drive/folder | 204 // https://developers.google.com/drive/folder |
205 class FilesInsertRequest : public DriveApiDataRequest<FileResource> { | 205 class FilesInsertRequest : public DriveApiDataRequest<FileResource> { |
206 public: | 206 public: |
207 FilesInsertRequest(RequestSender* sender, | 207 FilesInsertRequest(RequestSender* sender, |
208 const DriveApiUrlGenerator& url_generator, | 208 const DriveApiUrlGenerator& url_generator, |
209 const FileResourceCallback& callback); | 209 const FileResourceCallback& callback); |
210 virtual ~FilesInsertRequest(); | 210 ~FilesInsertRequest() override; |
211 | 211 |
212 // Optional request body. | 212 // Optional request body. |
213 const base::Time& last_viewed_by_me_date() const { | 213 const base::Time& last_viewed_by_me_date() const { |
214 return last_viewed_by_me_date_; | 214 return last_viewed_by_me_date_; |
215 } | 215 } |
216 void set_last_viewed_by_me_date(const base::Time& last_viewed_by_me_date) { | 216 void set_last_viewed_by_me_date(const base::Time& last_viewed_by_me_date) { |
217 last_viewed_by_me_date_ = last_viewed_by_me_date; | 217 last_viewed_by_me_date_ = last_viewed_by_me_date; |
218 } | 218 } |
219 | 219 |
220 const std::string& mime_type() const { return mime_type_; } | 220 const std::string& mime_type() const { return mime_type_; } |
221 void set_mime_type(const std::string& mime_type) { | 221 void set_mime_type(const std::string& mime_type) { |
222 mime_type_ = mime_type; | 222 mime_type_ = mime_type; |
223 } | 223 } |
224 | 224 |
225 const base::Time& modified_date() const { return modified_date_; } | 225 const base::Time& modified_date() const { return modified_date_; } |
226 void set_modified_date(const base::Time& modified_date) { | 226 void set_modified_date(const base::Time& modified_date) { |
227 modified_date_ = modified_date; | 227 modified_date_ = modified_date; |
228 } | 228 } |
229 | 229 |
230 const std::vector<std::string>& parents() const { return parents_; } | 230 const std::vector<std::string>& parents() const { return parents_; } |
231 void add_parent(const std::string& parent) { parents_.push_back(parent); } | 231 void add_parent(const std::string& parent) { parents_.push_back(parent); } |
232 | 232 |
233 const std::string& title() const { return title_; } | 233 const std::string& title() const { return title_; } |
234 void set_title(const std::string& title) { title_ = title; } | 234 void set_title(const std::string& title) { title_ = title; } |
235 | 235 |
236 protected: | 236 protected: |
237 // Overridden from GetDataRequest. | 237 // Overridden from GetDataRequest. |
238 virtual net::URLFetcher::RequestType GetRequestType() const override; | 238 net::URLFetcher::RequestType GetRequestType() const override; |
239 virtual bool GetContentData(std::string* upload_content_type, | 239 bool GetContentData(std::string* upload_content_type, |
240 std::string* upload_content) override; | 240 std::string* upload_content) override; |
241 | 241 |
242 // Overridden from DriveApiDataRequest. | 242 // Overridden from DriveApiDataRequest. |
243 virtual GURL GetURLInternal() const override; | 243 GURL GetURLInternal() const override; |
244 | 244 |
245 private: | 245 private: |
246 const DriveApiUrlGenerator url_generator_; | 246 const DriveApiUrlGenerator url_generator_; |
247 | 247 |
248 base::Time last_viewed_by_me_date_; | 248 base::Time last_viewed_by_me_date_; |
249 std::string mime_type_; | 249 std::string mime_type_; |
250 base::Time modified_date_; | 250 base::Time modified_date_; |
251 std::vector<std::string> parents_; | 251 std::vector<std::string> parents_; |
252 std::string title_; | 252 std::string title_; |
253 | 253 |
254 DISALLOW_COPY_AND_ASSIGN(FilesInsertRequest); | 254 DISALLOW_COPY_AND_ASSIGN(FilesInsertRequest); |
255 }; | 255 }; |
256 | 256 |
257 //============================== FilesPatchRequest ============================ | 257 //============================== FilesPatchRequest ============================ |
258 | 258 |
259 // This class performs the request for patching file metadata. | 259 // This class performs the request for patching file metadata. |
260 // This request is mapped to | 260 // This request is mapped to |
261 // https://developers.google.com/drive/v2/reference/files/patch | 261 // https://developers.google.com/drive/v2/reference/files/patch |
262 class FilesPatchRequest : public DriveApiDataRequest<FileResource> { | 262 class FilesPatchRequest : public DriveApiDataRequest<FileResource> { |
263 public: | 263 public: |
264 FilesPatchRequest(RequestSender* sender, | 264 FilesPatchRequest(RequestSender* sender, |
265 const DriveApiUrlGenerator& url_generator, | 265 const DriveApiUrlGenerator& url_generator, |
266 const FileResourceCallback& callback); | 266 const FileResourceCallback& callback); |
267 virtual ~FilesPatchRequest(); | 267 ~FilesPatchRequest() override; |
268 | 268 |
269 // Required parameter. | 269 // Required parameter. |
270 const std::string& file_id() const { return file_id_; } | 270 const std::string& file_id() const { return file_id_; } |
271 void set_file_id(const std::string& file_id) { file_id_ = file_id; } | 271 void set_file_id(const std::string& file_id) { file_id_ = file_id; } |
272 | 272 |
273 // Optional parameter. | 273 // Optional parameter. |
274 bool set_modified_date() const { return set_modified_date_; } | 274 bool set_modified_date() const { return set_modified_date_; } |
275 void set_set_modified_date(bool set_modified_date) { | 275 void set_set_modified_date(bool set_modified_date) { |
276 set_modified_date_ = set_modified_date; | 276 set_modified_date_ = set_modified_date; |
277 } | 277 } |
(...skipping 20 matching lines...) Expand all Loading... |
298 } | 298 } |
299 void set_last_viewed_by_me_date(const base::Time& last_viewed_by_me_date) { | 299 void set_last_viewed_by_me_date(const base::Time& last_viewed_by_me_date) { |
300 last_viewed_by_me_date_ = last_viewed_by_me_date; | 300 last_viewed_by_me_date_ = last_viewed_by_me_date; |
301 } | 301 } |
302 | 302 |
303 const std::vector<std::string>& parents() const { return parents_; } | 303 const std::vector<std::string>& parents() const { return parents_; } |
304 void add_parent(const std::string& parent) { parents_.push_back(parent); } | 304 void add_parent(const std::string& parent) { parents_.push_back(parent); } |
305 | 305 |
306 protected: | 306 protected: |
307 // Overridden from URLFetchRequestBase. | 307 // Overridden from URLFetchRequestBase. |
308 virtual net::URLFetcher::RequestType GetRequestType() const override; | 308 net::URLFetcher::RequestType GetRequestType() const override; |
309 virtual std::vector<std::string> GetExtraRequestHeaders() const override; | 309 std::vector<std::string> GetExtraRequestHeaders() const override; |
310 virtual bool GetContentData(std::string* upload_content_type, | 310 bool GetContentData(std::string* upload_content_type, |
311 std::string* upload_content) override; | 311 std::string* upload_content) override; |
312 | 312 |
313 // Overridden from DriveApiDataRequest. | 313 // Overridden from DriveApiDataRequest. |
314 virtual GURL GetURLInternal() const override; | 314 GURL GetURLInternal() const override; |
315 | 315 |
316 private: | 316 private: |
317 const DriveApiUrlGenerator url_generator_; | 317 const DriveApiUrlGenerator url_generator_; |
318 | 318 |
319 std::string file_id_; | 319 std::string file_id_; |
320 bool set_modified_date_; | 320 bool set_modified_date_; |
321 bool update_viewed_date_; | 321 bool update_viewed_date_; |
322 | 322 |
323 std::string title_; | 323 std::string title_; |
324 base::Time modified_date_; | 324 base::Time modified_date_; |
325 base::Time last_viewed_by_me_date_; | 325 base::Time last_viewed_by_me_date_; |
326 std::vector<std::string> parents_; | 326 std::vector<std::string> parents_; |
327 | 327 |
328 DISALLOW_COPY_AND_ASSIGN(FilesPatchRequest); | 328 DISALLOW_COPY_AND_ASSIGN(FilesPatchRequest); |
329 }; | 329 }; |
330 | 330 |
331 //============================= FilesCopyRequest ============================== | 331 //============================= FilesCopyRequest ============================== |
332 | 332 |
333 // This class performs the request for copying a resource. | 333 // This class performs the request for copying a resource. |
334 // This request is mapped to | 334 // This request is mapped to |
335 // https://developers.google.com/drive/v2/reference/files/copy | 335 // https://developers.google.com/drive/v2/reference/files/copy |
336 class FilesCopyRequest : public DriveApiDataRequest<FileResource> { | 336 class FilesCopyRequest : public DriveApiDataRequest<FileResource> { |
337 public: | 337 public: |
338 // Upon completion, |callback| will be called. |callback| must not be null. | 338 // Upon completion, |callback| will be called. |callback| must not be null. |
339 FilesCopyRequest(RequestSender* sender, | 339 FilesCopyRequest(RequestSender* sender, |
340 const DriveApiUrlGenerator& url_generator, | 340 const DriveApiUrlGenerator& url_generator, |
341 const FileResourceCallback& callback); | 341 const FileResourceCallback& callback); |
342 virtual ~FilesCopyRequest(); | 342 ~FilesCopyRequest() override; |
343 | 343 |
344 // Required parameter. | 344 // Required parameter. |
345 const std::string& file_id() const { return file_id_; } | 345 const std::string& file_id() const { return file_id_; } |
346 void set_file_id(const std::string& file_id) { file_id_ = file_id; } | 346 void set_file_id(const std::string& file_id) { file_id_ = file_id; } |
347 | 347 |
348 // Optional request body. | 348 // Optional request body. |
349 const std::vector<std::string>& parents() const { return parents_; } | 349 const std::vector<std::string>& parents() const { return parents_; } |
350 void add_parent(const std::string& parent) { parents_.push_back(parent); } | 350 void add_parent(const std::string& parent) { parents_.push_back(parent); } |
351 | 351 |
352 const base::Time& modified_date() const { return modified_date_; } | 352 const base::Time& modified_date() const { return modified_date_; } |
353 void set_modified_date(const base::Time& modified_date) { | 353 void set_modified_date(const base::Time& modified_date) { |
354 modified_date_ = modified_date; | 354 modified_date_ = modified_date; |
355 } | 355 } |
356 | 356 |
357 const std::string& title() const { return title_; } | 357 const std::string& title() const { return title_; } |
358 void set_title(const std::string& title) { title_ = title; } | 358 void set_title(const std::string& title) { title_ = title; } |
359 | 359 |
360 protected: | 360 protected: |
361 // Overridden from URLFetchRequestBase. | 361 // Overridden from URLFetchRequestBase. |
362 virtual net::URLFetcher::RequestType GetRequestType() const override; | 362 net::URLFetcher::RequestType GetRequestType() const override; |
363 virtual bool GetContentData(std::string* upload_content_type, | 363 bool GetContentData(std::string* upload_content_type, |
364 std::string* upload_content) override; | 364 std::string* upload_content) override; |
365 | 365 |
366 // Overridden from DriveApiDataRequest. | 366 // Overridden from DriveApiDataRequest. |
367 virtual GURL GetURLInternal() const override; | 367 GURL GetURLInternal() const override; |
368 | 368 |
369 private: | 369 private: |
370 const DriveApiUrlGenerator url_generator_; | 370 const DriveApiUrlGenerator url_generator_; |
371 | 371 |
372 std::string file_id_; | 372 std::string file_id_; |
373 base::Time modified_date_; | 373 base::Time modified_date_; |
374 std::vector<std::string> parents_; | 374 std::vector<std::string> parents_; |
375 std::string title_; | 375 std::string title_; |
376 | 376 |
377 DISALLOW_COPY_AND_ASSIGN(FilesCopyRequest); | 377 DISALLOW_COPY_AND_ASSIGN(FilesCopyRequest); |
378 }; | 378 }; |
379 | 379 |
380 //============================= FilesListRequest ============================= | 380 //============================= FilesListRequest ============================= |
381 | 381 |
382 // This class performs the request for fetching FileList. | 382 // This class performs the request for fetching FileList. |
383 // The result may contain only first part of the result. The remaining result | 383 // The result may contain only first part of the result. The remaining result |
384 // should be able to be fetched by ContinueGetFileListRequest defined below, | 384 // should be able to be fetched by ContinueGetFileListRequest defined below, |
385 // or by FilesListRequest with setting page token. | 385 // or by FilesListRequest with setting page token. |
386 // This request is mapped to | 386 // This request is mapped to |
387 // https://developers.google.com/drive/v2/reference/files/list | 387 // https://developers.google.com/drive/v2/reference/files/list |
388 class FilesListRequest : public DriveApiDataRequest<FileList> { | 388 class FilesListRequest : public DriveApiDataRequest<FileList> { |
389 public: | 389 public: |
390 FilesListRequest(RequestSender* sender, | 390 FilesListRequest(RequestSender* sender, |
391 const DriveApiUrlGenerator& url_generator, | 391 const DriveApiUrlGenerator& url_generator, |
392 const FileListCallback& callback); | 392 const FileListCallback& callback); |
393 virtual ~FilesListRequest(); | 393 ~FilesListRequest() override; |
394 | 394 |
395 // Optional parameter | 395 // Optional parameter |
396 int max_results() const { return max_results_; } | 396 int max_results() const { return max_results_; } |
397 void set_max_results(int max_results) { max_results_ = max_results; } | 397 void set_max_results(int max_results) { max_results_ = max_results; } |
398 | 398 |
399 const std::string& page_token() const { return page_token_; } | 399 const std::string& page_token() const { return page_token_; } |
400 void set_page_token(const std::string& page_token) { | 400 void set_page_token(const std::string& page_token) { |
401 page_token_ = page_token; | 401 page_token_ = page_token; |
402 } | 402 } |
403 | 403 |
404 const std::string& q() const { return q_; } | 404 const std::string& q() const { return q_; } |
405 void set_q(const std::string& q) { q_ = q; } | 405 void set_q(const std::string& q) { q_ = q; } |
406 | 406 |
407 protected: | 407 protected: |
408 // Overridden from DriveApiDataRequest. | 408 // Overridden from DriveApiDataRequest. |
409 virtual GURL GetURLInternal() const override; | 409 GURL GetURLInternal() const override; |
410 | 410 |
411 private: | 411 private: |
412 const DriveApiUrlGenerator url_generator_; | 412 const DriveApiUrlGenerator url_generator_; |
413 int max_results_; | 413 int max_results_; |
414 std::string page_token_; | 414 std::string page_token_; |
415 std::string q_; | 415 std::string q_; |
416 | 416 |
417 DISALLOW_COPY_AND_ASSIGN(FilesListRequest); | 417 DISALLOW_COPY_AND_ASSIGN(FilesListRequest); |
418 }; | 418 }; |
419 | 419 |
420 //========================= FilesListNextPageRequest ========================== | 420 //========================= FilesListNextPageRequest ========================== |
421 | 421 |
422 // There are two ways to obtain next pages of "Files: list" result (if paged). | 422 // There are two ways to obtain next pages of "Files: list" result (if paged). |
423 // 1) Set pageToken and all params used for the initial request. | 423 // 1) Set pageToken and all params used for the initial request. |
424 // 2) Use URL in the nextLink field in the previous response. | 424 // 2) Use URL in the nextLink field in the previous response. |
425 // This class implements 2)'s request. | 425 // This class implements 2)'s request. |
426 class FilesListNextPageRequest : public DriveApiDataRequest<FileList> { | 426 class FilesListNextPageRequest : public DriveApiDataRequest<FileList> { |
427 public: | 427 public: |
428 FilesListNextPageRequest(RequestSender* sender, | 428 FilesListNextPageRequest(RequestSender* sender, |
429 const FileListCallback& callback); | 429 const FileListCallback& callback); |
430 virtual ~FilesListNextPageRequest(); | 430 ~FilesListNextPageRequest() override; |
431 | 431 |
432 const GURL& next_link() const { return next_link_; } | 432 const GURL& next_link() const { return next_link_; } |
433 void set_next_link(const GURL& next_link) { next_link_ = next_link; } | 433 void set_next_link(const GURL& next_link) { next_link_ = next_link; } |
434 | 434 |
435 protected: | 435 protected: |
436 // Overridden from DriveApiDataRequest. | 436 // Overridden from DriveApiDataRequest. |
437 virtual GURL GetURLInternal() const override; | 437 GURL GetURLInternal() const override; |
438 | 438 |
439 private: | 439 private: |
440 GURL next_link_; | 440 GURL next_link_; |
441 | 441 |
442 DISALLOW_COPY_AND_ASSIGN(FilesListNextPageRequest); | 442 DISALLOW_COPY_AND_ASSIGN(FilesListNextPageRequest); |
443 }; | 443 }; |
444 | 444 |
445 //============================= FilesDeleteRequest ============================= | 445 //============================= FilesDeleteRequest ============================= |
446 | 446 |
447 // This class performs the request for deleting a resource. | 447 // This class performs the request for deleting a resource. |
448 // This request is mapped to | 448 // This request is mapped to |
449 // https://developers.google.com/drive/v2/reference/files/delete | 449 // https://developers.google.com/drive/v2/reference/files/delete |
450 class FilesDeleteRequest : public EntryActionRequest { | 450 class FilesDeleteRequest : public EntryActionRequest { |
451 public: | 451 public: |
452 FilesDeleteRequest(RequestSender* sender, | 452 FilesDeleteRequest(RequestSender* sender, |
453 const DriveApiUrlGenerator& url_generator, | 453 const DriveApiUrlGenerator& url_generator, |
454 const EntryActionCallback& callback); | 454 const EntryActionCallback& callback); |
455 virtual ~FilesDeleteRequest(); | 455 ~FilesDeleteRequest() override; |
456 | 456 |
457 // Required parameter. | 457 // Required parameter. |
458 const std::string& file_id() const { return file_id_; } | 458 const std::string& file_id() const { return file_id_; } |
459 void set_file_id(const std::string& file_id) { file_id_ = file_id; } | 459 void set_file_id(const std::string& file_id) { file_id_ = file_id; } |
460 void set_etag(const std::string& etag) { etag_ = etag; } | 460 void set_etag(const std::string& etag) { etag_ = etag; } |
461 | 461 |
462 protected: | 462 protected: |
463 // Overridden from UrlFetchRequestBase. | 463 // Overridden from UrlFetchRequestBase. |
464 virtual net::URLFetcher::RequestType GetRequestType() const override; | 464 net::URLFetcher::RequestType GetRequestType() const override; |
465 virtual GURL GetURL() const override; | 465 GURL GetURL() const override; |
466 virtual std::vector<std::string> GetExtraRequestHeaders() const override; | 466 std::vector<std::string> GetExtraRequestHeaders() const override; |
467 | 467 |
468 private: | 468 private: |
469 const DriveApiUrlGenerator url_generator_; | 469 const DriveApiUrlGenerator url_generator_; |
470 std::string file_id_; | 470 std::string file_id_; |
471 std::string etag_; | 471 std::string etag_; |
472 | 472 |
473 DISALLOW_COPY_AND_ASSIGN(FilesDeleteRequest); | 473 DISALLOW_COPY_AND_ASSIGN(FilesDeleteRequest); |
474 }; | 474 }; |
475 | 475 |
476 //============================= FilesTrashRequest ============================== | 476 //============================= FilesTrashRequest ============================== |
477 | 477 |
478 // This class performs the request for trashing a resource. | 478 // This class performs the request for trashing a resource. |
479 // This request is mapped to | 479 // This request is mapped to |
480 // https://developers.google.com/drive/v2/reference/files/trash | 480 // https://developers.google.com/drive/v2/reference/files/trash |
481 class FilesTrashRequest : public DriveApiDataRequest<FileResource> { | 481 class FilesTrashRequest : public DriveApiDataRequest<FileResource> { |
482 public: | 482 public: |
483 FilesTrashRequest(RequestSender* sender, | 483 FilesTrashRequest(RequestSender* sender, |
484 const DriveApiUrlGenerator& url_generator, | 484 const DriveApiUrlGenerator& url_generator, |
485 const FileResourceCallback& callback); | 485 const FileResourceCallback& callback); |
486 virtual ~FilesTrashRequest(); | 486 ~FilesTrashRequest() override; |
487 | 487 |
488 // Required parameter. | 488 // Required parameter. |
489 const std::string& file_id() const { return file_id_; } | 489 const std::string& file_id() const { return file_id_; } |
490 void set_file_id(const std::string& file_id) { file_id_ = file_id; } | 490 void set_file_id(const std::string& file_id) { file_id_ = file_id; } |
491 | 491 |
492 protected: | 492 protected: |
493 // Overridden from UrlFetchRequestBase. | 493 // Overridden from UrlFetchRequestBase. |
494 virtual net::URLFetcher::RequestType GetRequestType() const override; | 494 net::URLFetcher::RequestType GetRequestType() const override; |
495 | 495 |
496 // Overridden from DriveApiDataRequest. | 496 // Overridden from DriveApiDataRequest. |
497 virtual GURL GetURLInternal() const override; | 497 GURL GetURLInternal() const override; |
498 | 498 |
499 private: | 499 private: |
500 const DriveApiUrlGenerator url_generator_; | 500 const DriveApiUrlGenerator url_generator_; |
501 std::string file_id_; | 501 std::string file_id_; |
502 | 502 |
503 DISALLOW_COPY_AND_ASSIGN(FilesTrashRequest); | 503 DISALLOW_COPY_AND_ASSIGN(FilesTrashRequest); |
504 }; | 504 }; |
505 | 505 |
506 //============================== AboutGetRequest ============================= | 506 //============================== AboutGetRequest ============================= |
507 | 507 |
508 // This class performs the request for fetching About data. | 508 // This class performs the request for fetching About data. |
509 // This request is mapped to | 509 // This request is mapped to |
510 // https://developers.google.com/drive/v2/reference/about/get | 510 // https://developers.google.com/drive/v2/reference/about/get |
511 class AboutGetRequest : public DriveApiDataRequest<AboutResource> { | 511 class AboutGetRequest : public DriveApiDataRequest<AboutResource> { |
512 public: | 512 public: |
513 AboutGetRequest(RequestSender* sender, | 513 AboutGetRequest(RequestSender* sender, |
514 const DriveApiUrlGenerator& url_generator, | 514 const DriveApiUrlGenerator& url_generator, |
515 const AboutResourceCallback& callback); | 515 const AboutResourceCallback& callback); |
516 virtual ~AboutGetRequest(); | 516 ~AboutGetRequest() override; |
517 | 517 |
518 protected: | 518 protected: |
519 // Overridden from DriveApiDataRequest. | 519 // Overridden from DriveApiDataRequest. |
520 virtual GURL GetURLInternal() const override; | 520 GURL GetURLInternal() const override; |
521 | 521 |
522 private: | 522 private: |
523 const DriveApiUrlGenerator url_generator_; | 523 const DriveApiUrlGenerator url_generator_; |
524 | 524 |
525 DISALLOW_COPY_AND_ASSIGN(AboutGetRequest); | 525 DISALLOW_COPY_AND_ASSIGN(AboutGetRequest); |
526 }; | 526 }; |
527 | 527 |
528 //============================ ChangesListRequest ============================ | 528 //============================ ChangesListRequest ============================ |
529 | 529 |
530 // This class performs the request for fetching ChangeList. | 530 // This class performs the request for fetching ChangeList. |
531 // The result may contain only first part of the result. The remaining result | 531 // The result may contain only first part of the result. The remaining result |
532 // should be able to be fetched by ContinueGetFileListRequest defined below. | 532 // should be able to be fetched by ContinueGetFileListRequest defined below. |
533 // or by ChangesListRequest with setting page token. | 533 // or by ChangesListRequest with setting page token. |
534 // This request is mapped to | 534 // This request is mapped to |
535 // https://developers.google.com/drive/v2/reference/changes/list | 535 // https://developers.google.com/drive/v2/reference/changes/list |
536 class ChangesListRequest : public DriveApiDataRequest<ChangeList> { | 536 class ChangesListRequest : public DriveApiDataRequest<ChangeList> { |
537 public: | 537 public: |
538 ChangesListRequest(RequestSender* sender, | 538 ChangesListRequest(RequestSender* sender, |
539 const DriveApiUrlGenerator& url_generator, | 539 const DriveApiUrlGenerator& url_generator, |
540 const ChangeListCallback& callback); | 540 const ChangeListCallback& callback); |
541 virtual ~ChangesListRequest(); | 541 ~ChangesListRequest() override; |
542 | 542 |
543 // Optional parameter | 543 // Optional parameter |
544 bool include_deleted() const { return include_deleted_; } | 544 bool include_deleted() const { return include_deleted_; } |
545 void set_include_deleted(bool include_deleted) { | 545 void set_include_deleted(bool include_deleted) { |
546 include_deleted_ = include_deleted; | 546 include_deleted_ = include_deleted; |
547 } | 547 } |
548 | 548 |
549 int max_results() const { return max_results_; } | 549 int max_results() const { return max_results_; } |
550 void set_max_results(int max_results) { max_results_ = max_results; } | 550 void set_max_results(int max_results) { max_results_ = max_results; } |
551 | 551 |
552 const std::string& page_token() const { return page_token_; } | 552 const std::string& page_token() const { return page_token_; } |
553 void set_page_token(const std::string& page_token) { | 553 void set_page_token(const std::string& page_token) { |
554 page_token_ = page_token; | 554 page_token_ = page_token; |
555 } | 555 } |
556 | 556 |
557 int64 start_change_id() const { return start_change_id_; } | 557 int64 start_change_id() const { return start_change_id_; } |
558 void set_start_change_id(int64 start_change_id) { | 558 void set_start_change_id(int64 start_change_id) { |
559 start_change_id_ = start_change_id; | 559 start_change_id_ = start_change_id; |
560 } | 560 } |
561 | 561 |
562 protected: | 562 protected: |
563 // Overridden from DriveApiDataRequest. | 563 // Overridden from DriveApiDataRequest. |
564 virtual GURL GetURLInternal() const override; | 564 GURL GetURLInternal() const override; |
565 | 565 |
566 private: | 566 private: |
567 const DriveApiUrlGenerator url_generator_; | 567 const DriveApiUrlGenerator url_generator_; |
568 bool include_deleted_; | 568 bool include_deleted_; |
569 int max_results_; | 569 int max_results_; |
570 std::string page_token_; | 570 std::string page_token_; |
571 int64 start_change_id_; | 571 int64 start_change_id_; |
572 | 572 |
573 DISALLOW_COPY_AND_ASSIGN(ChangesListRequest); | 573 DISALLOW_COPY_AND_ASSIGN(ChangesListRequest); |
574 }; | 574 }; |
575 | 575 |
576 //======================== ChangesListNextPageRequest ========================= | 576 //======================== ChangesListNextPageRequest ========================= |
577 | 577 |
578 // There are two ways to obtain next pages of "Changes: list" result (if paged). | 578 // There are two ways to obtain next pages of "Changes: list" result (if paged). |
579 // 1) Set pageToken and all params used for the initial request. | 579 // 1) Set pageToken and all params used for the initial request. |
580 // 2) Use URL in the nextLink field in the previous response. | 580 // 2) Use URL in the nextLink field in the previous response. |
581 // This class implements 2)'s request. | 581 // This class implements 2)'s request. |
582 class ChangesListNextPageRequest : public DriveApiDataRequest<ChangeList> { | 582 class ChangesListNextPageRequest : public DriveApiDataRequest<ChangeList> { |
583 public: | 583 public: |
584 ChangesListNextPageRequest(RequestSender* sender, | 584 ChangesListNextPageRequest(RequestSender* sender, |
585 const ChangeListCallback& callback); | 585 const ChangeListCallback& callback); |
586 virtual ~ChangesListNextPageRequest(); | 586 ~ChangesListNextPageRequest() override; |
587 | 587 |
588 const GURL& next_link() const { return next_link_; } | 588 const GURL& next_link() const { return next_link_; } |
589 void set_next_link(const GURL& next_link) { next_link_ = next_link; } | 589 void set_next_link(const GURL& next_link) { next_link_ = next_link; } |
590 | 590 |
591 protected: | 591 protected: |
592 // Overridden from DriveApiDataRequest. | 592 // Overridden from DriveApiDataRequest. |
593 virtual GURL GetURLInternal() const override; | 593 GURL GetURLInternal() const override; |
594 | 594 |
595 private: | 595 private: |
596 GURL next_link_; | 596 GURL next_link_; |
597 | 597 |
598 DISALLOW_COPY_AND_ASSIGN(ChangesListNextPageRequest); | 598 DISALLOW_COPY_AND_ASSIGN(ChangesListNextPageRequest); |
599 }; | 599 }; |
600 | 600 |
601 //============================= AppsListRequest ============================ | 601 //============================= AppsListRequest ============================ |
602 | 602 |
603 // This class performs the request for fetching AppList. | 603 // This class performs the request for fetching AppList. |
604 // This request is mapped to | 604 // This request is mapped to |
605 // https://developers.google.com/drive/v2/reference/apps/list | 605 // https://developers.google.com/drive/v2/reference/apps/list |
606 class AppsListRequest : public DriveApiDataRequest<AppList> { | 606 class AppsListRequest : public DriveApiDataRequest<AppList> { |
607 public: | 607 public: |
608 AppsListRequest(RequestSender* sender, | 608 AppsListRequest(RequestSender* sender, |
609 const DriveApiUrlGenerator& url_generator, | 609 const DriveApiUrlGenerator& url_generator, |
610 bool use_internal_endpoint, | 610 bool use_internal_endpoint, |
611 const AppListCallback& callback); | 611 const AppListCallback& callback); |
612 virtual ~AppsListRequest(); | 612 ~AppsListRequest() override; |
613 | 613 |
614 protected: | 614 protected: |
615 // Overridden from DriveApiDataRequest. | 615 // Overridden from DriveApiDataRequest. |
616 virtual GURL GetURLInternal() const override; | 616 GURL GetURLInternal() const override; |
617 | 617 |
618 private: | 618 private: |
619 const DriveApiUrlGenerator url_generator_; | 619 const DriveApiUrlGenerator url_generator_; |
620 bool use_internal_endpoint_; | 620 bool use_internal_endpoint_; |
621 | 621 |
622 DISALLOW_COPY_AND_ASSIGN(AppsListRequest); | 622 DISALLOW_COPY_AND_ASSIGN(AppsListRequest); |
623 }; | 623 }; |
624 | 624 |
625 //============================= AppsDeleteRequest ============================== | 625 //============================= AppsDeleteRequest ============================== |
626 | 626 |
627 // This class performs the request for deleting a Drive app. | 627 // This class performs the request for deleting a Drive app. |
628 // This request is mapped to | 628 // This request is mapped to |
629 // https://developers.google.com/drive/v2/reference/files/trash | 629 // https://developers.google.com/drive/v2/reference/files/trash |
630 class AppsDeleteRequest : public EntryActionRequest { | 630 class AppsDeleteRequest : public EntryActionRequest { |
631 public: | 631 public: |
632 AppsDeleteRequest(RequestSender* sender, | 632 AppsDeleteRequest(RequestSender* sender, |
633 const DriveApiUrlGenerator& url_generator, | 633 const DriveApiUrlGenerator& url_generator, |
634 const EntryActionCallback& callback); | 634 const EntryActionCallback& callback); |
635 virtual ~AppsDeleteRequest(); | 635 ~AppsDeleteRequest() override; |
636 | 636 |
637 // Required parameter. | 637 // Required parameter. |
638 const std::string& app_id() const { return app_id_; } | 638 const std::string& app_id() const { return app_id_; } |
639 void set_app_id(const std::string& app_id) { app_id_ = app_id; } | 639 void set_app_id(const std::string& app_id) { app_id_ = app_id; } |
640 | 640 |
641 protected: | 641 protected: |
642 // Overridden from UrlFetchRequestBase. | 642 // Overridden from UrlFetchRequestBase. |
643 virtual net::URLFetcher::RequestType GetRequestType() const override; | 643 net::URLFetcher::RequestType GetRequestType() const override; |
644 virtual GURL GetURL() const override; | 644 GURL GetURL() const override; |
645 | 645 |
646 private: | 646 private: |
647 const DriveApiUrlGenerator url_generator_; | 647 const DriveApiUrlGenerator url_generator_; |
648 std::string app_id_; | 648 std::string app_id_; |
649 | 649 |
650 DISALLOW_COPY_AND_ASSIGN(AppsDeleteRequest); | 650 DISALLOW_COPY_AND_ASSIGN(AppsDeleteRequest); |
651 }; | 651 }; |
652 | 652 |
653 //========================== ChildrenInsertRequest ============================ | 653 //========================== ChildrenInsertRequest ============================ |
654 | 654 |
655 // This class performs the request for inserting a resource to a directory. | 655 // This class performs the request for inserting a resource to a directory. |
656 // This request is mapped to | 656 // This request is mapped to |
657 // https://developers.google.com/drive/v2/reference/children/insert | 657 // https://developers.google.com/drive/v2/reference/children/insert |
658 class ChildrenInsertRequest : public EntryActionRequest { | 658 class ChildrenInsertRequest : public EntryActionRequest { |
659 public: | 659 public: |
660 ChildrenInsertRequest(RequestSender* sender, | 660 ChildrenInsertRequest(RequestSender* sender, |
661 const DriveApiUrlGenerator& url_generator, | 661 const DriveApiUrlGenerator& url_generator, |
662 const EntryActionCallback& callback); | 662 const EntryActionCallback& callback); |
663 virtual ~ChildrenInsertRequest(); | 663 ~ChildrenInsertRequest() override; |
664 | 664 |
665 // Required parameter. | 665 // Required parameter. |
666 const std::string& folder_id() const { return folder_id_; } | 666 const std::string& folder_id() const { return folder_id_; } |
667 void set_folder_id(const std::string& folder_id) { | 667 void set_folder_id(const std::string& folder_id) { |
668 folder_id_ = folder_id; | 668 folder_id_ = folder_id; |
669 } | 669 } |
670 | 670 |
671 // Required body. | 671 // Required body. |
672 const std::string& id() const { return id_; } | 672 const std::string& id() const { return id_; } |
673 void set_id(const std::string& id) { id_ = id; } | 673 void set_id(const std::string& id) { id_ = id; } |
674 | 674 |
675 protected: | 675 protected: |
676 // UrlFetchRequestBase overrides. | 676 // UrlFetchRequestBase overrides. |
677 virtual net::URLFetcher::RequestType GetRequestType() const override; | 677 net::URLFetcher::RequestType GetRequestType() const override; |
678 virtual GURL GetURL() const override; | 678 GURL GetURL() const override; |
679 virtual bool GetContentData(std::string* upload_content_type, | 679 bool GetContentData(std::string* upload_content_type, |
680 std::string* upload_content) override; | 680 std::string* upload_content) override; |
681 | 681 |
682 private: | 682 private: |
683 const DriveApiUrlGenerator url_generator_; | 683 const DriveApiUrlGenerator url_generator_; |
684 std::string folder_id_; | 684 std::string folder_id_; |
685 std::string id_; | 685 std::string id_; |
686 | 686 |
687 DISALLOW_COPY_AND_ASSIGN(ChildrenInsertRequest); | 687 DISALLOW_COPY_AND_ASSIGN(ChildrenInsertRequest); |
688 }; | 688 }; |
689 | 689 |
690 //========================== ChildrenDeleteRequest ============================ | 690 //========================== ChildrenDeleteRequest ============================ |
691 | 691 |
692 // This class performs the request for removing a resource from a directory. | 692 // This class performs the request for removing a resource from a directory. |
693 // This request is mapped to | 693 // This request is mapped to |
694 // https://developers.google.com/drive/v2/reference/children/delete | 694 // https://developers.google.com/drive/v2/reference/children/delete |
695 class ChildrenDeleteRequest : public EntryActionRequest { | 695 class ChildrenDeleteRequest : public EntryActionRequest { |
696 public: | 696 public: |
697 // |callback| must not be null. | 697 // |callback| must not be null. |
698 ChildrenDeleteRequest(RequestSender* sender, | 698 ChildrenDeleteRequest(RequestSender* sender, |
699 const DriveApiUrlGenerator& url_generator, | 699 const DriveApiUrlGenerator& url_generator, |
700 const EntryActionCallback& callback); | 700 const EntryActionCallback& callback); |
701 virtual ~ChildrenDeleteRequest(); | 701 ~ChildrenDeleteRequest() override; |
702 | 702 |
703 // Required parameter. | 703 // Required parameter. |
704 const std::string& child_id() const { return child_id_; } | 704 const std::string& child_id() const { return child_id_; } |
705 void set_child_id(const std::string& child_id) { | 705 void set_child_id(const std::string& child_id) { |
706 child_id_ = child_id; | 706 child_id_ = child_id; |
707 } | 707 } |
708 | 708 |
709 const std::string& folder_id() const { return folder_id_; } | 709 const std::string& folder_id() const { return folder_id_; } |
710 void set_folder_id(const std::string& folder_id) { | 710 void set_folder_id(const std::string& folder_id) { |
711 folder_id_ = folder_id; | 711 folder_id_ = folder_id; |
712 } | 712 } |
713 | 713 |
714 protected: | 714 protected: |
715 // UrlFetchRequestBase overrides. | 715 // UrlFetchRequestBase overrides. |
716 virtual net::URLFetcher::RequestType GetRequestType() const override; | 716 net::URLFetcher::RequestType GetRequestType() const override; |
717 virtual GURL GetURL() const override; | 717 GURL GetURL() const override; |
718 | 718 |
719 private: | 719 private: |
720 const DriveApiUrlGenerator url_generator_; | 720 const DriveApiUrlGenerator url_generator_; |
721 std::string child_id_; | 721 std::string child_id_; |
722 std::string folder_id_; | 722 std::string folder_id_; |
723 | 723 |
724 DISALLOW_COPY_AND_ASSIGN(ChildrenDeleteRequest); | 724 DISALLOW_COPY_AND_ASSIGN(ChildrenDeleteRequest); |
725 }; | 725 }; |
726 | 726 |
727 //======================= InitiateUploadNewFileRequest ======================= | 727 //======================= InitiateUploadNewFileRequest ======================= |
728 | 728 |
729 // This class performs the request for initiating the upload of a new file. | 729 // This class performs the request for initiating the upload of a new file. |
730 class InitiateUploadNewFileRequest : public InitiateUploadRequestBase { | 730 class InitiateUploadNewFileRequest : public InitiateUploadRequestBase { |
731 public: | 731 public: |
732 // |parent_resource_id| should be the resource id of the parent directory. | 732 // |parent_resource_id| should be the resource id of the parent directory. |
733 // |title| should be set. | 733 // |title| should be set. |
734 // See also the comments of InitiateUploadRequestBase for more details | 734 // See also the comments of InitiateUploadRequestBase for more details |
735 // about the other parameters. | 735 // about the other parameters. |
736 InitiateUploadNewFileRequest(RequestSender* sender, | 736 InitiateUploadNewFileRequest(RequestSender* sender, |
737 const DriveApiUrlGenerator& url_generator, | 737 const DriveApiUrlGenerator& url_generator, |
738 const std::string& content_type, | 738 const std::string& content_type, |
739 int64 content_length, | 739 int64 content_length, |
740 const std::string& parent_resource_id, | 740 const std::string& parent_resource_id, |
741 const std::string& title, | 741 const std::string& title, |
742 const InitiateUploadCallback& callback); | 742 const InitiateUploadCallback& callback); |
743 virtual ~InitiateUploadNewFileRequest(); | 743 ~InitiateUploadNewFileRequest() override; |
744 | 744 |
745 // Optional parameters. | 745 // Optional parameters. |
746 const base::Time& modified_date() const { return modified_date_; } | 746 const base::Time& modified_date() const { return modified_date_; } |
747 void set_modified_date(const base::Time& modified_date) { | 747 void set_modified_date(const base::Time& modified_date) { |
748 modified_date_ = modified_date; | 748 modified_date_ = modified_date; |
749 } | 749 } |
750 const base::Time& last_viewed_by_me_date() const { | 750 const base::Time& last_viewed_by_me_date() const { |
751 return last_viewed_by_me_date_; | 751 return last_viewed_by_me_date_; |
752 } | 752 } |
753 void set_last_viewed_by_me_date(const base::Time& last_viewed_by_me_date) { | 753 void set_last_viewed_by_me_date(const base::Time& last_viewed_by_me_date) { |
754 last_viewed_by_me_date_ = last_viewed_by_me_date; | 754 last_viewed_by_me_date_ = last_viewed_by_me_date; |
755 } | 755 } |
756 | 756 |
757 protected: | 757 protected: |
758 // UrlFetchRequestBase overrides. | 758 // UrlFetchRequestBase overrides. |
759 virtual GURL GetURL() const override; | 759 GURL GetURL() const override; |
760 virtual net::URLFetcher::RequestType GetRequestType() const override; | 760 net::URLFetcher::RequestType GetRequestType() const override; |
761 virtual bool GetContentData(std::string* upload_content_type, | 761 bool GetContentData(std::string* upload_content_type, |
762 std::string* upload_content) override; | 762 std::string* upload_content) override; |
763 | 763 |
764 private: | 764 private: |
765 const DriveApiUrlGenerator url_generator_; | 765 const DriveApiUrlGenerator url_generator_; |
766 const std::string parent_resource_id_; | 766 const std::string parent_resource_id_; |
767 const std::string title_; | 767 const std::string title_; |
768 | 768 |
769 base::Time modified_date_; | 769 base::Time modified_date_; |
770 base::Time last_viewed_by_me_date_; | 770 base::Time last_viewed_by_me_date_; |
771 | 771 |
772 DISALLOW_COPY_AND_ASSIGN(InitiateUploadNewFileRequest); | 772 DISALLOW_COPY_AND_ASSIGN(InitiateUploadNewFileRequest); |
(...skipping 10 matching lines...) Expand all Loading... |
783 // |etag| should be set if it is available to detect the upload confliction. | 783 // |etag| should be set if it is available to detect the upload confliction. |
784 // See also the comments of InitiateUploadRequestBase for more details | 784 // See also the comments of InitiateUploadRequestBase for more details |
785 // about the other parameters. | 785 // about the other parameters. |
786 InitiateUploadExistingFileRequest(RequestSender* sender, | 786 InitiateUploadExistingFileRequest(RequestSender* sender, |
787 const DriveApiUrlGenerator& url_generator, | 787 const DriveApiUrlGenerator& url_generator, |
788 const std::string& content_type, | 788 const std::string& content_type, |
789 int64 content_length, | 789 int64 content_length, |
790 const std::string& resource_id, | 790 const std::string& resource_id, |
791 const std::string& etag, | 791 const std::string& etag, |
792 const InitiateUploadCallback& callback); | 792 const InitiateUploadCallback& callback); |
793 virtual ~InitiateUploadExistingFileRequest(); | 793 ~InitiateUploadExistingFileRequest() override; |
794 | |
795 | 794 |
796 // Optional parameters. | 795 // Optional parameters. |
797 const std::string& parent_resource_id() const { return parent_resource_id_; } | 796 const std::string& parent_resource_id() const { return parent_resource_id_; } |
798 void set_parent_resource_id(const std::string& parent_resource_id) { | 797 void set_parent_resource_id(const std::string& parent_resource_id) { |
799 parent_resource_id_ = parent_resource_id; | 798 parent_resource_id_ = parent_resource_id; |
800 } | 799 } |
801 const std::string& title() const { return title_; } | 800 const std::string& title() const { return title_; } |
802 void set_title(const std::string& title) { title_ = title; } | 801 void set_title(const std::string& title) { title_ = title; } |
803 const base::Time& modified_date() const { return modified_date_; } | 802 const base::Time& modified_date() const { return modified_date_; } |
804 void set_modified_date(const base::Time& modified_date) { | 803 void set_modified_date(const base::Time& modified_date) { |
805 modified_date_ = modified_date; | 804 modified_date_ = modified_date; |
806 } | 805 } |
807 const base::Time& last_viewed_by_me_date() const { | 806 const base::Time& last_viewed_by_me_date() const { |
808 return last_viewed_by_me_date_; | 807 return last_viewed_by_me_date_; |
809 } | 808 } |
810 void set_last_viewed_by_me_date(const base::Time& last_viewed_by_me_date) { | 809 void set_last_viewed_by_me_date(const base::Time& last_viewed_by_me_date) { |
811 last_viewed_by_me_date_ = last_viewed_by_me_date; | 810 last_viewed_by_me_date_ = last_viewed_by_me_date; |
812 } | 811 } |
813 | 812 |
814 protected: | 813 protected: |
815 // UrlFetchRequestBase overrides. | 814 // UrlFetchRequestBase overrides. |
816 virtual GURL GetURL() const override; | 815 GURL GetURL() const override; |
817 virtual net::URLFetcher::RequestType GetRequestType() const override; | 816 net::URLFetcher::RequestType GetRequestType() const override; |
818 virtual std::vector<std::string> GetExtraRequestHeaders() const override; | 817 std::vector<std::string> GetExtraRequestHeaders() const override; |
819 virtual bool GetContentData(std::string* upload_content_type, | 818 bool GetContentData(std::string* upload_content_type, |
820 std::string* upload_content) override; | 819 std::string* upload_content) override; |
821 | 820 |
822 private: | 821 private: |
823 const DriveApiUrlGenerator url_generator_; | 822 const DriveApiUrlGenerator url_generator_; |
824 const std::string resource_id_; | 823 const std::string resource_id_; |
825 const std::string etag_; | 824 const std::string etag_; |
826 | 825 |
827 std::string parent_resource_id_; | 826 std::string parent_resource_id_; |
828 std::string title_; | 827 std::string title_; |
829 base::Time modified_date_; | 828 base::Time modified_date_; |
830 base::Time last_viewed_by_me_date_; | 829 base::Time last_viewed_by_me_date_; |
(...skipping 15 matching lines...) Expand all Loading... |
846 // |callback| must not be null. |progress_callback| may be null. | 845 // |callback| must not be null. |progress_callback| may be null. |
847 ResumeUploadRequest(RequestSender* sender, | 846 ResumeUploadRequest(RequestSender* sender, |
848 const GURL& upload_location, | 847 const GURL& upload_location, |
849 int64 start_position, | 848 int64 start_position, |
850 int64 end_position, | 849 int64 end_position, |
851 int64 content_length, | 850 int64 content_length, |
852 const std::string& content_type, | 851 const std::string& content_type, |
853 const base::FilePath& local_file_path, | 852 const base::FilePath& local_file_path, |
854 const UploadRangeCallback& callback, | 853 const UploadRangeCallback& callback, |
855 const ProgressCallback& progress_callback); | 854 const ProgressCallback& progress_callback); |
856 virtual ~ResumeUploadRequest(); | 855 ~ResumeUploadRequest() override; |
857 | 856 |
858 protected: | 857 protected: |
859 // UploadRangeRequestBase overrides. | 858 // UploadRangeRequestBase overrides. |
860 virtual void OnRangeRequestComplete( | 859 void OnRangeRequestComplete(const UploadRangeResponse& response, |
861 const UploadRangeResponse& response, | 860 scoped_ptr<base::Value> value) override; |
862 scoped_ptr<base::Value> value) override; | |
863 // content::UrlFetcherDelegate overrides. | 861 // content::UrlFetcherDelegate overrides. |
864 virtual void OnURLFetchUploadProgress(const net::URLFetcher* source, | 862 void OnURLFetchUploadProgress(const net::URLFetcher* source, |
865 int64 current, int64 total) override; | 863 int64 current, |
| 864 int64 total) override; |
866 | 865 |
867 private: | 866 private: |
868 const UploadRangeCallback callback_; | 867 const UploadRangeCallback callback_; |
869 const ProgressCallback progress_callback_; | 868 const ProgressCallback progress_callback_; |
870 | 869 |
871 DISALLOW_COPY_AND_ASSIGN(ResumeUploadRequest); | 870 DISALLOW_COPY_AND_ASSIGN(ResumeUploadRequest); |
872 }; | 871 }; |
873 | 872 |
874 //========================== GetUploadStatusRequest ========================== | 873 //========================== GetUploadStatusRequest ========================== |
875 | 874 |
876 // Performs the request to fetch the current upload status of a file. | 875 // Performs the request to fetch the current upload status of a file. |
877 class GetUploadStatusRequest : public GetUploadStatusRequestBase { | 876 class GetUploadStatusRequest : public GetUploadStatusRequestBase { |
878 public: | 877 public: |
879 // See also GetUploadStatusRequestBase's comment for parameters meaning. | 878 // See also GetUploadStatusRequestBase's comment for parameters meaning. |
880 // |callback| must not be null. | 879 // |callback| must not be null. |
881 GetUploadStatusRequest(RequestSender* sender, | 880 GetUploadStatusRequest(RequestSender* sender, |
882 const GURL& upload_url, | 881 const GURL& upload_url, |
883 int64 content_length, | 882 int64 content_length, |
884 const UploadRangeCallback& callback); | 883 const UploadRangeCallback& callback); |
885 virtual ~GetUploadStatusRequest(); | 884 ~GetUploadStatusRequest() override; |
886 | 885 |
887 protected: | 886 protected: |
888 // UploadRangeRequestBase overrides. | 887 // UploadRangeRequestBase overrides. |
889 virtual void OnRangeRequestComplete( | 888 void OnRangeRequestComplete(const UploadRangeResponse& response, |
890 const UploadRangeResponse& response, | 889 scoped_ptr<base::Value> value) override; |
891 scoped_ptr<base::Value> value) override; | |
892 | 890 |
893 private: | 891 private: |
894 const UploadRangeCallback callback_; | 892 const UploadRangeCallback callback_; |
895 | 893 |
896 DISALLOW_COPY_AND_ASSIGN(GetUploadStatusRequest); | 894 DISALLOW_COPY_AND_ASSIGN(GetUploadStatusRequest); |
897 }; | 895 }; |
898 | 896 |
899 //========================== DownloadFileRequest ========================== | 897 //========================== DownloadFileRequest ========================== |
900 | 898 |
901 // This class performs the request for downloading of a specified file. | 899 // This class performs the request for downloading of a specified file. |
902 class DownloadFileRequest : public DownloadFileRequestBase { | 900 class DownloadFileRequest : public DownloadFileRequestBase { |
903 public: | 901 public: |
904 // See also DownloadFileRequestBase's comment for parameters meaning. | 902 // See also DownloadFileRequestBase's comment for parameters meaning. |
905 DownloadFileRequest(RequestSender* sender, | 903 DownloadFileRequest(RequestSender* sender, |
906 const DriveApiUrlGenerator& url_generator, | 904 const DriveApiUrlGenerator& url_generator, |
907 const std::string& resource_id, | 905 const std::string& resource_id, |
908 const base::FilePath& output_file_path, | 906 const base::FilePath& output_file_path, |
909 const DownloadActionCallback& download_action_callback, | 907 const DownloadActionCallback& download_action_callback, |
910 const GetContentCallback& get_content_callback, | 908 const GetContentCallback& get_content_callback, |
911 const ProgressCallback& progress_callback); | 909 const ProgressCallback& progress_callback); |
912 virtual ~DownloadFileRequest(); | 910 ~DownloadFileRequest() override; |
913 | 911 |
914 DISALLOW_COPY_AND_ASSIGN(DownloadFileRequest); | 912 DISALLOW_COPY_AND_ASSIGN(DownloadFileRequest); |
915 }; | 913 }; |
916 | 914 |
917 //========================== PermissionsInsertRequest ========================== | 915 //========================== PermissionsInsertRequest ========================== |
918 | 916 |
919 // Enumeration type for specifying type of permissions. | 917 // Enumeration type for specifying type of permissions. |
920 enum PermissionType { | 918 enum PermissionType { |
921 PERMISSION_TYPE_ANYONE, | 919 PERMISSION_TYPE_ANYONE, |
922 PERMISSION_TYPE_DOMAIN, | 920 PERMISSION_TYPE_DOMAIN, |
923 PERMISSION_TYPE_GROUP, | 921 PERMISSION_TYPE_GROUP, |
924 PERMISSION_TYPE_USER, | 922 PERMISSION_TYPE_USER, |
925 }; | 923 }; |
926 | 924 |
927 // Enumeration type for specifying the role of permissions. | 925 // Enumeration type for specifying the role of permissions. |
928 enum PermissionRole { | 926 enum PermissionRole { |
929 PERMISSION_ROLE_OWNER, | 927 PERMISSION_ROLE_OWNER, |
930 PERMISSION_ROLE_READER, | 928 PERMISSION_ROLE_READER, |
931 PERMISSION_ROLE_WRITER, | 929 PERMISSION_ROLE_WRITER, |
932 PERMISSION_ROLE_COMMENTER, | 930 PERMISSION_ROLE_COMMENTER, |
933 }; | 931 }; |
934 | 932 |
935 // This class performs the request for adding permission on a specified file. | 933 // This class performs the request for adding permission on a specified file. |
936 class PermissionsInsertRequest : public EntryActionRequest { | 934 class PermissionsInsertRequest : public EntryActionRequest { |
937 public: | 935 public: |
938 // See https://developers.google.com/drive/v2/reference/permissions/insert. | 936 // See https://developers.google.com/drive/v2/reference/permissions/insert. |
939 PermissionsInsertRequest(RequestSender* sender, | 937 PermissionsInsertRequest(RequestSender* sender, |
940 const DriveApiUrlGenerator& url_generator, | 938 const DriveApiUrlGenerator& url_generator, |
941 const EntryActionCallback& callback); | 939 const EntryActionCallback& callback); |
942 virtual ~PermissionsInsertRequest(); | 940 ~PermissionsInsertRequest() override; |
943 | 941 |
944 void set_id(const std::string& id) { id_ = id; } | 942 void set_id(const std::string& id) { id_ = id; } |
945 void set_type(PermissionType type) { type_ = type; } | 943 void set_type(PermissionType type) { type_ = type; } |
946 void set_role(PermissionRole role) { role_ = role; } | 944 void set_role(PermissionRole role) { role_ = role; } |
947 void set_value(const std::string& value) { value_ = value; } | 945 void set_value(const std::string& value) { value_ = value; } |
948 | 946 |
949 // UrlFetchRequestBase overrides. | 947 // UrlFetchRequestBase overrides. |
950 virtual GURL GetURL() const override; | 948 GURL GetURL() const override; |
951 virtual net::URLFetcher::RequestType GetRequestType() const override; | 949 net::URLFetcher::RequestType GetRequestType() const override; |
952 virtual bool GetContentData(std::string* upload_content_type, | 950 bool GetContentData(std::string* upload_content_type, |
953 std::string* upload_content) override; | 951 std::string* upload_content) override; |
954 | 952 |
955 private: | 953 private: |
956 const DriveApiUrlGenerator url_generator_; | 954 const DriveApiUrlGenerator url_generator_; |
957 std::string id_; | 955 std::string id_; |
958 PermissionType type_; | 956 PermissionType type_; |
959 PermissionRole role_; | 957 PermissionRole role_; |
960 std::string value_; | 958 std::string value_; |
961 | 959 |
962 DISALLOW_COPY_AND_ASSIGN(PermissionsInsertRequest); | 960 DISALLOW_COPY_AND_ASSIGN(PermissionsInsertRequest); |
963 }; | 961 }; |
964 | 962 |
965 } // namespace drive | 963 } // namespace drive |
966 } // namespace google_apis | 964 } // namespace google_apis |
967 | 965 |
968 #endif // GOOGLE_APIS_DRIVE_DRIVE_API_REQUESTS_H_ | 966 #endif // GOOGLE_APIS_DRIVE_DRIVE_API_REQUESTS_H_ |
OLD | NEW |