| 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 "components/drive/service/drive_api_service.h" | 5 #include "components/drive/service/drive_api_service.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 850 } | 850 } |
| 851 | 851 |
| 852 void DriveAPIService::ClearRefreshToken() { | 852 void DriveAPIService::ClearRefreshToken() { |
| 853 DCHECK(thread_checker_.CalledOnValidThread()); | 853 DCHECK(thread_checker_.CalledOnValidThread()); |
| 854 sender_->auth_service()->ClearRefreshToken(); | 854 sender_->auth_service()->ClearRefreshToken(); |
| 855 } | 855 } |
| 856 | 856 |
| 857 void DriveAPIService::OnOAuth2RefreshTokenChanged() { | 857 void DriveAPIService::OnOAuth2RefreshTokenChanged() { |
| 858 DCHECK(thread_checker_.CalledOnValidThread()); | 858 DCHECK(thread_checker_.CalledOnValidThread()); |
| 859 if (CanSendRequest()) { | 859 if (CanSendRequest()) { |
| 860 FOR_EACH_OBSERVER( | 860 for (auto& observer : observers_) |
| 861 DriveServiceObserver, observers_, OnReadyToSendRequests()); | 861 observer.OnReadyToSendRequests(); |
| 862 } else if (!HasRefreshToken()) { | 862 } else if (!HasRefreshToken()) { |
| 863 FOR_EACH_OBSERVER( | 863 for (auto& observer : observers_) |
| 864 DriveServiceObserver, observers_, OnRefreshTokenInvalid()); | 864 observer.OnRefreshTokenInvalid(); |
| 865 } | 865 } |
| 866 } | 866 } |
| 867 | 867 |
| 868 std::unique_ptr<BatchRequestConfiguratorInterface> | 868 std::unique_ptr<BatchRequestConfiguratorInterface> |
| 869 DriveAPIService::StartBatchRequest() { | 869 DriveAPIService::StartBatchRequest() { |
| 870 std::unique_ptr<google_apis::drive::BatchUploadRequest> request = | 870 std::unique_ptr<google_apis::drive::BatchUploadRequest> request = |
| 871 base::MakeUnique<google_apis::drive::BatchUploadRequest>(sender_.get(), | 871 base::MakeUnique<google_apis::drive::BatchUploadRequest>(sender_.get(), |
| 872 url_generator_); | 872 url_generator_); |
| 873 const base::WeakPtr<google_apis::drive::BatchUploadRequest> weak_ref = | 873 const base::WeakPtr<google_apis::drive::BatchUploadRequest> weak_ref = |
| 874 request->GetWeakPtrAsBatchUploadRequest(); | 874 request->GetWeakPtrAsBatchUploadRequest(); |
| 875 // Have sender_ manage the lifetime of the request. | 875 // Have sender_ manage the lifetime of the request. |
| 876 // TODO(hirono): Currently we need to pass the ownership of the request to | 876 // TODO(hirono): Currently we need to pass the ownership of the request to |
| 877 // RequestSender before the request is committed because the request has a | 877 // RequestSender before the request is committed because the request has a |
| 878 // reference to RequestSender and we should ensure to delete the request when | 878 // reference to RequestSender and we should ensure to delete the request when |
| 879 // the sender is deleted. Resolve the circulating dependency and fix it. | 879 // the sender is deleted. Resolve the circulating dependency and fix it. |
| 880 const google_apis::CancelCallback callback = | 880 const google_apis::CancelCallback callback = |
| 881 sender_->StartRequestWithAuthRetry(std::move(request)); | 881 sender_->StartRequestWithAuthRetry(std::move(request)); |
| 882 return base::MakeUnique<BatchRequestConfigurator>( | 882 return base::MakeUnique<BatchRequestConfigurator>( |
| 883 weak_ref, sender_->blocking_task_runner(), url_generator_, callback); | 883 weak_ref, sender_->blocking_task_runner(), url_generator_, callback); |
| 884 } | 884 } |
| 885 | 885 |
| 886 } // namespace drive | 886 } // namespace drive |
| OLD | NEW |