| 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 #include "chrome/browser/google_apis/drive_api_requests.h" | 5 #include "chrome/browser/google_apis/drive_api_requests.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 net::URLFetcher::RequestType DeleteResourceRequest::GetRequestType() const { | 491 net::URLFetcher::RequestType DeleteResourceRequest::GetRequestType() const { |
| 492 return net::URLFetcher::DELETE_REQUEST; | 492 return net::URLFetcher::DELETE_REQUEST; |
| 493 } | 493 } |
| 494 | 494 |
| 495 //======================= InitiateUploadNewFileRequest ======================= | 495 //======================= InitiateUploadNewFileRequest ======================= |
| 496 | 496 |
| 497 InitiateUploadNewFileRequest::InitiateUploadNewFileRequest( | 497 InitiateUploadNewFileRequest::InitiateUploadNewFileRequest( |
| 498 RequestSender* runner, | 498 RequestSender* runner, |
| 499 net::URLRequestContextGetter* url_request_context_getter, | 499 net::URLRequestContextGetter* url_request_context_getter, |
| 500 const DriveApiUrlGenerator& url_generator, | 500 const DriveApiUrlGenerator& url_generator, |
| 501 const base::FilePath& drive_file_path, | |
| 502 const std::string& content_type, | 501 const std::string& content_type, |
| 503 int64 content_length, | 502 int64 content_length, |
| 504 const std::string& parent_resource_id, | 503 const std::string& parent_resource_id, |
| 505 const std::string& title, | 504 const std::string& title, |
| 506 const InitiateUploadCallback& callback) | 505 const InitiateUploadCallback& callback) |
| 507 : InitiateUploadRequestBase(runner, | 506 : InitiateUploadRequestBase(runner, |
| 508 url_request_context_getter, | 507 url_request_context_getter, |
| 509 callback, | 508 callback, |
| 510 drive_file_path, | |
| 511 content_type, | 509 content_type, |
| 512 content_length), | 510 content_length), |
| 513 url_generator_(url_generator), | 511 url_generator_(url_generator), |
| 514 parent_resource_id_(parent_resource_id), | 512 parent_resource_id_(parent_resource_id), |
| 515 title_(title) { | 513 title_(title) { |
| 516 } | 514 } |
| 517 | 515 |
| 518 InitiateUploadNewFileRequest::~InitiateUploadNewFileRequest() {} | 516 InitiateUploadNewFileRequest::~InitiateUploadNewFileRequest() {} |
| 519 | 517 |
| 520 GURL InitiateUploadNewFileRequest::GetURL() const { | 518 GURL InitiateUploadNewFileRequest::GetURL() const { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 << *upload_content << "]"; | 550 << *upload_content << "]"; |
| 553 return true; | 551 return true; |
| 554 } | 552 } |
| 555 | 553 |
| 556 //===================== InitiateUploadExistingFileRequest ==================== | 554 //===================== InitiateUploadExistingFileRequest ==================== |
| 557 | 555 |
| 558 InitiateUploadExistingFileRequest::InitiateUploadExistingFileRequest( | 556 InitiateUploadExistingFileRequest::InitiateUploadExistingFileRequest( |
| 559 RequestSender* runner, | 557 RequestSender* runner, |
| 560 net::URLRequestContextGetter* url_request_context_getter, | 558 net::URLRequestContextGetter* url_request_context_getter, |
| 561 const DriveApiUrlGenerator& url_generator, | 559 const DriveApiUrlGenerator& url_generator, |
| 562 const base::FilePath& drive_file_path, | |
| 563 const std::string& content_type, | 560 const std::string& content_type, |
| 564 int64 content_length, | 561 int64 content_length, |
| 565 const std::string& resource_id, | 562 const std::string& resource_id, |
| 566 const std::string& etag, | 563 const std::string& etag, |
| 567 const InitiateUploadCallback& callback) | 564 const InitiateUploadCallback& callback) |
| 568 : InitiateUploadRequestBase(runner, | 565 : InitiateUploadRequestBase(runner, |
| 569 url_request_context_getter, | 566 url_request_context_getter, |
| 570 callback, | 567 callback, |
| 571 drive_file_path, | |
| 572 content_type, | 568 content_type, |
| 573 content_length), | 569 content_length), |
| 574 url_generator_(url_generator), | 570 url_generator_(url_generator), |
| 575 resource_id_(resource_id), | 571 resource_id_(resource_id), |
| 576 etag_(etag) { | 572 etag_(etag) { |
| 577 } | 573 } |
| 578 | 574 |
| 579 InitiateUploadExistingFileRequest::~InitiateUploadExistingFileRequest() {} | 575 InitiateUploadExistingFileRequest::~InitiateUploadExistingFileRequest() {} |
| 580 | 576 |
| 581 GURL InitiateUploadExistingFileRequest::GetURL() const { | 577 GURL InitiateUploadExistingFileRequest::GetURL() const { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 593 InitiateUploadRequestBase::GetExtraRequestHeaders()); | 589 InitiateUploadRequestBase::GetExtraRequestHeaders()); |
| 594 headers.push_back(util::GenerateIfMatchHeader(etag_)); | 590 headers.push_back(util::GenerateIfMatchHeader(etag_)); |
| 595 return headers; | 591 return headers; |
| 596 } | 592 } |
| 597 | 593 |
| 598 //============================ ResumeUploadRequest =========================== | 594 //============================ ResumeUploadRequest =========================== |
| 599 | 595 |
| 600 ResumeUploadRequest::ResumeUploadRequest( | 596 ResumeUploadRequest::ResumeUploadRequest( |
| 601 RequestSender* runner, | 597 RequestSender* runner, |
| 602 net::URLRequestContextGetter* url_request_context_getter, | 598 net::URLRequestContextGetter* url_request_context_getter, |
| 603 const base::FilePath& drive_file_path, | |
| 604 const GURL& upload_location, | 599 const GURL& upload_location, |
| 605 int64 start_position, | 600 int64 start_position, |
| 606 int64 end_position, | 601 int64 end_position, |
| 607 int64 content_length, | 602 int64 content_length, |
| 608 const std::string& content_type, | 603 const std::string& content_type, |
| 609 const base::FilePath& local_file_path, | 604 const base::FilePath& local_file_path, |
| 610 const UploadRangeCallback& callback, | 605 const UploadRangeCallback& callback, |
| 611 const ProgressCallback& progress_callback) | 606 const ProgressCallback& progress_callback) |
| 612 : ResumeUploadRequestBase(runner, | 607 : ResumeUploadRequestBase(runner, |
| 613 url_request_context_getter, | 608 url_request_context_getter, |
| 614 drive_file_path, | |
| 615 upload_location, | 609 upload_location, |
| 616 start_position, | 610 start_position, |
| 617 end_position, | 611 end_position, |
| 618 content_length, | 612 content_length, |
| 619 content_type, | 613 content_type, |
| 620 local_file_path), | 614 local_file_path), |
| 621 callback_(callback), | 615 callback_(callback), |
| 622 progress_callback_(progress_callback) { | 616 progress_callback_(progress_callback) { |
| 623 DCHECK(!callback_.is_null()); | 617 DCHECK(!callback_.is_null()); |
| 624 } | 618 } |
| 625 | 619 |
| 626 ResumeUploadRequest::~ResumeUploadRequest() {} | 620 ResumeUploadRequest::~ResumeUploadRequest() {} |
| 627 | 621 |
| 628 void ResumeUploadRequest::OnRangeRequestComplete( | 622 void ResumeUploadRequest::OnRangeRequestComplete( |
| 629 const UploadRangeResponse& response, scoped_ptr<base::Value> value) { | 623 const UploadRangeResponse& response, scoped_ptr<base::Value> value) { |
| 630 ParseFileResourceWithUploadRangeAndRun(callback_, response, value.Pass()); | 624 ParseFileResourceWithUploadRangeAndRun(callback_, response, value.Pass()); |
| 631 } | 625 } |
| 632 | 626 |
| 633 void ResumeUploadRequest::OnURLFetchUploadProgress( | 627 void ResumeUploadRequest::OnURLFetchUploadProgress( |
| 634 const net::URLFetcher* source, int64 current, int64 total) { | 628 const net::URLFetcher* source, int64 current, int64 total) { |
| 635 if (!progress_callback_.is_null()) | 629 if (!progress_callback_.is_null()) |
| 636 progress_callback_.Run(current, total); | 630 progress_callback_.Run(current, total); |
| 637 } | 631 } |
| 638 | 632 |
| 639 //========================== GetUploadStatusRequest ========================== | 633 //========================== GetUploadStatusRequest ========================== |
| 640 | 634 |
| 641 GetUploadStatusRequest::GetUploadStatusRequest( | 635 GetUploadStatusRequest::GetUploadStatusRequest( |
| 642 RequestSender* runner, | 636 RequestSender* runner, |
| 643 net::URLRequestContextGetter* url_request_context_getter, | 637 net::URLRequestContextGetter* url_request_context_getter, |
| 644 const base::FilePath& drive_file_path, | |
| 645 const GURL& upload_url, | 638 const GURL& upload_url, |
| 646 int64 content_length, | 639 int64 content_length, |
| 647 const UploadRangeCallback& callback) | 640 const UploadRangeCallback& callback) |
| 648 : GetUploadStatusRequestBase(runner, | 641 : GetUploadStatusRequestBase(runner, |
| 649 url_request_context_getter, | 642 url_request_context_getter, |
| 650 drive_file_path, | |
| 651 upload_url, | 643 upload_url, |
| 652 content_length), | 644 content_length), |
| 653 callback_(callback) { | 645 callback_(callback) { |
| 654 DCHECK(!callback.is_null()); | 646 DCHECK(!callback.is_null()); |
| 655 } | 647 } |
| 656 | 648 |
| 657 GetUploadStatusRequest::~GetUploadStatusRequest() {} | 649 GetUploadStatusRequest::~GetUploadStatusRequest() {} |
| 658 | 650 |
| 659 void GetUploadStatusRequest::OnRangeRequestComplete( | 651 void GetUploadStatusRequest::OnRangeRequestComplete( |
| 660 const UploadRangeResponse& response, scoped_ptr<base::Value> value) { | 652 const UploadRangeResponse& response, scoped_ptr<base::Value> value) { |
| 661 ParseFileResourceWithUploadRangeAndRun(callback_, response, value.Pass()); | 653 ParseFileResourceWithUploadRangeAndRun(callback_, response, value.Pass()); |
| 662 } | 654 } |
| 663 | 655 |
| 664 } // namespace drive | 656 } // namespace drive |
| 665 } // namespace google_apis | 657 } // namespace google_apis |
| OLD | NEW |