| 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 #ifndef GOOGLE_APIS_GAIA_OAUTH2_TOKEN_SERVICE_H_ | 5 #ifndef GOOGLE_APIS_GAIA_OAUTH2_TOKEN_SERVICE_H_ |
| 6 #define GOOGLE_APIS_GAIA_OAUTH2_TOKEN_SERVICE_H_ | 6 #define GOOGLE_APIS_GAIA_OAUTH2_TOKEN_SERVICE_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 // successful completion. | 129 // successful completion. |
| 130 virtual void OnFetchAccessTokenComplete(const std::string& account_id, | 130 virtual void OnFetchAccessTokenComplete(const std::string& account_id, |
| 131 const std::string& consumer_id, | 131 const std::string& consumer_id, |
| 132 const ScopeSet& scopes, | 132 const ScopeSet& scopes, |
| 133 GoogleServiceAuthError error, | 133 GoogleServiceAuthError error, |
| 134 base::Time expiration_time) = 0; | 134 base::Time expiration_time) = 0; |
| 135 virtual void OnTokenRemoved(const std::string& account_id, | 135 virtual void OnTokenRemoved(const std::string& account_id, |
| 136 const ScopeSet& scopes) = 0; | 136 const ScopeSet& scopes) = 0; |
| 137 }; | 137 }; |
| 138 | 138 |
| 139 explicit OAuth2TokenService(OAuth2TokenServiceDelegate* delegate); | 139 explicit OAuth2TokenService( |
| 140 std::unique_ptr<OAuth2TokenServiceDelegate> delegate); |
| 140 virtual ~OAuth2TokenService(); | 141 virtual ~OAuth2TokenService(); |
| 141 | 142 |
| 142 // Add or remove observers of this token service. | 143 // Add or remove observers of this token service. |
| 143 void AddObserver(Observer* observer); | 144 void AddObserver(Observer* observer); |
| 144 void RemoveObserver(Observer* observer); | 145 void RemoveObserver(Observer* observer); |
| 145 | 146 |
| 146 // Add or remove observers of this token service. | 147 // Add or remove observers of this token service. |
| 147 void AddDiagnosticsObserver(DiagnosticsObserver* observer); | 148 void AddDiagnosticsObserver(DiagnosticsObserver* observer); |
| 148 void RemoveDiagnosticsObserver(DiagnosticsObserver* observer); | 149 void RemoveDiagnosticsObserver(DiagnosticsObserver* observer); |
| 149 | 150 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 const std::string& access_token); | 207 const std::string& access_token); |
| 207 | 208 |
| 208 void set_max_authorization_token_fetch_retries_for_testing(int max_retries); | 209 void set_max_authorization_token_fetch_retries_for_testing(int max_retries); |
| 209 // Returns the current number of pending fetchers matching given params. | 210 // Returns the current number of pending fetchers matching given params. |
| 210 size_t GetNumPendingRequestsForTesting( | 211 size_t GetNumPendingRequestsForTesting( |
| 211 const std::string& client_id, | 212 const std::string& client_id, |
| 212 const std::string& account_id, | 213 const std::string& account_id, |
| 213 const ScopeSet& scopes) const; | 214 const ScopeSet& scopes) const; |
| 214 | 215 |
| 215 OAuth2TokenServiceDelegate* GetDelegate(); | 216 OAuth2TokenServiceDelegate* GetDelegate(); |
| 217 const OAuth2TokenServiceDelegate* GetDelegate() const; |
| 216 | 218 |
| 217 protected: | 219 protected: |
| 218 // Implements a cancelable |OAuth2TokenService::Request|, which should be | 220 // Implements a cancelable |OAuth2TokenService::Request|, which should be |
| 219 // operated on the UI thread. | 221 // operated on the UI thread. |
| 220 // TODO(davidroche): move this out of header file. | 222 // TODO(davidroche): move this out of header file. |
| 221 class RequestImpl : public base::SupportsWeakPtr<RequestImpl>, | 223 class RequestImpl : public base::SupportsWeakPtr<RequestImpl>, |
| 222 public base::NonThreadSafe, | 224 public base::NonThreadSafe, |
| 223 public Request { | 225 public Request { |
| 224 public: | 226 public: |
| 225 // |consumer| is required to outlive this. | 227 // |consumer| is required to outlive this. |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 | 385 |
| 384 FRIEND_TEST_ALL_PREFIXES(OAuth2TokenServiceTest, RequestParametersOrderTest); | 386 FRIEND_TEST_ALL_PREFIXES(OAuth2TokenServiceTest, RequestParametersOrderTest); |
| 385 FRIEND_TEST_ALL_PREFIXES(OAuth2TokenServiceTest, | 387 FRIEND_TEST_ALL_PREFIXES(OAuth2TokenServiceTest, |
| 386 SameScopesRequestedForDifferentClients); | 388 SameScopesRequestedForDifferentClients); |
| 387 FRIEND_TEST_ALL_PREFIXES(OAuth2TokenServiceTest, UpdateClearsCache); | 389 FRIEND_TEST_ALL_PREFIXES(OAuth2TokenServiceTest, UpdateClearsCache); |
| 388 | 390 |
| 389 DISALLOW_COPY_AND_ASSIGN(OAuth2TokenService); | 391 DISALLOW_COPY_AND_ASSIGN(OAuth2TokenService); |
| 390 }; | 392 }; |
| 391 | 393 |
| 392 #endif // GOOGLE_APIS_GAIA_OAUTH2_TOKEN_SERVICE_H_ | 394 #endif // GOOGLE_APIS_GAIA_OAUTH2_TOKEN_SERVICE_H_ |
| OLD | NEW |