| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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_SIGNIN_OAUTH2_TOKEN_SERVICE_REQUEST_H_ | 5 #ifndef CHROME_BROWSER_SIGNIN_PROFILE_OAUTH2_TOKEN_SERVICE_REQUEST_H_ |
| 6 #define CHROME_BROWSER_SIGNIN_OAUTH2_TOKEN_SERVICE_REQUEST_H_ | 6 #define CHROME_BROWSER_SIGNIN_PROFILE_OAUTH2_TOKEN_SERVICE_REQUEST_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/memory/ref_counted.h" | |
| 12 #include "base/threading/non_thread_safe.h" | 11 #include "base/threading/non_thread_safe.h" |
| 13 #include "base/time.h" | |
| 14 #include "chrome/browser/signin/oauth2_token_service.h" | 12 #include "chrome/browser/signin/oauth2_token_service.h" |
| 15 #include "google_apis/gaia/google_service_auth_error.h" | |
| 16 | 13 |
| 17 class Profile; | 14 class Profile; |
| 18 | 15 |
| 19 // OAuth2TokenServiceRequest represents a request to fetch an OAuth2 access | 16 // ProfileOAuth2TokenServiceRequest represents a request to fetch an |
| 20 // token for a given set of |scopes| by calling |profile|'s | 17 // OAuth2 access token for a given set of |scopes| by calling |profile|'s |
| 21 // OAuth2TokenService. A request can be created and started from any thread | 18 // ProfileOAuth2TokenService. A request can be created and started from |
| 22 // with an object |consumer| that will be called back on the same thread when | 19 // any thread with an object |consumer| that will be called back on the |
| 23 // fetching completes. | 20 // same thread when fetching completes. If the request is destructed |
| 24 // If the request is destructed before |consumer| is called, |consumer| will | 21 // before |consumer| is called, |consumer| will never be called back. (Note |
| 25 // never be called back. (Note the actual network activities are not canceled | 22 // the actual network activities are not canceled and the cache in |
| 26 // and the cache in OAuth2TokenService will be populated with the fetched | 23 // ProfileOAuth2TokenService will be populated with the fetched results.) |
| 27 // results.) | 24 class ProfileOAuth2TokenServiceRequest : public OAuth2TokenService::Request, |
| 28 class OAuth2TokenServiceRequest : public OAuth2TokenService::Request, | 25 public base::NonThreadSafe { |
| 29 public base::NonThreadSafe { | |
| 30 public: | 26 public: |
| 31 static OAuth2TokenServiceRequest* CreateAndStart( | 27 static ProfileOAuth2TokenServiceRequest* CreateAndStart( |
| 32 Profile* profile, | 28 Profile* profile, |
| 33 const OAuth2TokenService::ScopeSet& scopes, | 29 const OAuth2TokenService::ScopeSet& scopes, |
| 34 OAuth2TokenService::Consumer* consumer); | 30 OAuth2TokenService::Consumer* consumer); |
| 35 | 31 |
| 36 virtual ~OAuth2TokenServiceRequest(); | 32 virtual ~ProfileOAuth2TokenServiceRequest(); |
| 37 | 33 |
| 38 private: | 34 private: |
| 39 class Core; | 35 class Core; |
| 40 friend class Core; | 36 friend class Core; |
| 41 | 37 |
| 42 OAuth2TokenServiceRequest(Profile* profile, | 38 ProfileOAuth2TokenServiceRequest(Profile* profile, |
| 43 const OAuth2TokenService::ScopeSet& scopes, | 39 const OAuth2TokenService::ScopeSet& scopes, |
| 44 OAuth2TokenService::Consumer* consumer); | 40 OAuth2TokenService::Consumer* consumer); |
| 45 OAuth2TokenService::Consumer* const consumer_; | 41 OAuth2TokenService::Consumer* const consumer_; |
| 46 scoped_refptr<Core> core_; | 42 scoped_refptr<Core> core_; |
| 47 | 43 |
| 48 DISALLOW_COPY_AND_ASSIGN(OAuth2TokenServiceRequest); | 44 DISALLOW_COPY_AND_ASSIGN(ProfileOAuth2TokenServiceRequest); |
| 49 }; | 45 }; |
| 50 | 46 |
| 51 #endif // CHROME_BROWSER_SIGNIN_OAUTH2_TOKEN_SERVICE_REQUEST_H_ | 47 #endif // CHROME_BROWSER_SIGNIN_PROFILE_OAUTH2_TOKEN_SERVICE_REQUEST_H_ |
| OLD | NEW |