1 // Copyright 2015 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.
5 #ifndef CHROME_BROWSER_CHROMEOS_CERTIFICATE_PROVIDER_SIGN_REQUESTS_H_
6 #define CHROME_BROWSER_CHROMEOS_CERTIFICATE_PROVIDER_SIGN_REQUESTS_H_
12 #include "base/macros.h"
13 #include "net/ssl/ssl_private_key.h"
16 namespace certificate_provider
{
23 // Returns the id of the new request. The returned request id is specific to
24 // the given extension.
25 int AddRequest(const std::string
& extension_id
,
26 const net::SSLPrivateKey::SignCallback
& callback
);
28 // Returns false if no request with the given id for |extension_id|
29 // could be found. Otherwise removes the request and sets |callback| to the
30 // callback that was provided with AddRequest(). |callback| may be a nullptr.
31 bool RemoveRequest(const std::string
& extension_id
,
33 net::SSLPrivateKey::SignCallback
* callback
);
35 // Remove all pending requests for this extension and return their
37 std::vector
<net::SSLPrivateKey::SignCallback
> RemoveAllRequests(
38 const std::string
& extension_id
);
41 // Holds state of all sign requests to a single extension.
42 struct RequestsState
{
46 // Maps from request id to the SignCallback that must be called with the
47 // signature or error.
48 std::map
<int, net::SSLPrivateKey::SignCallback
> pending_requests
;
50 // The request id that will be used for the next sign request to this
55 // Contains the state of all sign requests per extension.
56 std::map
<std::string
, RequestsState
> extension_to_requests_
;
58 DISALLOW_COPY_AND_ASSIGN(SignRequests
);
61 } // namespace certificate_provider
62 } // namespace chromeos
64 #endif // CHROME_BROWSER_CHROMEOS_CERTIFICATE_PROVIDER_SIGN_REQUESTS_H_