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 CHROME_BROWSER_GOOGLE_APIS_GDATA_WAPI_OPERATIONS_H_ | 5 #ifndef CHROME_BROWSER_GOOGLE_APIS_GDATA_WAPI_OPERATIONS_H_ |
6 #define CHROME_BROWSER_GOOGLE_APIS_GDATA_WAPI_OPERATIONS_H_ | 6 #define CHROME_BROWSER_GOOGLE_APIS_GDATA_WAPI_OPERATIONS_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 | 506 |
507 // Struct for passing params needed for DriveServiceInterface::ResumeUpload() | 507 // Struct for passing params needed for DriveServiceInterface::ResumeUpload() |
508 // calls. | 508 // calls. |
509 struct ResumeUploadParams { | 509 struct ResumeUploadParams { |
510 ResumeUploadParams(UploadMode upload_mode, | 510 ResumeUploadParams(UploadMode upload_mode, |
511 int64 start_position, | 511 int64 start_position, |
512 int64 end_position, | 512 int64 end_position, |
513 int64 content_length, | 513 int64 content_length, |
514 const std::string& content_type, | 514 const std::string& content_type, |
515 scoped_refptr<net::IOBuffer> buf, | 515 scoped_refptr<net::IOBuffer> buf, |
| 516 const int64 buffer_offset, |
516 const GURL& upload_location, | 517 const GURL& upload_location, |
517 const FilePath& drive_file_path); | 518 const FilePath& drive_file_path); |
518 ~ResumeUploadParams(); | 519 ~ResumeUploadParams(); |
519 | 520 |
520 const UploadMode upload_mode; // Mode of the upload. | 521 const UploadMode upload_mode; // Mode of the upload. |
521 // Start of range of contents currently stored in |buf|. | 522 // Start of range of contents currently stored in |buf|. |
522 const int64 start_position; | 523 const int64 start_position; |
523 // End of range of contents currently stored in |buf|. This is exclusive. | 524 // End of range of contents currently stored in |buf|. This is exclusive. |
524 // For instance, if you are to upload the first 500 bytes of data, | 525 // For instance, if you are to upload the first 500 bytes of data, |
525 // |start_position| is 0 and |end_position| is 500. | 526 // |start_position| is 0 and |end_position| is 500. |
526 const int64 end_position; | 527 const int64 end_position; |
527 const int64 content_length; // File content-Length. | 528 const int64 content_length; // File content-Length. |
528 const std::string content_type; // Content-Type of file. | 529 const std::string content_type; // Content-Type of file. |
529 // Holds current content to be uploaded. | 530 // Holds current content to be uploaded. |
530 const scoped_refptr<net::IOBuffer> buf; | 531 const scoped_refptr<net::IOBuffer> buf; |
| 532 const int64 buffer_offset; |
531 const GURL upload_location; // Url of where to upload the file to. | 533 const GURL upload_location; // Url of where to upload the file to. |
532 // Drive file path of the file seen in the UI. Not necessary for | 534 // Drive file path of the file seen in the UI. Not necessary for |
533 // resuming an upload, but used for adding an entry to OperationRegistry. | 535 // resuming an upload, but used for adding an entry to OperationRegistry. |
534 // TODO(satorux): Remove the drive file path hack. crbug.com/163296 | 536 // TODO(satorux): Remove the drive file path hack. crbug.com/163296 |
535 const FilePath drive_file_path; | 537 const FilePath drive_file_path; |
536 }; | 538 }; |
537 | 539 |
538 // Callback type for DocumentServiceInterface::ResumeUpload. | 540 // Callback type for DocumentServiceInterface::ResumeUpload. |
539 typedef base::Callback<void( | 541 typedef base::Callback<void( |
540 const ResumeUploadResponse& response, | 542 const ResumeUploadResponse& response, |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
584 const ResumeUploadCallback callback_; | 586 const ResumeUploadCallback callback_; |
585 const ResumeUploadParams params_; | 587 const ResumeUploadParams params_; |
586 bool last_chunk_completed_; | 588 bool last_chunk_completed_; |
587 | 589 |
588 // Note: This should remain the last member so it'll be destroyed and | 590 // Note: This should remain the last member so it'll be destroyed and |
589 // invalidate its weak pointers before any other members are destroyed. | 591 // invalidate its weak pointers before any other members are destroyed. |
590 base::WeakPtrFactory<ResumeUploadOperation> weak_ptr_factory_; | 592 base::WeakPtrFactory<ResumeUploadOperation> weak_ptr_factory_; |
591 DISALLOW_COPY_AND_ASSIGN(ResumeUploadOperation); | 593 DISALLOW_COPY_AND_ASSIGN(ResumeUploadOperation); |
592 }; | 594 }; |
593 | 595 |
| 596 class GetUploadStateOperation : public UrlFetchOperationBase { |
| 597 public: |
| 598 GetUploadStateOperation( |
| 599 OperationRegistry* registry, |
| 600 net::URLRequestContextGetter* url_request_context_getter, |
| 601 const ResumeUploadCallback& callback, |
| 602 UploadMode upload_mode, |
| 603 const FilePath& drive_file_path, |
| 604 const GURL& upload_url, |
| 605 int64 content_length); |
| 606 virtual ~GetUploadStateOperation(); |
| 607 |
| 608 protected: |
| 609 virtual GURL GetURL() const OVERRIDE; |
| 610 virtual net::URLFetcher::RequestType GetRequestType() const OVERRIDE; |
| 611 virtual void ProcessURLFetchResults(const net::URLFetcher* source) OVERRIDE; |
| 612 virtual void RunCallbackOnPrematureFailure(GDataErrorCode code) OVERRIDE; |
| 613 virtual std::vector<std::string> GetExtraRequestHeaders() const OVERRIDE; |
| 614 |
| 615 private: |
| 616 // Called when ParseJson() is completed. |
| 617 void OnDataParsed(GDataErrorCode code, scoped_ptr<base::Value> value); |
| 618 |
| 619 const ResumeUploadCallback callback_; |
| 620 const UploadMode upload_mode_; |
| 621 const FilePath drive_file_path_; |
| 622 const GURL upload_url_; |
| 623 const int64 content_length_; |
| 624 |
| 625 // Note: This should remain the last member so it'll be destroyed and |
| 626 // invalidate its weak pointers before any other members are destroyed. |
| 627 base::WeakPtrFactory<GetUploadStateOperation> weak_ptr_factory_; |
| 628 DISALLOW_COPY_AND_ASSIGN(GetUploadStateOperation); |
| 629 }; |
| 630 |
594 } // namespace google_apis | 631 } // namespace google_apis |
595 | 632 |
596 #endif // CHROME_BROWSER_GOOGLE_APIS_GDATA_WAPI_OPERATIONS_H_ | 633 #endif // CHROME_BROWSER_GOOGLE_APIS_GDATA_WAPI_OPERATIONS_H_ |
OLD | NEW |