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

Side by Side Diff: chrome/browser/chromeos/certificate_provider/certificate_requests.h

Issue 2937553003: Make CertificateProviderService vend ClientCertIdentities directly. (Closed)
Patch Set: review changes for comments 11 & 12 Created 3 years, 6 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 2015 The Chromium Authors. All rights reserved. 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 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_CHROMEOS_CERTIFICATE_PROVIDER_CERTIFICATE_REQUESTS_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_CERTIFICATE_PROVIDER_CERTIFICATE_REQUESTS_H_
6 #define CHROME_BROWSER_CHROMEOS_CERTIFICATE_PROVIDER_CERTIFICATE_REQUESTS_H_ 6 #define CHROME_BROWSER_CHROMEOS_CERTIFICATE_PROVIDER_CERTIFICATE_REQUESTS_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/callback_forward.h" 13 #include "base/callback_forward.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "chrome/browser/chromeos/certificate_provider/certificate_info.h" 15 #include "chrome/browser/chromeos/certificate_provider/certificate_info.h"
16 #include "net/cert/x509_certificate.h" 16 #include "net/ssl/client_cert_identity.h"
17 17
18 namespace chromeos { 18 namespace chromeos {
19 namespace certificate_provider { 19 namespace certificate_provider {
20 20
21 class CertificateRequests { 21 class CertificateRequests {
22 public: 22 public:
23 CertificateRequests(); 23 CertificateRequests();
24 ~CertificateRequests(); 24 ~CertificateRequests();
25 25
26 // Returns the id of the new request. |callback| will be stored with this 26 // Returns the id of the new request. |callback| will be stored with this
27 // request and be returned by RemoveRequest(). |timeout_callback| will be 27 // request and be returned by RemoveRequest(). |timeout_callback| will be
28 // called with the request id if this request times out before 28 // called with the request id if this request times out before
29 // SetCertificates() was called for all extensions in |extension_ids|. 29 // SetCertificates() was called for all extensions in |extension_ids|.
30 int AddRequest( 30 int AddRequest(
31 const std::vector<std::string>& extension_ids, 31 const std::vector<std::string>& extension_ids,
32 const base::Callback<void(const net::CertificateList&)>& callback, 32 const base::Callback<void(net::ClientCertIdentityList)>& callback,
33 const base::Callback<void(int)>& timeout_callback); 33 const base::Callback<void(int)>& timeout_callback);
34 34
35 // Returns whether this reply was expected, i.e. the request with |request_id| 35 // Returns whether this reply was expected, i.e. the request with |request_id|
36 // was waiting for a reply from this extension. If it was expected, the 36 // was waiting for a reply from this extension. If it was expected, the
37 // certificates are stored and |completed| is set to whether this request has 37 // certificates are stored and |completed| is set to whether this request has
38 // no more pending replies. Otherwise |completed| will be set to false. 38 // no more pending replies. Otherwise |completed| will be set to false.
39 bool SetCertificates(const std::string& extension_id, 39 bool SetCertificates(const std::string& extension_id,
40 int request_id, 40 int request_id,
41 const CertificateInfoList& certificate_infos, 41 const CertificateInfoList& certificate_infos,
42 bool* completed); 42 bool* completed);
43 43
44 // If this request is pending, stores the collected certificates in 44 // If this request is pending, stores the collected certificates in
45 // |certificates|, sets |callback|, drops the request and returns true. 45 // |certificates|, sets |callback|, drops the request and returns true.
46 // Otherwise returns false. 46 // Otherwise returns false.
47 bool RemoveRequest( 47 bool RemoveRequest(
48 int request_id, 48 int request_id,
49 std::map<std::string, CertificateInfoList>* certificates, 49 std::map<std::string, CertificateInfoList>* certificates,
50 base::Callback<void(const net::CertificateList&)>* callback); 50 base::Callback<void(net::ClientCertIdentityList)>* callback);
51 51
52 // Removes this extension from all pending requests and returns the ids of 52 // Removes this extension from all pending requests and returns the ids of
53 // all completed requests. 53 // all completed requests.
54 std::vector<int> DropExtension(const std::string& extension_id); 54 std::vector<int> DropExtension(const std::string& extension_id);
55 55
56 private: 56 private:
57 struct CertificateRequestState; 57 struct CertificateRequestState;
58 58
59 std::map<int, std::unique_ptr<CertificateRequestState>> requests_; 59 std::map<int, std::unique_ptr<CertificateRequestState>> requests_;
60 int next_free_request_id_ = 0; 60 int next_free_request_id_ = 0;
61 61
62 DISALLOW_COPY_AND_ASSIGN(CertificateRequests); 62 DISALLOW_COPY_AND_ASSIGN(CertificateRequests);
63 }; 63 };
64 64
65 } // namespace certificate_provider 65 } // namespace certificate_provider
66 } // namespace chromeos 66 } // namespace chromeos
67 67
68 #endif // CHROME_BROWSER_CHROMEOS_CERTIFICATE_PROVIDER_CERTIFICATE_REQUESTS_H_ 68 #endif // CHROME_BROWSER_CHROMEOS_CERTIFICATE_PROVIDER_CERTIFICATE_REQUESTS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698