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

Side by Side Diff: google_apis/gaia/ubertoken_fetcher.h

Issue 136723009: Move UbertokenFetcher from //chrome to //google_apis. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « google_apis/gaia/fake_oauth2_token_service.cc ('k') | google_apis/gaia/ubertoken_fetcher.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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_UBERTOKEN_FETCHER_H_ 5 #ifndef GOOGLE_APIS_GAIA_UBERTOKEN_FETCHER_H_
6 #define CHROME_BROWSER_SIGNIN_UBERTOKEN_FETCHER_H_ 6 #define GOOGLE_APIS_GAIA_UBERTOKEN_FETCHER_H_
7 7
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "google_apis/gaia/gaia_auth_consumer.h" 9 #include "google_apis/gaia/gaia_auth_consumer.h"
10 #include "google_apis/gaia/oauth2_token_service.h" 10 #include "google_apis/gaia/oauth2_token_service.h"
11 11
12 // Allow to retrieves an uber-auth token for the user. This class uses the 12 // Allow to retrieves an uber-auth token for the user. This class uses the
13 // |OAuth2TokenService| and considers that the user is already logged in. It 13 // |OAuth2TokenService| and considers that the user is already logged in. It
14 // will use the OAuth2 access token to generate the uber-auth token. 14 // will use the OAuth2 access token to generate the uber-auth token.
15 // 15 //
16 // This class should be used on a single thread, but it can be whichever thread 16 // This class should be used on a single thread, but it can be whichever thread
17 // that you like. 17 // that you like.
18 // 18 //
19 // This class can handle one request at a time. 19 // This class can handle one request at a time.
20 20
21 class GaiaAuthFetcher; 21 class GaiaAuthFetcher;
22 class GoogleServiceAuthError; 22 class GoogleServiceAuthError;
23 class Profile; 23
24 namespace net {
25 class URLRequestContextGetter;
26 }
24 27
25 // Callback for the |UbertokenFetcher| class. 28 // Callback for the |UbertokenFetcher| class.
26 class UbertokenConsumer { 29 class UbertokenConsumer {
27 public: 30 public:
28 UbertokenConsumer() {} 31 UbertokenConsumer() {}
29 virtual ~UbertokenConsumer() {} 32 virtual ~UbertokenConsumer() {}
30 virtual void OnUbertokenSuccess(const std::string& token) {} 33 virtual void OnUbertokenSuccess(const std::string& token) {}
31 virtual void OnUbertokenFailure(const GoogleServiceAuthError& error) {} 34 virtual void OnUbertokenFailure(const GoogleServiceAuthError& error) {}
32 }; 35 };
33 36
34 // Allows to retrieve an uber-auth token. 37 // Allows to retrieve an uber-auth token.
35 class UbertokenFetcher : public GaiaAuthConsumer, 38 class UbertokenFetcher : public GaiaAuthConsumer,
36 public OAuth2TokenService::Consumer { 39 public OAuth2TokenService::Consumer {
37 public: 40 public:
38 UbertokenFetcher(Profile* profile, UbertokenConsumer* consumer); 41 UbertokenFetcher(OAuth2TokenService* token_service,
42 UbertokenConsumer* consumer,
43 net::URLRequestContextGetter* request_context);
39 virtual ~UbertokenFetcher(); 44 virtual ~UbertokenFetcher();
40 45
41 // Start fetching the token for |account_id|. 46 // Start fetching the token for |account_id|.
42 virtual void StartFetchingToken(const std::string& account_id); 47 virtual void StartFetchingToken(const std::string& account_id);
43 48
44 // Overriden from GaiaAuthConsumer 49 // Overriden from GaiaAuthConsumer
45 virtual void OnUberAuthTokenSuccess(const std::string& token) OVERRIDE; 50 virtual void OnUberAuthTokenSuccess(const std::string& token) OVERRIDE;
46 virtual void OnUberAuthTokenFailure( 51 virtual void OnUberAuthTokenFailure(
47 const GoogleServiceAuthError& error) OVERRIDE; 52 const GoogleServiceAuthError& error) OVERRIDE;
48 53
49 // Overriden from OAuth2TokenService::Consumer: 54 // Overriden from OAuth2TokenService::Consumer:
50 virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request, 55 virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request,
51 const std::string& access_token, 56 const std::string& access_token,
52 const base::Time& expiration_time) OVERRIDE; 57 const base::Time& expiration_time) OVERRIDE;
53 virtual void OnGetTokenFailure(const OAuth2TokenService::Request* request, 58 virtual void OnGetTokenFailure(const OAuth2TokenService::Request* request,
54 const GoogleServiceAuthError& error) OVERRIDE; 59 const GoogleServiceAuthError& error) OVERRIDE;
55 60
56 private: 61 private:
57 Profile* profile_; 62 OAuth2TokenService* token_service_;
58 UbertokenConsumer* consumer_; 63 UbertokenConsumer* consumer_;
64 net::URLRequestContextGetter* request_context_;
59 scoped_ptr<GaiaAuthFetcher> gaia_auth_fetcher_; 65 scoped_ptr<GaiaAuthFetcher> gaia_auth_fetcher_;
60 scoped_ptr<OAuth2TokenService::Request> access_token_request_; 66 scoped_ptr<OAuth2TokenService::Request> access_token_request_;
61 67
62 DISALLOW_COPY_AND_ASSIGN(UbertokenFetcher); 68 DISALLOW_COPY_AND_ASSIGN(UbertokenFetcher);
63 }; 69 };
64 70
65 #endif // CHROME_BROWSER_SIGNIN_UBERTOKEN_FETCHER_H_ 71 #endif // GOOGLE_APIS_GAIA_UBERTOKEN_FETCHER_H_
OLDNEW
« no previous file with comments | « google_apis/gaia/fake_oauth2_token_service.cc ('k') | google_apis/gaia/ubertoken_fetcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698