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 30 matching lines...) Expand all Loading... |
47 | 48 |
48 void OAuthClient::OnRefreshTokenResponse( | 49 void OAuthClient::OnRefreshTokenResponse( |
49 const std::string& access_token, | 50 const std::string& access_token, |
50 int expires_in_seconds) { | 51 int expires_in_seconds) { |
51 // We never request a refresh token, so this call is not expected. | 52 // We never request a refresh token, so this call is not expected. |
52 NOTREACHED(); | 53 NOTREACHED(); |
53 } | 54 } |
54 | 55 |
55 void OAuthClient::SendResponse(const std::string& user_email, | 56 void OAuthClient::SendResponse(const std::string& user_email, |
56 const std::string& refresh_token) { | 57 const std::string& refresh_token) { |
57 CompletionCallback on_done = on_done_; | 58 base::ResetAndReturn(&on_done_).Run(user_email, refresh_token); |
58 on_done_.Reset(); | |
59 on_done.Run(user_email, refresh_token); | |
60 | 59 |
61 // Process the next request in the queue. | 60 // Process the next request in the queue. |
62 if (pending_requests_.size()) { | 61 if (pending_requests_.size()) { |
63 Request request = pending_requests_.front(); | 62 Request request = pending_requests_.front(); |
64 pending_requests_.pop(); | 63 pending_requests_.pop(); |
65 // GetCredentialsFromAuthCode is asynchronous, so it's safe to call it here. | 64 // GetCredentialsFromAuthCode is asynchronous, so it's safe to call it here. |
66 GetCredentialsFromAuthCode( | 65 GetCredentialsFromAuthCode( |
67 request.oauth_client_info, request.auth_code, request.on_done); | 66 request.oauth_client_info, request.auth_code, request.on_done); |
68 } | 67 } |
69 } | 68 } |
(...skipping 16 matching lines...) Expand all Loading... |
86 CompletionCallback on_done) { | 85 CompletionCallback on_done) { |
87 this->oauth_client_info = oauth_client_info; | 86 this->oauth_client_info = oauth_client_info; |
88 this->auth_code = auth_code; | 87 this->auth_code = auth_code; |
89 this->on_done = on_done; | 88 this->on_done = on_done; |
90 } | 89 } |
91 | 90 |
92 OAuthClient::Request::~Request() { | 91 OAuthClient::Request::~Request() { |
93 } | 92 } |
94 | 93 |
95 } // namespace remoting | 94 } // namespace remoting |
OLD | NEW |