diff options
author | courage@chromium.org <courage@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-03 03:28:44 +0000 |
---|---|---|
committer | courage@chromium.org <courage@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-03 03:28:44 +0000 |
commit | 51c5e6c62d3dbc1fe36b2b2f2930a762dea29ec4 (patch) | |
tree | 3a075e643cd7435dfb716253f59c179dd264618e /chrome/browser/extensions/api/identity/identity_mint_queue.h | |
parent | f6da4513e9d3549da419a6ce5abfb3265162c3e8 (diff) | |
download | chromium_src-51c5e6c62d3dbc1fe36b2b2f2930a762dea29ec4.zip chromium_src-51c5e6c62d3dbc1fe36b2b2f2930a762dea29ec4.tar.gz chromium_src-51c5e6c62d3dbc1fe36b2b2f2930a762dea29ec4.tar.bz2 |
Identity API: add multi-account support to token cache and request queues
This change is part of adding chrome.identity.getAccountAndAuthToken.
The token cache in IdentityAPI and the IdentityMintRequestQueue both had
separate code for tranlating the same API parameters to a lookup key for
their internal maps. They now both use ExtensionTokenKey.
The ExtensionTokenKey includes an account_id field which will allow its
users to support multiple accounts in one profile. All callers currently
use the primary account ID, but will be updated in a future change.
This change also fixes a bug where getAuthToken would return tokens
for the wrong user after switching the account on the profile.
BUG=324874, 322284
Review URL: https://codereview.chromium.org/99173004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@238292 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/api/identity/identity_mint_queue.h')
-rw-r--r-- | chrome/browser/extensions/api/identity/identity_mint_queue.h | 36 |
1 files changed, 14 insertions, 22 deletions
diff --git a/chrome/browser/extensions/api/identity/identity_mint_queue.h b/chrome/browser/extensions/api/identity/identity_mint_queue.h index f014998..a1ca89b 100644 --- a/chrome/browser/extensions/api/identity/identity_mint_queue.h +++ b/chrome/browser/extensions/api/identity/identity_mint_queue.h @@ -10,6 +10,8 @@ #include <set> #include <string> +#include "chrome/browser/extensions/api/identity/extension_token_key.h" + namespace extensions { // getAuthToken requests are serialized to avoid excessive traffic to @@ -37,36 +39,26 @@ class IdentityMintRequestQueue { virtual void StartMintToken(IdentityMintRequestQueue::MintType type) = 0; }; - struct RequestKey { - RequestKey(IdentityMintRequestQueue::MintType type, - const std::string& extension_id, - const std::set<std::string> scopes); - ~RequestKey(); - bool operator<(const RequestKey& rhs) const; - IdentityMintRequestQueue::MintType type; - std::string extension_id; - std::set<std::string> scopes; - }; - - // Adds a request to the queue specified by the id and scopes. + // Adds a request to the queue specified by the token key. void RequestStart(IdentityMintRequestQueue::MintType type, - const std::string& extension_id, - const std::set<std::string> scopes, + const ExtensionTokenKey& key, IdentityMintRequestQueue::Request* request); - // Removes a request from the queue specified by the id and scopes. + // Removes a request from the queue specified by the token key. void RequestComplete(IdentityMintRequestQueue::MintType type, - const std::string& extension_id, - const std::set<std::string> scopes, + const ExtensionTokenKey& key, IdentityMintRequestQueue::Request* request); bool empty(IdentityMintRequestQueue::MintType type, - const std::string& extension_id, - const std::set<std::string> scopes) const; + const ExtensionTokenKey& key); private: - typedef std::list<IdentityMintRequestQueue::Request*> RequestList; - std::map<RequestKey, RequestList> request_queue_; -}; + typedef std::list<IdentityMintRequestQueue::Request*> RequestQueue; + typedef std::map<const ExtensionTokenKey, RequestQueue> RequestQueueMap; + + RequestQueueMap& GetRequestQueueMap(IdentityMintRequestQueue::MintType type); + RequestQueueMap interactive_request_queue_map_; + RequestQueueMap noninteractive_request_queue_map_; +}; } // namespace extensions |