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

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

Issue 649283003: Standardize usage of virtual/override/final in google_apis/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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_ACCOUNT_TRACKER_H_ 5 #ifndef GOOGLE_APIS_GAIA_ACCOUNT_TRACKER_H_
6 #define GOOGLE_APIS_GAIA_ACCOUNT_TRACKER_H_ 6 #define GOOGLE_APIS_GAIA_ACCOUNT_TRACKER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 27 matching lines...) Expand all
38 // The AccountTracker maintains these invariants: 38 // The AccountTracker maintains these invariants:
39 // 1. Events are only fired after the gaia ID has been fetched. 39 // 1. Events are only fired after the gaia ID has been fetched.
40 // 2. Add/Remove and SignIn/SignOut pairs are always generated in order. 40 // 2. Add/Remove and SignIn/SignOut pairs are always generated in order.
41 // 3. SignIn follows Add, and there will be a SignOut between SignIn & Remove. 41 // 3. SignIn follows Add, and there will be a SignOut between SignIn & Remove.
42 // 4. If there is no primary account, there are no other accounts. 42 // 4. If there is no primary account, there are no other accounts.
43 class AccountTracker : public OAuth2TokenService::Observer, 43 class AccountTracker : public OAuth2TokenService::Observer,
44 public IdentityProvider::Observer { 44 public IdentityProvider::Observer {
45 public: 45 public:
46 AccountTracker(IdentityProvider* identity_provider, 46 AccountTracker(IdentityProvider* identity_provider,
47 net::URLRequestContextGetter* request_context_getter); 47 net::URLRequestContextGetter* request_context_getter);
48 virtual ~AccountTracker(); 48 ~AccountTracker() override;
49 49
50 class Observer { 50 class Observer {
51 public: 51 public:
52 virtual void OnAccountAdded(const AccountIds& ids) = 0; 52 virtual void OnAccountAdded(const AccountIds& ids) = 0;
53 virtual void OnAccountRemoved(const AccountIds& ids) = 0; 53 virtual void OnAccountRemoved(const AccountIds& ids) = 0;
54 virtual void OnAccountSignInChanged(const AccountIds& ids, 54 virtual void OnAccountSignInChanged(const AccountIds& ids,
55 bool is_signed_in) = 0; 55 bool is_signed_in) = 0;
56 }; 56 };
57 57
58 void Shutdown(); 58 void Shutdown();
59 59
60 void AddObserver(Observer* observer); 60 void AddObserver(Observer* observer);
61 void RemoveObserver(Observer* observer); 61 void RemoveObserver(Observer* observer);
62 62
63 // Returns the list of accounts that are signed in, and for which gaia IDs 63 // Returns the list of accounts that are signed in, and for which gaia IDs
64 // have been fetched. The primary account for the profile will be first 64 // have been fetched. The primary account for the profile will be first
65 // in the vector. Additional accounts will be in order of their gaia IDs. 65 // in the vector. Additional accounts will be in order of their gaia IDs.
66 std::vector<AccountIds> GetAccounts() const; 66 std::vector<AccountIds> GetAccounts() const;
67 AccountIds FindAccountIdsByGaiaId(const std::string& gaia_id); 67 AccountIds FindAccountIdsByGaiaId(const std::string& gaia_id);
68 68
69 // OAuth2TokenService::Observer implementation. 69 // OAuth2TokenService::Observer implementation.
70 virtual void OnRefreshTokenAvailable(const std::string& account_key) override; 70 void OnRefreshTokenAvailable(const std::string& account_key) override;
71 virtual void OnRefreshTokenRevoked(const std::string& account_key) override; 71 void OnRefreshTokenRevoked(const std::string& account_key) override;
72 72
73 void OnUserInfoFetchSuccess(AccountIdFetcher* fetcher, 73 void OnUserInfoFetchSuccess(AccountIdFetcher* fetcher,
74 const std::string& gaia_id); 74 const std::string& gaia_id);
75 void OnUserInfoFetchFailure(AccountIdFetcher* fetcher); 75 void OnUserInfoFetchFailure(AccountIdFetcher* fetcher);
76 76
77 // IdentityProvider::Observer implementation. 77 // IdentityProvider::Observer implementation.
78 virtual void OnActiveAccountLogin() override; 78 void OnActiveAccountLogin() override;
79 virtual void OnActiveAccountLogout() override; 79 void OnActiveAccountLogout() override;
80 80
81 // Sets the state of an account. Does not fire notifications. 81 // Sets the state of an account. Does not fire notifications.
82 void SetAccountStateForTest(AccountIds ids, bool is_signed_in); 82 void SetAccountStateForTest(AccountIds ids, bool is_signed_in);
83 83
84 IdentityProvider* identity_provider() { return identity_provider_; } 84 IdentityProvider* identity_provider() { return identity_provider_; }
85 85
86 // Indicates if all user information has been fetched. If the result is false, 86 // Indicates if all user information has been fetched. If the result is false,
87 // there are still unfininshed fetchers. 87 // there are still unfininshed fetchers.
88 virtual bool IsAllUserInfoFetched() const; 88 virtual bool IsAllUserInfoFetched() const;
89 89
(...skipping 23 matching lines...) Expand all
113 bool shutdown_called_; 113 bool shutdown_called_;
114 }; 114 };
115 115
116 class AccountIdFetcher : public OAuth2TokenService::Consumer, 116 class AccountIdFetcher : public OAuth2TokenService::Consumer,
117 public gaia::GaiaOAuthClient::Delegate { 117 public gaia::GaiaOAuthClient::Delegate {
118 public: 118 public:
119 AccountIdFetcher(OAuth2TokenService* token_service, 119 AccountIdFetcher(OAuth2TokenService* token_service,
120 net::URLRequestContextGetter* request_context_getter, 120 net::URLRequestContextGetter* request_context_getter,
121 AccountTracker* tracker, 121 AccountTracker* tracker,
122 const std::string& account_key); 122 const std::string& account_key);
123 virtual ~AccountIdFetcher(); 123 ~AccountIdFetcher() override;
124 124
125 const std::string& account_key() { return account_key_; } 125 const std::string& account_key() { return account_key_; }
126 126
127 void Start(); 127 void Start();
128 128
129 // OAuth2TokenService::Consumer implementation. 129 // OAuth2TokenService::Consumer implementation.
130 virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request, 130 void OnGetTokenSuccess(const OAuth2TokenService::Request* request,
131 const std::string& access_token, 131 const std::string& access_token,
132 const base::Time& expiration_time) override; 132 const base::Time& expiration_time) override;
133 virtual void OnGetTokenFailure(const OAuth2TokenService::Request* request, 133 void OnGetTokenFailure(const OAuth2TokenService::Request* request,
134 const GoogleServiceAuthError& error) override; 134 const GoogleServiceAuthError& error) override;
135 135
136 // gaia::GaiaOAuthClient::Delegate implementation. 136 // gaia::GaiaOAuthClient::Delegate implementation.
137 virtual void OnGetUserIdResponse(const std::string& gaia_id) override; 137 void OnGetUserIdResponse(const std::string& gaia_id) override;
138 virtual void OnOAuthError() override; 138 void OnOAuthError() override;
139 virtual void OnNetworkError(int response_code) override; 139 void OnNetworkError(int response_code) override;
140 140
141 private: 141 private:
142 OAuth2TokenService* token_service_; 142 OAuth2TokenService* token_service_;
143 net::URLRequestContextGetter* request_context_getter_; 143 net::URLRequestContextGetter* request_context_getter_;
144 AccountTracker* tracker_; 144 AccountTracker* tracker_;
145 const std::string account_key_; 145 const std::string account_key_;
146 146
147 scoped_ptr<OAuth2TokenService::Request> login_token_request_; 147 scoped_ptr<OAuth2TokenService::Request> login_token_request_;
148 scoped_ptr<gaia::GaiaOAuthClient> gaia_oauth_client_; 148 scoped_ptr<gaia::GaiaOAuthClient> gaia_oauth_client_;
149 }; 149 };
150 150
151 } // namespace extensions 151 } // namespace extensions
152 152
153 #endif // GOOGLE_APIS_GAIA_ACCOUNT_TRACKER_H_ 153 #endif // GOOGLE_APIS_GAIA_ACCOUNT_TRACKER_H_
OLDNEW
« no previous file with comments | « google_apis/drive/request_sender_unittest.cc ('k') | google_apis/gaia/account_tracker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698