BookmarkManager: Fix 'new folder text field size changes on clicking it' issue.
[chromium-blink-merge.git] / chrome / browser / chromeos / certificate_provider / sign_requests.cc
blob092077c95e3c3204cc88e3402a40252c02b3ada5
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 #include "chrome/browser/chromeos/certificate_provider/sign_requests.h"
7 #include "base/callback.h"
9 namespace chromeos {
10 namespace certificate_provider {
12 SignRequests::RequestsState::RequestsState() {}
14 SignRequests::RequestsState::~RequestsState() {}
16 SignRequests::SignRequests() {}
18 SignRequests::~SignRequests() {}
20 int SignRequests::AddRequest(const std::string& extension_id,
21 const net::SSLPrivateKey::SignCallback& callback) {
22 RequestsState& state = extension_to_requests_[extension_id];
23 const int request_id = state.next_free_id++;
24 state.pending_requests[request_id] = callback;
25 return request_id;
28 bool SignRequests::RemoveRequest(const std::string& extension_id,
29 int request_id,
30 net::SSLPrivateKey::SignCallback* callback) {
31 RequestsState& state = extension_to_requests_[extension_id];
32 std::map<int, net::SSLPrivateKey::SignCallback>& pending =
33 state.pending_requests;
34 const auto it = pending.find(request_id);
35 if (it == pending.end())
36 return false;
38 if (callback)
39 *callback = it->second;
40 pending.erase(it);
41 return true;
44 std::vector<net::SSLPrivateKey::SignCallback> SignRequests::RemoveAllRequests(
45 const std::string& extension_id) {
46 std::vector<net::SSLPrivateKey::SignCallback> callbacks;
47 for (const auto& entry :
48 extension_to_requests_[extension_id].pending_requests) {
49 callbacks.push_back(entry.second);
51 extension_to_requests_.erase(extension_id);
52 return callbacks;
55 } // namespace certificate_provider
56 } // namespace chromeos