OLD | NEW |
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 #include "chrome/browser/chromeos/certificate_provider/sign_requests.h" | 5 #include "chrome/browser/chromeos/certificate_provider/sign_requests.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 | 8 |
9 namespace chromeos { | 9 namespace chromeos { |
10 namespace certificate_provider { | 10 namespace certificate_provider { |
(...skipping 17 matching lines...) Expand all Loading... |
28 bool SignRequests::RemoveRequest(const std::string& extension_id, | 28 bool SignRequests::RemoveRequest(const std::string& extension_id, |
29 int request_id, | 29 int request_id, |
30 net::SSLPrivateKey::SignCallback* callback) { | 30 net::SSLPrivateKey::SignCallback* callback) { |
31 RequestsState& state = extension_to_requests_[extension_id]; | 31 RequestsState& state = extension_to_requests_[extension_id]; |
32 std::map<int, net::SSLPrivateKey::SignCallback>& pending = | 32 std::map<int, net::SSLPrivateKey::SignCallback>& pending = |
33 state.pending_requests; | 33 state.pending_requests; |
34 const auto it = pending.find(request_id); | 34 const auto it = pending.find(request_id); |
35 if (it == pending.end()) | 35 if (it == pending.end()) |
36 return false; | 36 return false; |
37 | 37 |
38 *callback = it->second; | 38 if (callback) |
| 39 *callback = it->second; |
39 pending.erase(it); | 40 pending.erase(it); |
40 return true; | 41 return true; |
41 } | 42 } |
42 | 43 |
43 std::vector<net::SSLPrivateKey::SignCallback> SignRequests::RemoveAllRequests( | 44 std::vector<net::SSLPrivateKey::SignCallback> SignRequests::RemoveAllRequests( |
44 const std::string& extension_id) { | 45 const std::string& extension_id) { |
45 std::vector<net::SSLPrivateKey::SignCallback> callbacks; | 46 std::vector<net::SSLPrivateKey::SignCallback> callbacks; |
46 for (const auto& entry : | 47 for (const auto& entry : |
47 extension_to_requests_[extension_id].pending_requests) { | 48 extension_to_requests_[extension_id].pending_requests) { |
48 callbacks.push_back(entry.second); | 49 callbacks.push_back(entry.second); |
49 } | 50 } |
50 extension_to_requests_.erase(extension_id); | 51 extension_to_requests_.erase(extension_id); |
51 return callbacks; | 52 return callbacks; |
52 } | 53 } |
53 | 54 |
54 } // namespace certificate_provider | 55 } // namespace certificate_provider |
55 } // namespace chromeos | 56 } // namespace chromeos |
OLD | NEW |