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 // This file provides base classes used to issue HTTP requests for Google | 5 // This file provides base classes used to issue HTTP requests for Google |
6 // APIs. | 6 // APIs. |
7 | 7 |
8 #ifndef GOOGLE_APIS_DRIVE_BASE_REQUESTS_H_ | 8 #ifndef GOOGLE_APIS_DRIVE_BASE_REQUESTS_H_ |
9 #define GOOGLE_APIS_DRIVE_BASE_REQUESTS_H_ | 9 #define GOOGLE_APIS_DRIVE_BASE_REQUESTS_H_ |
10 | 10 |
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 class MultipartUploadRequestBase : public UrlFetchRequestBase { | 442 class MultipartUploadRequestBase : public UrlFetchRequestBase { |
443 public: | 443 public: |
444 // Set boundary. Only tests can use this method. | 444 // Set boundary. Only tests can use this method. |
445 void SetBoundaryForTesting(const std::string& boundary); | 445 void SetBoundaryForTesting(const std::string& boundary); |
446 | 446 |
447 protected: | 447 protected: |
448 // |callback| will be called with the file resource.upload URL. | 448 // |callback| will be called with the file resource.upload URL. |
449 // |content_type| and |content_length| should be the attributes of the | 449 // |content_type| and |content_length| should be the attributes of the |
450 // uploading file. Other parameters are optional and can be empty or null | 450 // uploading file. Other parameters are optional and can be empty or null |
451 // depending on Upload URL provided by the subclasses. | 451 // depending on Upload URL provided by the subclasses. |
452 MultipartUploadRequestBase( | 452 MultipartUploadRequestBase(RequestSender* sender, |
453 RequestSender* sender, | 453 const std::string& metadata_json, |
454 const std::string& title, | 454 const std::string& content_type, |
455 const std::string& parent_resource_id, | 455 int64 content_length, |
456 const std::string& content_type, | 456 const base::FilePath& local_file_path, |
457 int64 content_length, | 457 const FileResourceCallback& callback, |
458 const base::Time& modified_date, | 458 const ProgressCallback& progress_callback); |
459 const base::Time& last_viewed_by_me_date, | |
460 const base::FilePath& local_file_path, | |
461 const FileResourceCallback& callback, | |
462 const google_apis::ProgressCallback& progress_callback); | |
463 ~MultipartUploadRequestBase() override; | 459 ~MultipartUploadRequestBase() override; |
464 | 460 |
465 // Overridden from AuthenticatedRequestInterface. | 461 // Overridden from AuthenticatedRequestInterface. |
466 void Start(const std::string& access_token, | 462 void Start(const std::string& access_token, |
467 const std::string& custom_user_agent, | 463 const std::string& custom_user_agent, |
468 const ReAuthenticateCallback& callback) override; | 464 const ReAuthenticateCallback& callback) override; |
469 | 465 |
470 // Overridden from UrlFetchRequestBase. | 466 // Overridden from UrlFetchRequestBase. |
471 bool GetContentData(std::string* upload_content_type, | 467 bool GetContentData(std::string* upload_content_type, |
472 std::string* upload_content) override; | 468 std::string* upload_content) override; |
473 void ProcessURLFetchResults(const net::URLFetcher* source) override; | 469 void ProcessURLFetchResults(const net::URLFetcher* source) override; |
474 void RunCallbackOnPrematureFailure(DriveApiErrorCode code) override; | 470 void RunCallbackOnPrematureFailure(DriveApiErrorCode code) override; |
475 | 471 |
476 // content::UrlFetcherDelegate overrides. | 472 // content::UrlFetcherDelegate overrides. |
477 void OnURLFetchUploadProgress(const net::URLFetcher* source, | 473 void OnURLFetchUploadProgress(const net::URLFetcher* source, |
478 int64 current, | 474 int64 current, |
479 int64 total) override; | 475 int64 total) override; |
480 | 476 |
481 // Parses the response value and invokes |callback_| with |FileResource|. | 477 // Parses the response value and invokes |callback_| with |FileResource|. |
482 void OnDataParsed(DriveApiErrorCode code, scoped_ptr<base::Value> value); | 478 void OnDataParsed(DriveApiErrorCode code, scoped_ptr<base::Value> value); |
483 | 479 |
484 // Whether to the request has modified date information or not. | |
485 bool has_modified_date() const { return has_modified_date_; } | |
486 | |
487 private: | 480 private: |
488 // Continues to rest part of |Start| method after determining boundary string | 481 // Continues to rest part of |Start| method after determining boundary string |
489 // of multipart/related. | 482 // of multipart/related. |
490 void OnPrepareUploadContent(const std::string& access_token, | 483 void OnPrepareUploadContent(const std::string& access_token, |
491 const std::string& custom_user_agent, | 484 const std::string& custom_user_agent, |
492 const ReAuthenticateCallback& callback, | 485 const ReAuthenticateCallback& callback, |
493 std::string* upload_content_type, | 486 std::string* upload_content_type, |
494 std::string* upload_content_data, | 487 std::string* upload_content_data, |
495 bool result); | 488 bool result); |
496 | 489 |
497 const std::string metadata_json_; | 490 const std::string metadata_json_; |
498 const std::string content_type_; | 491 const std::string content_type_; |
499 const base::FilePath local_path_; | 492 const base::FilePath local_path_; |
500 const bool has_modified_date_; | |
501 const FileResourceCallback callback_; | 493 const FileResourceCallback callback_; |
502 const ProgressCallback progress_callback_; | 494 const ProgressCallback progress_callback_; |
503 | 495 |
504 // Boundary of multipart body. | 496 // Boundary of multipart body. |
505 std::string boundary_; | 497 std::string boundary_; |
506 | 498 |
507 // Upload content of multipart body. | 499 // Upload content of multipart body. |
508 std::string upload_content_type_; | 500 std::string upload_content_type_; |
509 std::string upload_content_data_; | 501 std::string upload_content_data_; |
510 | 502 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
570 const ProgressCallback progress_callback_; | 562 const ProgressCallback progress_callback_; |
571 const GURL download_url_; | 563 const GURL download_url_; |
572 const base::FilePath output_file_path_; | 564 const base::FilePath output_file_path_; |
573 | 565 |
574 DISALLOW_COPY_AND_ASSIGN(DownloadFileRequestBase); | 566 DISALLOW_COPY_AND_ASSIGN(DownloadFileRequestBase); |
575 }; | 567 }; |
576 | 568 |
577 } // namespace google_apis | 569 } // namespace google_apis |
578 | 570 |
579 #endif // GOOGLE_APIS_DRIVE_BASE_REQUESTS_H_ | 571 #endif // GOOGLE_APIS_DRIVE_BASE_REQUESTS_H_ |
OLD | NEW |