OLD | NEW |
| (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 #include "chrome/browser/browsing_data/mock_browsing_data_server_bound_cert_help
er.h" | |
6 | |
7 #include "base/logging.h" | |
8 | |
9 MockBrowsingDataServerBoundCertHelper::MockBrowsingDataServerBoundCertHelper() | |
10 : BrowsingDataServerBoundCertHelper() {} | |
11 | |
12 MockBrowsingDataServerBoundCertHelper:: | |
13 ~MockBrowsingDataServerBoundCertHelper() {} | |
14 | |
15 void MockBrowsingDataServerBoundCertHelper::StartFetching( | |
16 const FetchResultCallback& callback) { | |
17 callback_ = callback; | |
18 } | |
19 | |
20 void MockBrowsingDataServerBoundCertHelper::DeleteServerBoundCert( | |
21 const std::string& server_id) { | |
22 CHECK(server_bound_certs_.find(server_id) != server_bound_certs_.end()); | |
23 server_bound_certs_[server_id] = false; | |
24 } | |
25 | |
26 void MockBrowsingDataServerBoundCertHelper::AddServerBoundCertSample( | |
27 const std::string& server_id) { | |
28 DCHECK(server_bound_certs_.find(server_id) == server_bound_certs_.end()); | |
29 server_bound_cert_list_.push_back( | |
30 net::ServerBoundCertStore::ServerBoundCert( | |
31 server_id, base::Time(), base::Time(), "key", "cert")); | |
32 server_bound_certs_[server_id] = true; | |
33 } | |
34 | |
35 void MockBrowsingDataServerBoundCertHelper::Notify() { | |
36 net::ServerBoundCertStore::ServerBoundCertList cert_list; | |
37 for (net::ServerBoundCertStore::ServerBoundCertList::iterator i = | |
38 server_bound_cert_list_.begin(); | |
39 i != server_bound_cert_list_.end(); ++i) { | |
40 if (server_bound_certs_[i->server_identifier()]) | |
41 cert_list.push_back(*i); | |
42 } | |
43 callback_.Run(cert_list); | |
44 } | |
45 | |
46 void MockBrowsingDataServerBoundCertHelper::Reset() { | |
47 for (std::map<const std::string, bool>::iterator i = | |
48 server_bound_certs_.begin(); | |
49 i != server_bound_certs_.end(); ++i) | |
50 i->second = true; | |
51 } | |
52 | |
53 bool MockBrowsingDataServerBoundCertHelper::AllDeleted() { | |
54 for (std::map<const std::string, bool>::const_iterator i = | |
55 server_bound_certs_.begin(); | |
56 i != server_bound_certs_.end(); ++i) | |
57 if (i->second) | |
58 return false; | |
59 return true; | |
60 } | |
OLD | NEW |