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

Side by Side Diff: chrome/browser/extensions/api/identity/identity_mint_queue.h

Issue 14270007: Identity API: getAuthToken request queues (token cache prelude) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: fix test fixture init + address code review feedback 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_IDENTITY_IDENTITY_MINT_QUEUE_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_IDENTITY_IDENTITY_MINT_QUEUE_H_
7
8 #include <list>
9 #include <map>
10 #include <set>
11 #include <string>
12
13 namespace extensions {
14
15 // getAuthToken requests are serialized to avoid excessive traffic to
16 // GAIA and to consolidate UI pop-ups. IdentityMintRequestQueue
17 // maitains a set of queues, one for each RequestKey.
18 //
19 // The queue calls StartMintToken on each Request when it reaches the
20 // head of the line.
21 //
22 // The queue does not own Requests. Request pointers must be valid
23 // until they are removed from the queue with RequestComplete.
24 class IdentityMintRequestQueue {
25 public:
26 enum MintType {
27 MINT_TYPE_NONINTERACTIVE,
28 MINT_TYPE_INTERACTIVE
29 };
30
31 IdentityMintRequestQueue();
32 virtual ~IdentityMintRequestQueue();
33
34 class Request {
35 public:
36 virtual ~Request() {}
37 virtual void StartMintToken(IdentityMintRequestQueue::MintType type) = 0;
38 };
39
40 struct RequestKey {
41 RequestKey(IdentityMintRequestQueue::MintType type,
42 const std::string& extension_id,
43 const std::set<std::string> scopes);
44 ~RequestKey();
45 bool operator<(const RequestKey& rhs) const;
46 IdentityMintRequestQueue::MintType type;
47 std::string extension_id;
48 std::set<std::string> scopes;
49 };
50
51 // Adds a request to the queue specified by the id and scopes.
52 void RequestStart(IdentityMintRequestQueue::MintType type,
53 const std::string& extension_id,
54 const std::set<std::string> scopes,
55 IdentityMintRequestQueue::Request* request);
56 // Removes a request from the queue specified by the id and scopes.
57 void RequestComplete(IdentityMintRequestQueue::MintType type,
58 const std::string& extension_id,
59 const std::set<std::string> scopes,
60 IdentityMintRequestQueue::Request* request);
61 bool empty(IdentityMintRequestQueue::MintType type,
62 const std::string& extension_id,
63 const std::set<std::string> scopes) const;
64
65 private:
66 typedef std::list<IdentityMintRequestQueue::Request*> RequestList;
67 std::map<RequestKey, RequestList> request_queue_;
68 };
69
70
71 } // namespace extensions
72
73 #endif // CHROME_BROWSER_EXTENSIONS_API_IDENTITY_IDENTITY_MINT_QUEUE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698