| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "remoting/host/setup/oauth_client.h" | 5 #include "remoting/host/setup/oauth_client.h" |
| 6 | 6 |
| 7 #include "base/callback_helpers.h" |
| 7 #include "base/logging.h" | 8 #include "base/logging.h" |
| 8 | 9 |
| 9 namespace { | 10 namespace { |
| 10 const int kMaxGaiaRetries = 3; | 11 const int kMaxGaiaRetries = 3; |
| 11 } // namespace | 12 } // namespace |
| 12 | 13 |
| 13 namespace remoting { | 14 namespace remoting { |
| 14 | 15 |
| 15 OAuthClient::OAuthClient( | 16 OAuthClient::OAuthClient( |
| 16 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter) | 17 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter) |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 | 55 |
| 55 void OAuthClient::OnRefreshTokenResponse( | 56 void OAuthClient::OnRefreshTokenResponse( |
| 56 const std::string& access_token, | 57 const std::string& access_token, |
| 57 int expires_in_seconds) { | 58 int expires_in_seconds) { |
| 58 // We never request a refresh token, so this call is not expected. | 59 // We never request a refresh token, so this call is not expected. |
| 59 NOTREACHED(); | 60 NOTREACHED(); |
| 60 } | 61 } |
| 61 | 62 |
| 62 void OAuthClient::SendResponse(const std::string& user_email, | 63 void OAuthClient::SendResponse(const std::string& user_email, |
| 63 const std::string& refresh_token) { | 64 const std::string& refresh_token) { |
| 64 CompletionCallback on_done = on_done_; | 65 base::ResetAndReturn(&on_done_).Run(user_email, refresh_token); |
| 65 on_done_.Reset(); | |
| 66 on_done.Run(user_email, refresh_token); | |
| 67 | 66 |
| 68 // Process the next request in the queue. | 67 // Process the next request in the queue. |
| 69 if (pending_requests_.size()) { | 68 if (pending_requests_.size()) { |
| 70 Request request = pending_requests_.front(); | 69 Request request = pending_requests_.front(); |
| 71 pending_requests_.pop(); | 70 pending_requests_.pop(); |
| 72 // GetCredentialsFromAuthCode is asynchronous, so it's safe to call it here. | 71 // GetCredentialsFromAuthCode is asynchronous, so it's safe to call it here. |
| 73 GetCredentialsFromAuthCode( | 72 GetCredentialsFromAuthCode( |
| 74 request.oauth_client_info, | 73 request.oauth_client_info, |
| 75 request.auth_code, | 74 request.auth_code, |
| 76 request.need_user_email, | 75 request.need_user_email, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 98 this->oauth_client_info = oauth_client_info; | 97 this->oauth_client_info = oauth_client_info; |
| 99 this->auth_code = auth_code; | 98 this->auth_code = auth_code; |
| 100 this->need_user_email = need_user_email; | 99 this->need_user_email = need_user_email; |
| 101 this->on_done = on_done; | 100 this->on_done = on_done; |
| 102 } | 101 } |
| 103 | 102 |
| 104 OAuthClient::Request::~Request() { | 103 OAuthClient::Request::~Request() { |
| 105 } | 104 } |
| 106 | 105 |
| 107 } // namespace remoting | 106 } // namespace remoting |
| OLD | NEW |