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

Side by Side Diff: chrome/browser/signin/account_service_flag_fetcher.h

Issue 284763004: Create AccountServiceFlagFetcher which downloads an account's Gaia service flags. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add missing OVERRIDEs Created 6 years, 7 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_SIGNIN_ACCOUNT_SERVICE_FLAG_FETCHER_H_
6 #define CHROME_BROWSER_SIGNIN_ACCOUNT_SERVICE_FLAG_FETCHER_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "base/callback.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "google_apis/gaia/gaia_auth_consumer.h"
14 #include "google_apis/gaia/gaia_auth_fetcher.h"
15 #include "google_apis/gaia/oauth2_token_service.h"
16
17 class Profile;
18
19 // Downloads an account's list of Gaia service flags.
20 class AccountServiceFlagFetcher : public GaiaAuthConsumer,
Bernhard Bauer 2014/05/16 08:19:38 Gaia account maybe? This is very specific to Gaia.
Marc Treib 2014/05/20 10:46:40 Drew, WDYT? "Account" is used as a synonym for "Ga
Bernhard Bauer 2014/05/20 12:35:27 Oh, right. OK, if account in here means Gaia accou
21 public OAuth2TokenService::Observer,
22 public OAuth2TokenService::Consumer {
23 public:
24 // Callback for Start() below. If the flag download is successful, this will
25 // return the list of service flags that are set for the primary account.
26 typedef base::Callback<void(const std::vector<std::string>& /* flags */)>
Andrew T Wilson (Slow) 2014/05/16 08:44:44 What do you do in case of error?
Marc Treib 2014/05/20 10:46:40 I've added a status enum to the callback to report
27 Callback;
28
29 explicit AccountServiceFlagFetcher(Profile* profile);
Andrew T Wilson (Slow) 2014/05/16 08:44:44 Please put this in components/signin. To do this,
Marc Treib 2014/05/20 10:46:40 Done. The SigninManager actually isn't required, i
30 virtual ~AccountServiceFlagFetcher();
31
32 // Starts fetching the flags. Must not be called again while a previous call
33 // is still pending. The callback will be called iff the flags are
34 // successfully fetched.
35 void Start(const Callback& callback);
36
37 // Cancels the pending request (if any).
38 void Cancel();
Andrew T Wilson (Slow) 2014/05/16 08:44:44 Do you have to call Cancel() before destroying the
Marc Treib 2014/05/20 10:46:40 Okay, now the constructor immediately starts the r
39
40 // Returns whether a previous call to Start() is still pending.
41 bool IsPending() const;
42
43 private:
44 void StartFetchingOAuth2AccessToken(const std::string& account_id);
45
46 // Overridden from OAuth2TokenService::Observer:
47 virtual void OnRefreshTokenAvailable(const std::string& account_id) OVERRIDE;
48
49 // Overridden from OAuth2TokenService::Consumer:
50 virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request,
51 const std::string& access_token,
52 const base::Time& expiration_time) OVERRIDE;
53 virtual void OnGetTokenFailure(const OAuth2TokenService::Request* request,
54 const GoogleServiceAuthError& error) OVERRIDE;
55
56 // Overridden from GaiaAuthConsumer:
57 virtual void OnClientLoginSuccess(const ClientLoginResult& result) OVERRIDE;
58 virtual void OnClientLoginFailure(const GoogleServiceAuthError& error)
59 OVERRIDE;
60 virtual void OnGetUserInfoSuccess(const UserInfoMap& data) OVERRIDE;
61 virtual void OnGetUserInfoFailure(const GoogleServiceAuthError& error)
62 OVERRIDE;
63
64 Profile* profile_;
65
66 Callback callback_;
67
68 scoped_ptr<OAuth2TokenService::Request> oauth2_access_token_request_;
69 GaiaAuthFetcher gaia_auth_fetcher_;
70 };
71
72 #endif // CHROME_BROWSER_SIGNIN_ACCOUNT_SERVICE_FLAG_FETCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698