Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(939)

Side by Side Diff: remoting/host/oauth_token_getter_impl.h

Issue 1864213002: Convert //remoting to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Mac IWYU Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #ifndef REMOTING_HOST_OAUTH_TOKEN_GETTER_IMPL_H_ 5 #ifndef REMOTING_HOST_OAUTH_TOKEN_GETTER_IMPL_H_
6 #define REMOTING_HOST_OAUTH_TOKEN_GETTER_IMPL_H_ 6 #define REMOTING_HOST_OAUTH_TOKEN_GETTER_IMPL_H_
7 7
8 #include <queue> 8 #include <queue>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/threading/non_thread_safe.h" 11 #include "base/threading/non_thread_safe.h"
12 #include "base/time/time.h" 12 #include "base/time/time.h"
13 #include "base/timer/timer.h" 13 #include "base/timer/timer.h"
14 #include "google_apis/gaia/gaia_oauth_client.h" 14 #include "google_apis/gaia/gaia_oauth_client.h"
15 #include "remoting/host/oauth_token_getter.h" 15 #include "remoting/host/oauth_token_getter.h"
16 16
17 namespace net { 17 namespace net {
18 class URLRequestContextGetter; 18 class URLRequestContextGetter;
19 } // namespace net 19 } // namespace net
20 20
21 namespace remoting { 21 namespace remoting {
22 22
23 // OAuthTokenGetter caches OAuth access tokens and refreshes them as needed. 23 // OAuthTokenGetter caches OAuth access tokens and refreshes them as needed.
24 class OAuthTokenGetterImpl : public OAuthTokenGetter, 24 class OAuthTokenGetterImpl : public OAuthTokenGetter,
25 public base::NonThreadSafe, 25 public base::NonThreadSafe,
26 public gaia::GaiaOAuthClient::Delegate { 26 public gaia::GaiaOAuthClient::Delegate {
27 public: 27 public:
28 OAuthTokenGetterImpl(scoped_ptr<OAuthCredentials> oauth_credentials, 28 OAuthTokenGetterImpl(std::unique_ptr<OAuthCredentials> oauth_credentials,
29 const scoped_refptr<net::URLRequestContextGetter>& 29 const scoped_refptr<net::URLRequestContextGetter>&
30 url_request_context_getter, 30 url_request_context_getter,
31 bool auto_refresh); 31 bool auto_refresh);
32 ~OAuthTokenGetterImpl() override; 32 ~OAuthTokenGetterImpl() override;
33 33
34 // OAuthTokenGetter interface. 34 // OAuthTokenGetter interface.
35 void CallWithToken( 35 void CallWithToken(
36 const OAuthTokenGetter::TokenCallback& on_access_token) override; 36 const OAuthTokenGetter::TokenCallback& on_access_token) override;
37 void InvalidateCache() override; 37 void InvalidateCache() override;
38 38
39 private: 39 private:
40 // gaia::GaiaOAuthClient::Delegate interface. 40 // gaia::GaiaOAuthClient::Delegate interface.
41 void OnGetTokensResponse(const std::string& user_email, 41 void OnGetTokensResponse(const std::string& user_email,
42 const std::string& access_token, 42 const std::string& access_token,
43 int expires_seconds) override; 43 int expires_seconds) override;
44 void OnRefreshTokenResponse(const std::string& access_token, 44 void OnRefreshTokenResponse(const std::string& access_token,
45 int expires_in_seconds) override; 45 int expires_in_seconds) override;
46 void OnGetUserEmailResponse(const std::string& user_email) override; 46 void OnGetUserEmailResponse(const std::string& user_email) override;
47 void OnOAuthError() override; 47 void OnOAuthError() override;
48 void OnNetworkError(int response_code) override; 48 void OnNetworkError(int response_code) override;
49 49
50 void NotifyCallbacks(Status status, 50 void NotifyCallbacks(Status status,
51 const std::string& user_email, 51 const std::string& user_email,
52 const std::string& access_token); 52 const std::string& access_token);
53 void RefreshOAuthToken(); 53 void RefreshOAuthToken();
54 54
55 scoped_ptr<OAuthCredentials> oauth_credentials_; 55 std::unique_ptr<OAuthCredentials> oauth_credentials_;
56 scoped_ptr<gaia::GaiaOAuthClient> gaia_oauth_client_; 56 std::unique_ptr<gaia::GaiaOAuthClient> gaia_oauth_client_;
57 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; 57 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_;
58 58
59 bool refreshing_oauth_token_ = false; 59 bool refreshing_oauth_token_ = false;
60 bool email_verified_ = false; 60 bool email_verified_ = false;
61 std::string oauth_access_token_; 61 std::string oauth_access_token_;
62 base::Time auth_token_expiry_time_; 62 base::Time auth_token_expiry_time_;
63 std::queue<OAuthTokenGetter::TokenCallback> pending_callbacks_; 63 std::queue<OAuthTokenGetter::TokenCallback> pending_callbacks_;
64 scoped_ptr<base::OneShotTimer> refresh_timer_; 64 std::unique_ptr<base::OneShotTimer> refresh_timer_;
65 }; 65 };
66 66
67 } // namespace remoting 67 } // namespace remoting
68 68
69 #endif // REMOTING_HOST_OAUTH_TOKEN_GETTER_IMPL_H_ 69 #endif // REMOTING_HOST_OAUTH_TOKEN_GETTER_IMPL_H_
OLDNEW
« no previous file with comments | « remoting/host/native_messaging/pipe_messaging_channel.cc ('k') | remoting/host/oauth_token_getter_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698