OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/oauth_token_getter_impl.h" | 5 #include "remoting/host/oauth_token_getter_impl.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
12 #include "google_apis/google_api_keys.h" | 12 #include "google_apis/google_api_keys.h" |
13 #include "net/url_request/url_request_context_getter.h" | 13 #include "net/url_request/url_request_context_getter.h" |
14 #include "remoting/base/logging.h" | 14 #include "remoting/base/logging.h" |
15 | 15 |
16 namespace remoting { | 16 namespace remoting { |
17 | 17 |
18 namespace { | 18 namespace { |
19 | 19 |
20 // Maximum number of retries on network/500 errors. | 20 // Maximum number of retries on network/500 errors. |
21 const int kMaxRetries = 3; | 21 const int kMaxRetries = 3; |
22 | 22 |
23 // Time when we we try to update OAuth token before its expiration. | 23 // Time when we we try to update OAuth token before its expiration. |
24 const int kTokenUpdateTimeBeforeExpirySeconds = 60; | 24 const int kTokenUpdateTimeBeforeExpirySeconds = 60; |
25 | 25 |
26 } // namespace | 26 } // namespace |
27 | 27 |
28 OAuthTokenGetterImpl::OAuthTokenGetterImpl( | 28 OAuthTokenGetterImpl::OAuthTokenGetterImpl( |
29 scoped_ptr<OAuthCredentials> oauth_credentials, | 29 std::unique_ptr<OAuthCredentials> oauth_credentials, |
30 const scoped_refptr<net::URLRequestContextGetter>& | 30 const scoped_refptr<net::URLRequestContextGetter>& |
31 url_request_context_getter, | 31 url_request_context_getter, |
32 bool auto_refresh) | 32 bool auto_refresh) |
33 : oauth_credentials_(std::move(oauth_credentials)), | 33 : oauth_credentials_(std::move(oauth_credentials)), |
34 gaia_oauth_client_( | 34 gaia_oauth_client_( |
35 new gaia::GaiaOAuthClient(url_request_context_getter.get())), | 35 new gaia::GaiaOAuthClient(url_request_context_getter.get())), |
36 url_request_context_getter_(url_request_context_getter) { | 36 url_request_context_getter_(url_request_context_getter) { |
37 if (auto_refresh) { | 37 if (auto_refresh) { |
38 refresh_timer_.reset(new base::OneShotTimer()); | 38 refresh_timer_.reset(new base::OneShotTimer()); |
39 } | 39 } |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 ""}; | 172 ""}; |
173 | 173 |
174 refreshing_oauth_token_ = true; | 174 refreshing_oauth_token_ = true; |
175 std::vector<std::string> empty_scope_list; // Use scope from refresh token. | 175 std::vector<std::string> empty_scope_list; // Use scope from refresh token. |
176 gaia_oauth_client_->RefreshToken(client_info, | 176 gaia_oauth_client_->RefreshToken(client_info, |
177 oauth_credentials_->refresh_token, | 177 oauth_credentials_->refresh_token, |
178 empty_scope_list, kMaxRetries, this); | 178 empty_scope_list, kMaxRetries, this); |
179 } | 179 } |
180 | 180 |
181 } // namespace remoting | 181 } // namespace remoting |
OLD | NEW |