| 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 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 DCHECK(thread_checker_.CalledOnValidThread()); | 453 DCHECK(thread_checker_.CalledOnValidThread()); |
| 454 DCHECK(!callback.is_null()); | 454 DCHECK(!callback.is_null()); |
| 455 | 455 |
| 456 FilesInsertRequest* request = new FilesInsertRequest( | 456 FilesInsertRequest* request = new FilesInsertRequest( |
| 457 sender_.get(), url_generator_, callback); | 457 sender_.get(), url_generator_, callback); |
| 458 request->set_last_viewed_by_me_date(options.last_viewed_by_me_date); | 458 request->set_last_viewed_by_me_date(options.last_viewed_by_me_date); |
| 459 request->set_mime_type(kFolderMimeType); | 459 request->set_mime_type(kFolderMimeType); |
| 460 request->set_modified_date(options.modified_date); | 460 request->set_modified_date(options.modified_date); |
| 461 request->add_parent(parent_resource_id); | 461 request->add_parent(parent_resource_id); |
| 462 request->set_title(directory_title); | 462 request->set_title(directory_title); |
| 463 request->set_properties(options.properties); |
| 463 request->set_fields(kFileResourceFields); | 464 request->set_fields(kFileResourceFields); |
| 464 return sender_->StartRequestWithRetry(request); | 465 return sender_->StartRequestWithRetry(request); |
| 465 } | 466 } |
| 466 | 467 |
| 467 CancelCallback DriveAPIService::CopyResource( | 468 CancelCallback DriveAPIService::CopyResource( |
| 468 const std::string& resource_id, | 469 const std::string& resource_id, |
| 469 const std::string& parent_resource_id, | 470 const std::string& parent_resource_id, |
| 470 const std::string& new_title, | 471 const std::string& new_title, |
| 471 const base::Time& last_modified, | 472 const base::Time& last_modified, |
| 472 const FileResourceCallback& callback) { | 473 const FileResourceCallback& callback) { |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 557 InitiateUploadNewFileRequest* request = | 558 InitiateUploadNewFileRequest* request = |
| 558 new InitiateUploadNewFileRequest(sender_.get(), | 559 new InitiateUploadNewFileRequest(sender_.get(), |
| 559 url_generator_, | 560 url_generator_, |
| 560 content_type, | 561 content_type, |
| 561 content_length, | 562 content_length, |
| 562 parent_resource_id, | 563 parent_resource_id, |
| 563 title, | 564 title, |
| 564 callback); | 565 callback); |
| 565 request->set_modified_date(options.modified_date); | 566 request->set_modified_date(options.modified_date); |
| 566 request->set_last_viewed_by_me_date(options.last_viewed_by_me_date); | 567 request->set_last_viewed_by_me_date(options.last_viewed_by_me_date); |
| 568 request->set_properties(options.properties); |
| 567 return sender_->StartRequestWithRetry(request); | 569 return sender_->StartRequestWithRetry(request); |
| 568 } | 570 } |
| 569 | 571 |
| 570 CancelCallback DriveAPIService::InitiateUploadExistingFile( | 572 CancelCallback DriveAPIService::InitiateUploadExistingFile( |
| 571 const std::string& content_type, | 573 const std::string& content_type, |
| 572 int64 content_length, | 574 int64 content_length, |
| 573 const std::string& resource_id, | 575 const std::string& resource_id, |
| 574 const UploadExistingFileOptions& options, | 576 const UploadExistingFileOptions& options, |
| 575 const InitiateUploadCallback& callback) { | 577 const InitiateUploadCallback& callback) { |
| 576 DCHECK(thread_checker_.CalledOnValidThread()); | 578 DCHECK(thread_checker_.CalledOnValidThread()); |
| 577 DCHECK(!callback.is_null()); | 579 DCHECK(!callback.is_null()); |
| 578 | 580 |
| 579 InitiateUploadExistingFileRequest* request = | 581 InitiateUploadExistingFileRequest* request = |
| 580 new InitiateUploadExistingFileRequest(sender_.get(), | 582 new InitiateUploadExistingFileRequest(sender_.get(), |
| 581 url_generator_, | 583 url_generator_, |
| 582 content_type, | 584 content_type, |
| 583 content_length, | 585 content_length, |
| 584 resource_id, | 586 resource_id, |
| 585 options.etag, | 587 options.etag, |
| 586 callback); | 588 callback); |
| 587 request->set_parent_resource_id(options.parent_resource_id); | 589 request->set_parent_resource_id(options.parent_resource_id); |
| 588 request->set_title(options.title); | 590 request->set_title(options.title); |
| 589 request->set_modified_date(options.modified_date); | 591 request->set_modified_date(options.modified_date); |
| 590 request->set_last_viewed_by_me_date(options.last_viewed_by_me_date); | 592 request->set_last_viewed_by_me_date(options.last_viewed_by_me_date); |
| 593 request->set_properties(options.properties); |
| 591 return sender_->StartRequestWithRetry(request); | 594 return sender_->StartRequestWithRetry(request); |
| 592 } | 595 } |
| 593 | 596 |
| 594 CancelCallback DriveAPIService::ResumeUpload( | 597 CancelCallback DriveAPIService::ResumeUpload( |
| 595 const GURL& upload_url, | 598 const GURL& upload_url, |
| 596 int64 start_position, | 599 int64 start_position, |
| 597 int64 end_position, | 600 int64 end_position, |
| 598 int64 content_length, | 601 int64 content_length, |
| 599 const std::string& content_type, | 602 const std::string& content_type, |
| 600 const base::FilePath& local_file_path, | 603 const base::FilePath& local_file_path, |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 639 const UploadNewFileOptions& options, | 642 const UploadNewFileOptions& options, |
| 640 const FileResourceCallback& callback, | 643 const FileResourceCallback& callback, |
| 641 const google_apis::ProgressCallback& progress_callback) { | 644 const google_apis::ProgressCallback& progress_callback) { |
| 642 DCHECK(thread_checker_.CalledOnValidThread()); | 645 DCHECK(thread_checker_.CalledOnValidThread()); |
| 643 DCHECK(!callback.is_null()); | 646 DCHECK(!callback.is_null()); |
| 644 | 647 |
| 645 return sender_->StartRequestWithRetry( | 648 return sender_->StartRequestWithRetry( |
| 646 new google_apis::drive::MultipartUploadNewFileRequest( | 649 new google_apis::drive::MultipartUploadNewFileRequest( |
| 647 sender_.get(), title, parent_resource_id, content_type, | 650 sender_.get(), title, parent_resource_id, content_type, |
| 648 content_length, options.modified_date, options.last_viewed_by_me_date, | 651 content_length, options.modified_date, options.last_viewed_by_me_date, |
| 649 local_file_path, url_generator_, callback, progress_callback)); | 652 local_file_path, options.properties, url_generator_, callback, |
| 653 progress_callback)); |
| 650 } | 654 } |
| 651 | 655 |
| 652 CancelCallback DriveAPIService::MultipartUploadExistingFile( | 656 CancelCallback DriveAPIService::MultipartUploadExistingFile( |
| 653 const std::string& content_type, | 657 const std::string& content_type, |
| 654 int64 content_length, | 658 int64 content_length, |
| 655 const std::string& resource_id, | 659 const std::string& resource_id, |
| 656 const base::FilePath& local_file_path, | 660 const base::FilePath& local_file_path, |
| 657 const UploadExistingFileOptions& options, | 661 const UploadExistingFileOptions& options, |
| 658 const FileResourceCallback& callback, | 662 const FileResourceCallback& callback, |
| 659 const google_apis::ProgressCallback& progress_callback) { | 663 const google_apis::ProgressCallback& progress_callback) { |
| 660 DCHECK(thread_checker_.CalledOnValidThread()); | 664 DCHECK(thread_checker_.CalledOnValidThread()); |
| 661 DCHECK(!callback.is_null()); | 665 DCHECK(!callback.is_null()); |
| 662 | 666 |
| 663 return sender_->StartRequestWithRetry( | 667 return sender_->StartRequestWithRetry( |
| 664 new google_apis::drive::MultipartUploadExistingFileRequest( | 668 new google_apis::drive::MultipartUploadExistingFileRequest( |
| 665 sender_.get(), options.title, resource_id, options.parent_resource_id, | 669 sender_.get(), options.title, resource_id, options.parent_resource_id, |
| 666 content_type, content_length, options.modified_date, | 670 content_type, content_length, options.modified_date, |
| 667 options.last_viewed_by_me_date, local_file_path, options.etag, | 671 options.last_viewed_by_me_date, local_file_path, options.etag, |
| 668 url_generator_, callback, progress_callback)); | 672 options.properties, url_generator_, callback, progress_callback)); |
| 669 } | 673 } |
| 670 | 674 |
| 671 CancelCallback DriveAPIService::AuthorizeApp( | 675 CancelCallback DriveAPIService::AuthorizeApp( |
| 672 const std::string& resource_id, | 676 const std::string& resource_id, |
| 673 const std::string& app_id, | 677 const std::string& app_id, |
| 674 const AuthorizeAppCallback& callback) { | 678 const AuthorizeAppCallback& callback) { |
| 675 DCHECK(thread_checker_.CalledOnValidThread()); | 679 DCHECK(thread_checker_.CalledOnValidThread()); |
| 676 DCHECK(!callback.is_null()); | 680 DCHECK(!callback.is_null()); |
| 677 | 681 |
| 678 // Files.Authorize is only available for whitelisted clients like official | 682 // Files.Authorize is only available for whitelisted clients like official |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 770 if (CanSendRequest()) { | 774 if (CanSendRequest()) { |
| 771 FOR_EACH_OBSERVER( | 775 FOR_EACH_OBSERVER( |
| 772 DriveServiceObserver, observers_, OnReadyToSendRequests()); | 776 DriveServiceObserver, observers_, OnReadyToSendRequests()); |
| 773 } else if (!HasRefreshToken()) { | 777 } else if (!HasRefreshToken()) { |
| 774 FOR_EACH_OBSERVER( | 778 FOR_EACH_OBSERVER( |
| 775 DriveServiceObserver, observers_, OnRefreshTokenInvalid()); | 779 DriveServiceObserver, observers_, OnRefreshTokenInvalid()); |
| 776 } | 780 } |
| 777 } | 781 } |
| 778 | 782 |
| 779 } // namespace drive | 783 } // namespace drive |
| OLD | NEW |