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

Side by Side Diff: remoting/base/oauth_token_getter.h

Issue 2661153003: Moving oauth code from host to base to allow code sharing between host and client. (Closed)
Patch Set: Merge branch 'master' into auth_token Created 3 years, 10 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
« no previous file with comments | « remoting/base/oauth_helper_unittest.cc ('k') | remoting/base/oauth_token_getter.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_H_ 5 #ifndef REMOTING_BASE_OAUTH_TOKEN_GETTER_H_
6 #define REMOTING_HOST_OAUTH_TOKEN_GETTER_H_ 6 #define REMOTING_BASE_OAUTH_TOKEN_GETTER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 12
13 namespace remoting { 13 namespace remoting {
14 14
15 // OAuthTokenGetter caches OAuth access tokens and refreshes them as needed. 15 // OAuthTokenGetter caches OAuth access tokens and refreshes them as needed.
16 class OAuthTokenGetter { 16 class OAuthTokenGetter {
17 public: 17 public:
18 // Status of the refresh token attempt. 18 // Status of the refresh token attempt.
19 enum Status { 19 enum Status {
20 // Success, credentials in user_email/access_token. 20 // Success, credentials in user_email/access_token.
21 SUCCESS, 21 SUCCESS,
22 // Network failure (caller may retry). 22 // Network failure (caller may retry).
23 NETWORK_ERROR, 23 NETWORK_ERROR,
24 // Authentication failure (permanent). 24 // Authentication failure (permanent).
25 AUTH_ERROR, 25 AUTH_ERROR,
26 }; 26 };
27 27
28 typedef base::Callback<void(Status status, 28 typedef base::Callback<void(Status status,
29 const std::string& user_email, 29 const std::string& user_email,
30 const std::string& access_token)> TokenCallback; 30 const std::string& access_token)>
31 TokenCallback;
31 32
32 // This structure contains information required to perform 33 // This structure contains information required to perform
33 // authentication to OAuth2. 34 // authentication to OAuth2.
34 struct OAuthCredentials { 35 struct OAuthCredentials {
35 // |is_service_account| should be True if the OAuth refresh token is for a 36 // |is_service_account| should be True if the OAuth refresh token is for a
36 // service account, False for a user account, to allow the correct client-ID 37 // service account, False for a user account, to allow the correct client-ID
37 // to be used. 38 // to be used.
38 OAuthCredentials(const std::string& login, 39 OAuthCredentials(const std::string& login,
39 const std::string& refresh_token, 40 const std::string& refresh_token,
40 bool is_service_account); 41 bool is_service_account);
(...skipping 17 matching lines...) Expand all
58 59
59 // Invalidates the cache, so the next CallWithToken() will get a fresh access 60 // Invalidates the cache, so the next CallWithToken() will get a fresh access
60 // token. 61 // token.
61 virtual void InvalidateCache() = 0; 62 virtual void InvalidateCache() = 0;
62 63
63 DISALLOW_COPY_AND_ASSIGN(OAuthTokenGetter); 64 DISALLOW_COPY_AND_ASSIGN(OAuthTokenGetter);
64 }; 65 };
65 66
66 } // namespace remoting 67 } // namespace remoting
67 68
68 #endif // REMOTING_HOST_OAUTH_TOKEN_GETTER_H_ 69 #endif // REMOTING_BASE_OAUTH_TOKEN_GETTER_H_
OLDNEW
« no previous file with comments | « remoting/base/oauth_helper_unittest.cc ('k') | remoting/base/oauth_token_getter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698