OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_POLICY_OAUTH2_TOKEN_FETCHER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_POLICY_OAUTH2_TOKEN_FETCHER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_POLICY_POLICY_OAUTH2_TOKEN_FETCHER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_POLICY_POLICY_OAUTH2_TOKEN_FETCHER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
46 | 46 |
47 PolicyOAuth2TokenFetcher(const std::string& auth_code, | 47 PolicyOAuth2TokenFetcher(const std::string& auth_code, |
48 net::URLRequestContextGetter* system_context_getter, | 48 net::URLRequestContextGetter* system_context_getter, |
49 const TokenCallback& callback); | 49 const TokenCallback& callback); |
50 | 50 |
51 ~PolicyOAuth2TokenFetcher() override; | 51 ~PolicyOAuth2TokenFetcher() override; |
52 | 52 |
53 // Starts process of minting device management service OAuth2 access token. | 53 // Starts process of minting device management service OAuth2 access token. |
54 void Start(); | 54 void Start(); |
55 | 55 |
56 // Starts minting device management service OAuth2 access token with the given | |
57 // |oauth2_refresh_token|. | |
58 void StartWithRefreshToken(const std::string& oauth2_refresh_token); | |
Mattias Nissler (ping if slow)
2015/04/28 06:50:43
Please turn this into a 3rd constructor for consis
achuithb
2015/04/28 18:20:08
I considered this. The first problem is that the t
Mattias Nissler (ping if slow)
2015/04/29 07:10:52
That's a good point.
| |
59 | |
56 // Returns true if we have previously attempted to fetch tokens with this | 60 // Returns true if we have previously attempted to fetch tokens with this |
57 // class and failed. | 61 // class and failed. |
58 bool failed() const { | 62 bool failed() const { |
59 return failed_; | 63 return failed_; |
60 } | 64 } |
61 | 65 |
62 const std::string& oauth2_refresh_token() const { | 66 const std::string& oauth2_refresh_token() const { |
63 return oauth2_refresh_token_; | 67 return oauth2_refresh_token_; |
64 } | 68 } |
65 const std::string& oauth2_access_token() const { | 69 const std::string& oauth2_access_token() const { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
103 scoped_ptr<OAuth2AccessTokenFetcher> access_token_fetcher_; | 107 scoped_ptr<OAuth2AccessTokenFetcher> access_token_fetcher_; |
104 | 108 |
105 // OAuth2 refresh token. Could come either from the outside or through | 109 // OAuth2 refresh token. Could come either from the outside or through |
106 // refresh token fetching flow within this class. | 110 // refresh token fetching flow within this class. |
107 std::string oauth2_refresh_token_; | 111 std::string oauth2_refresh_token_; |
108 | 112 |
109 // OAuth2 access token. | 113 // OAuth2 access token. |
110 std::string oauth2_access_token_; | 114 std::string oauth2_access_token_; |
111 | 115 |
112 // The retry counter. Increment this only when failure happened. | 116 // The retry counter. Increment this only when failure happened. |
113 int retry_count_; | 117 int retry_count_ = 0; |
114 | 118 |
115 // True if we have already failed to fetch the policy. | 119 // True if we have already failed to fetch the policy. |
116 bool failed_; | 120 bool failed_ = false; |
117 | 121 |
118 // The callback to invoke when done. | 122 // The callback to invoke when done. |
119 TokenCallback callback_; | 123 TokenCallback callback_; |
120 | 124 |
121 DISALLOW_COPY_AND_ASSIGN(PolicyOAuth2TokenFetcher); | 125 DISALLOW_COPY_AND_ASSIGN(PolicyOAuth2TokenFetcher); |
122 }; | 126 }; |
123 | 127 |
124 } // namespace policy | 128 } // namespace policy |
125 | 129 |
126 #endif // CHROME_BROWSER_CHROMEOS_POLICY_POLICY_OAUTH2_TOKEN_FETCHER_H_ | 130 #endif // CHROME_BROWSER_CHROMEOS_POLICY_POLICY_OAUTH2_TOKEN_FETCHER_H_ |
OLD | NEW |