| 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/drive/drive_api_service.h" | 5 #include "chrome/browser/drive/drive_api_service.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 DCHECK(!download_action_callback.is_null()); | 447 DCHECK(!download_action_callback.is_null()); |
| 448 // get_content_callback may be null. | 448 // get_content_callback may be null. |
| 449 | 449 |
| 450 return sender_->StartRequestWithRetry( | 450 return sender_->StartRequestWithRetry( |
| 451 new DownloadFileRequest(sender_.get(), | 451 new DownloadFileRequest(sender_.get(), |
| 452 url_request_context_getter_, | 452 url_request_context_getter_, |
| 453 download_action_callback, | 453 download_action_callback, |
| 454 get_content_callback, | 454 get_content_callback, |
| 455 progress_callback, | 455 progress_callback, |
| 456 download_url, | 456 download_url, |
| 457 virtual_path, | |
| 458 local_cache_path)); | 457 local_cache_path)); |
| 459 } | 458 } |
| 460 | 459 |
| 461 CancelCallback DriveAPIService::DeleteResource( | 460 CancelCallback DriveAPIService::DeleteResource( |
| 462 const std::string& resource_id, | 461 const std::string& resource_id, |
| 463 const std::string& etag, | 462 const std::string& etag, |
| 464 const EntryActionCallback& callback) { | 463 const EntryActionCallback& callback) { |
| 465 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 464 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 466 DCHECK(!callback.is_null()); | 465 DCHECK(!callback.is_null()); |
| 467 | 466 |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 const std::string& title, | 606 const std::string& title, |
| 608 const InitiateUploadCallback& callback) { | 607 const InitiateUploadCallback& callback) { |
| 609 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 608 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 610 DCHECK(!callback.is_null()); | 609 DCHECK(!callback.is_null()); |
| 611 | 610 |
| 612 return sender_->StartRequestWithRetry( | 611 return sender_->StartRequestWithRetry( |
| 613 new drive::InitiateUploadNewFileRequest( | 612 new drive::InitiateUploadNewFileRequest( |
| 614 sender_.get(), | 613 sender_.get(), |
| 615 url_request_context_getter_, | 614 url_request_context_getter_, |
| 616 url_generator_, | 615 url_generator_, |
| 617 drive_file_path, | |
| 618 content_type, | 616 content_type, |
| 619 content_length, | 617 content_length, |
| 620 parent_resource_id, | 618 parent_resource_id, |
| 621 title, | 619 title, |
| 622 callback)); | 620 callback)); |
| 623 } | 621 } |
| 624 | 622 |
| 625 CancelCallback DriveAPIService::InitiateUploadExistingFile( | 623 CancelCallback DriveAPIService::InitiateUploadExistingFile( |
| 626 const base::FilePath& drive_file_path, | 624 const base::FilePath& drive_file_path, |
| 627 const std::string& content_type, | 625 const std::string& content_type, |
| 628 int64 content_length, | 626 int64 content_length, |
| 629 const std::string& resource_id, | 627 const std::string& resource_id, |
| 630 const std::string& etag, | 628 const std::string& etag, |
| 631 const InitiateUploadCallback& callback) { | 629 const InitiateUploadCallback& callback) { |
| 632 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 630 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 633 DCHECK(!callback.is_null()); | 631 DCHECK(!callback.is_null()); |
| 634 | 632 |
| 635 return sender_->StartRequestWithRetry( | 633 return sender_->StartRequestWithRetry( |
| 636 new drive::InitiateUploadExistingFileRequest( | 634 new drive::InitiateUploadExistingFileRequest( |
| 637 sender_.get(), | 635 sender_.get(), |
| 638 url_request_context_getter_, | 636 url_request_context_getter_, |
| 639 url_generator_, | 637 url_generator_, |
| 640 drive_file_path, | |
| 641 content_type, | 638 content_type, |
| 642 content_length, | 639 content_length, |
| 643 resource_id, | 640 resource_id, |
| 644 etag, | 641 etag, |
| 645 callback)); | 642 callback)); |
| 646 } | 643 } |
| 647 | 644 |
| 648 CancelCallback DriveAPIService::ResumeUpload( | 645 CancelCallback DriveAPIService::ResumeUpload( |
| 649 const base::FilePath& drive_file_path, | 646 const base::FilePath& drive_file_path, |
| 650 const GURL& upload_url, | 647 const GURL& upload_url, |
| 651 int64 start_position, | 648 int64 start_position, |
| 652 int64 end_position, | 649 int64 end_position, |
| 653 int64 content_length, | 650 int64 content_length, |
| 654 const std::string& content_type, | 651 const std::string& content_type, |
| 655 const base::FilePath& local_file_path, | 652 const base::FilePath& local_file_path, |
| 656 const UploadRangeCallback& callback, | 653 const UploadRangeCallback& callback, |
| 657 const ProgressCallback& progress_callback) { | 654 const ProgressCallback& progress_callback) { |
| 658 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 655 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 659 DCHECK(!callback.is_null()); | 656 DCHECK(!callback.is_null()); |
| 660 | 657 |
| 661 return sender_->StartRequestWithRetry( | 658 return sender_->StartRequestWithRetry( |
| 662 new drive::ResumeUploadRequest( | 659 new drive::ResumeUploadRequest( |
| 663 sender_.get(), | 660 sender_.get(), |
| 664 url_request_context_getter_, | 661 url_request_context_getter_, |
| 665 drive_file_path, | |
| 666 upload_url, | 662 upload_url, |
| 667 start_position, | 663 start_position, |
| 668 end_position, | 664 end_position, |
| 669 content_length, | 665 content_length, |
| 670 content_type, | 666 content_type, |
| 671 local_file_path, | 667 local_file_path, |
| 672 base::Bind(&ParseResourceEntryForUploadRangeAndRun, callback), | 668 base::Bind(&ParseResourceEntryForUploadRangeAndRun, callback), |
| 673 progress_callback)); | 669 progress_callback)); |
| 674 } | 670 } |
| 675 | 671 |
| 676 CancelCallback DriveAPIService::GetUploadStatus( | 672 CancelCallback DriveAPIService::GetUploadStatus( |
| 677 const base::FilePath& drive_file_path, | 673 const base::FilePath& drive_file_path, |
| 678 const GURL& upload_url, | 674 const GURL& upload_url, |
| 679 int64 content_length, | 675 int64 content_length, |
| 680 const UploadRangeCallback& callback) { | 676 const UploadRangeCallback& callback) { |
| 681 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 677 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 682 DCHECK(!callback.is_null()); | 678 DCHECK(!callback.is_null()); |
| 683 | 679 |
| 684 return sender_->StartRequestWithRetry(new drive::GetUploadStatusRequest( | 680 return sender_->StartRequestWithRetry(new drive::GetUploadStatusRequest( |
| 685 sender_.get(), | 681 sender_.get(), |
| 686 url_request_context_getter_, | 682 url_request_context_getter_, |
| 687 drive_file_path, | |
| 688 upload_url, | 683 upload_url, |
| 689 content_length, | 684 content_length, |
| 690 base::Bind(&ParseResourceEntryForUploadRangeAndRun, callback))); | 685 base::Bind(&ParseResourceEntryForUploadRangeAndRun, callback))); |
| 691 } | 686 } |
| 692 | 687 |
| 693 CancelCallback DriveAPIService::AuthorizeApp( | 688 CancelCallback DriveAPIService::AuthorizeApp( |
| 694 const std::string& resource_id, | 689 const std::string& resource_id, |
| 695 const std::string& app_id, | 690 const std::string& app_id, |
| 696 const AuthorizeAppCallback& callback) { | 691 const AuthorizeAppCallback& callback) { |
| 697 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 692 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 732 if (CanSendRequest()) { | 727 if (CanSendRequest()) { |
| 733 FOR_EACH_OBSERVER( | 728 FOR_EACH_OBSERVER( |
| 734 DriveServiceObserver, observers_, OnReadyToSendRequests()); | 729 DriveServiceObserver, observers_, OnReadyToSendRequests()); |
| 735 } else if (!HasRefreshToken()) { | 730 } else if (!HasRefreshToken()) { |
| 736 FOR_EACH_OBSERVER( | 731 FOR_EACH_OBSERVER( |
| 737 DriveServiceObserver, observers_, OnRefreshTokenInvalid()); | 732 DriveServiceObserver, observers_, OnRefreshTokenInvalid()); |
| 738 } | 733 } |
| 739 } | 734 } |
| 740 | 735 |
| 741 } // namespace google_apis | 736 } // namespace google_apis |
| OLD | NEW |