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

Side by Side Diff: trunk/src/chrome/browser/signin/oauth2_token_service.h

Issue 12782018: Revert 190531 "Get OAuth2TokenService working on Android." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 8 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
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_H_ 5 #ifndef CHROME_BROWSER_SIGNIN_OAUTH2_TOKEN_SERVICE_H_
6 #define CHROME_BROWSER_SIGNIN_OAUTH2_TOKEN_SERVICE_H_ 6 #define CHROME_BROWSER_SIGNIN_OAUTH2_TOKEN_SERVICE_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 // deleted. 92 // deleted.
93 // Note the refresh token has been collected from TokenService when this 93 // Note the refresh token has been collected from TokenService when this
94 // method returns, and the request can continue even if TokenService clears 94 // method returns, and the request can continue even if TokenService clears
95 // its tokens after this method returns. This means that outstanding 95 // its tokens after this method returns. This means that outstanding
96 // StartRequest actions will still complete even if the user signs out in the 96 // StartRequest actions will still complete even if the user signs out in the
97 // meantime. 97 // meantime.
98 virtual scoped_ptr<Request> StartRequest( 98 virtual scoped_ptr<Request> StartRequest(
99 const ScopeSet& scopes, 99 const ScopeSet& scopes,
100 OAuth2TokenService::Consumer* consumer); 100 OAuth2TokenService::Consumer* consumer);
101 101
102 // Mark an OAuth2 access token as invalid. This should be done if the token
103 // was received from this class, but was not accepted by the server (e.g.,
104 // the server returned 401 Unauthorized). The token will be removed from the
105 // cache for the given scopes.
106 void InvalidateToken(const ScopeSet& scopes,
107 const std::string& invalid_token);
108
109 // content::NotificationObserver 102 // content::NotificationObserver
110 virtual void Observe(int type, 103 virtual void Observe(int type,
111 const content::NotificationSource& source, 104 const content::NotificationSource& source,
112 const content::NotificationDetails& details) OVERRIDE; 105 const content::NotificationDetails& details) OVERRIDE;
113 106
114 // SigninGlobalError::AuthStatusProvider implementation. 107 // SigninGlobalError::AuthStatusProvider implementation.
115 virtual GoogleServiceAuthError GetAuthStatus() const OVERRIDE; 108 virtual GoogleServiceAuthError GetAuthStatus() const OVERRIDE;
116 109
117 private: 110 private:
118 // Class that fetches an OAuth2 access token for a given set of scopes and 111 // Class that fetches an OAuth2 access token for a given set of scopes and
119 // OAuth2 refresh token. 112 // OAuth2 refresh token.
120 class Fetcher; 113 class Fetcher;
121 friend class Fetcher; 114 friend class Fetcher;
122 // Implementation of Request. 115 // Implementation of Request.
123 class RequestImpl; 116 class RequestImpl;
124 117
125 // Informs the consumer of |request| fetch results. 118 // Informs the consumer of |request| fetch results.
126 static void InformConsumer( 119 static void InformConsumer(
127 base::WeakPtr<OAuth2TokenService::RequestImpl> request, 120 base::WeakPtr<OAuth2TokenService::RequestImpl> request,
128 const GoogleServiceAuthError& error, 121 GoogleServiceAuthError error,
129 const std::string& access_token, 122 std::string access_token,
130 const base::Time& expiration_date); 123 base::Time expiration_date);
131 124
132 // Struct that contains the information of an OAuth2 access token. 125 // Struct that contains the information of an OAuth2 access token.
133 struct CacheEntry { 126 struct CacheEntry {
134 std::string access_token; 127 std::string access_token;
135 base::Time expiration_date; 128 base::Time expiration_date;
136 }; 129 };
137 130
138 // Returns a currently valid OAuth2 access token for the given set of scopes, 131 // Returns a currently valid OAuth2 access token for the given set of scopes,
139 // or NULL if none have been cached. Note the user of this method should 132 // or NULL if none have been cached. Note the user of this method should
140 // ensure no entry with the same |scopes| is added before the usage of the 133 // ensure no entry with the same |scopes| is added before the usage of the
141 // returned entry is done. 134 // returned entry is done.
142 const CacheEntry* GetCacheEntry(const ScopeSet& scopes); 135 const CacheEntry* GetCacheEntry(const ScopeSet& scopes);
143
144 // Registers a new access token in the cache if |refresh_token| is the one 136 // Registers a new access token in the cache if |refresh_token| is the one
145 // currently held by TokenService. 137 // currently held by TokenService.
146 void RegisterCacheEntry(const std::string& refresh_token, 138 void RegisterCacheEntry(const std::string& refresh_token,
147 const ScopeSet& scopes, 139 const ScopeSet& scopes,
148 const std::string& access_token, 140 const std::string& access_token,
149 const base::Time& expiration_date); 141 const base::Time& expiration_date);
150 142
151 // Removes an access token for the given set of scopes from the cache.
152 // Returns true if the entry was removed, otherwise false.
153 bool RemoveCacheEntry(const OAuth2TokenService::ScopeSet& scopes,
154 const std::string& token_to_remove);
155
156
157 // Called when |fetcher| finishes fetching. 143 // Called when |fetcher| finishes fetching.
158 void OnFetchComplete(Fetcher* fetcher); 144 void OnFetchComplete(Fetcher* fetcher);
159 145
160 // Updates the internal cache of the result from the most-recently-completed 146 // Updates the internal cache of the result from the most-recently-completed
161 // auth request (used for reporting errors to the user). 147 // auth request (used for reporting errors to the user).
162 void UpdateAuthError(const GoogleServiceAuthError& error); 148 void UpdateAuthError(const GoogleServiceAuthError& error);
163 149
164 // The profile with which this instance was initialized, or NULL. 150 // The profile with which this instance was initialized, or NULL.
165 Profile* profile_; 151 Profile* profile_;
166 152
(...skipping 14 matching lines...) Expand all
181 // token using these parameters. 167 // token using these parameters.
182 std::map<FetchParameters, Fetcher*> pending_fetchers_; 168 std::map<FetchParameters, Fetcher*> pending_fetchers_;
183 169
184 // Registrar for notifications from the TokenService. 170 // Registrar for notifications from the TokenService.
185 content::NotificationRegistrar registrar_; 171 content::NotificationRegistrar registrar_;
186 172
187 DISALLOW_COPY_AND_ASSIGN(OAuth2TokenService); 173 DISALLOW_COPY_AND_ASSIGN(OAuth2TokenService);
188 }; 174 };
189 175
190 #endif // CHROME_BROWSER_SIGNIN_OAUTH2_TOKEN_SERVICE_H_ 176 #endif // CHROME_BROWSER_SIGNIN_OAUTH2_TOKEN_SERVICE_H_
OLDNEW
« no previous file with comments | « trunk/src/chrome/browser/history/web_history_service.cc ('k') | trunk/src/chrome/browser/signin/oauth2_token_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698