Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 "net/base/default_server_bound_cert_store.h" | 5 #include "net/base/default_server_bound_cert_store.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 16 | 16 |
| 17 namespace net { | 17 namespace net { |
| 18 | 18 |
| 19 class MockPersistentStore | 19 class MockPersistentStore |
| 20 : public DefaultServerBoundCertStore::PersistentStore { | 20 : public DefaultServerBoundCertStore::PersistentStore { |
| 21 public: | 21 public: |
| 22 MockPersistentStore(); | 22 MockPersistentStore(); |
| 23 virtual ~MockPersistentStore(); | |
| 24 | 23 |
| 25 // DefaultServerBoundCertStore::PersistentStore implementation. | 24 // DefaultServerBoundCertStore::PersistentStore implementation. |
| 26 virtual bool Load( | 25 virtual bool Load( |
| 27 std::vector<DefaultServerBoundCertStore::ServerBoundCert*>* certs) | 26 std::vector<DefaultServerBoundCertStore::ServerBoundCert*>* certs) |
| 28 OVERRIDE; | 27 OVERRIDE; |
| 29 virtual void AddServerBoundCert( | 28 virtual void AddServerBoundCert( |
| 30 const DefaultServerBoundCertStore::ServerBoundCert& cert) OVERRIDE; | 29 const DefaultServerBoundCertStore::ServerBoundCert& cert) OVERRIDE; |
| 31 virtual void DeleteServerBoundCert( | 30 virtual void DeleteServerBoundCert( |
| 32 const DefaultServerBoundCertStore::ServerBoundCert& cert) OVERRIDE; | 31 const DefaultServerBoundCertStore::ServerBoundCert& cert) OVERRIDE; |
| 33 virtual void SetClearLocalStateOnExit(bool clear_local_state) OVERRIDE; | 32 virtual void SetClearLocalStateOnExit(bool clear_local_state) OVERRIDE; |
| 34 virtual void Flush(const base::Closure& completion_task) OVERRIDE; | 33 virtual void Flush(const base::Closure& completion_task) OVERRIDE; |
| 35 | 34 |
| 36 private: | 35 private: |
| 36 virtual ~MockPersistentStore(); | |
| 37 | |
| 37 typedef std::map<std::string, DefaultServerBoundCertStore::ServerBoundCert> | 38 typedef std::map<std::string, DefaultServerBoundCertStore::ServerBoundCert> |
| 38 ServerBoundCertMap; | 39 ServerBoundCertMap; |
| 39 | 40 |
| 40 ServerBoundCertMap origin_certs_; | 41 ServerBoundCertMap origin_certs_; |
| 41 }; | 42 }; |
| 42 | 43 |
| 43 MockPersistentStore::MockPersistentStore() {} | 44 MockPersistentStore::MockPersistentStore() {} |
| 44 | 45 |
| 45 MockPersistentStore::~MockPersistentStore() {} | 46 MockPersistentStore::~MockPersistentStore() {} |
|
eroman
2012/04/13 18:59:34
nit: can you move this down to match declaration o
| |
| 46 | 47 |
| 47 bool MockPersistentStore::Load( | 48 bool MockPersistentStore::Load( |
| 48 std::vector<DefaultServerBoundCertStore::ServerBoundCert*>* certs) { | 49 std::vector<DefaultServerBoundCertStore::ServerBoundCert*>* certs) { |
| 49 ServerBoundCertMap::iterator it; | 50 ServerBoundCertMap::iterator it; |
| 50 | 51 |
| 51 for (it = origin_certs_.begin(); it != origin_certs_.end(); ++it) { | 52 for (it = origin_certs_.begin(); it != origin_certs_.end(); ++it) { |
| 52 certs->push_back( | 53 certs->push_back( |
| 53 new DefaultServerBoundCertStore::ServerBoundCert(it->second)); | 54 new DefaultServerBoundCertStore::ServerBoundCert(it->second)); |
| 54 } | 55 } |
| 55 | 56 |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 285 base::Time(), | 286 base::Time(), |
| 286 "g", "h"); | 287 "g", "h"); |
| 287 | 288 |
| 288 EXPECT_EQ(4, store.GetCertCount()); | 289 EXPECT_EQ(4, store.GetCertCount()); |
| 289 ServerBoundCertStore::ServerBoundCertList certs; | 290 ServerBoundCertStore::ServerBoundCertList certs; |
| 290 store.GetAllServerBoundCerts(&certs); | 291 store.GetAllServerBoundCerts(&certs); |
| 291 EXPECT_EQ(4u, certs.size()); | 292 EXPECT_EQ(4u, certs.size()); |
| 292 } | 293 } |
| 293 | 294 |
| 294 } // namespace net | 295 } // namespace net |
| OLD | NEW |