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

Side by Side Diff: net/base/default_server_bound_cert_store_unittest.cc

Issue 10066045: RefCounted types should not have public destructors, net/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Deprecated cookiestore fix Created 8 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « net/base/default_server_bound_cert_store.cc ('k') | net/base/file_stream_net_log_parameters.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
35 protected:
36 virtual ~MockPersistentStore();
37
36 private: 38 private:
37 typedef std::map<std::string, DefaultServerBoundCertStore::ServerBoundCert> 39 typedef std::map<std::string, DefaultServerBoundCertStore::ServerBoundCert>
38 ServerBoundCertMap; 40 ServerBoundCertMap;
39 41
40 ServerBoundCertMap origin_certs_; 42 ServerBoundCertMap origin_certs_;
41 }; 43 };
42 44
43 MockPersistentStore::MockPersistentStore() {} 45 MockPersistentStore::MockPersistentStore() {}
44 46
45 MockPersistentStore::~MockPersistentStore() {}
46
47 bool MockPersistentStore::Load( 47 bool MockPersistentStore::Load(
48 std::vector<DefaultServerBoundCertStore::ServerBoundCert*>* certs) { 48 std::vector<DefaultServerBoundCertStore::ServerBoundCert*>* certs) {
49 ServerBoundCertMap::iterator it; 49 ServerBoundCertMap::iterator it;
50 50
51 for (it = origin_certs_.begin(); it != origin_certs_.end(); ++it) { 51 for (it = origin_certs_.begin(); it != origin_certs_.end(); ++it) {
52 certs->push_back( 52 certs->push_back(
53 new DefaultServerBoundCertStore::ServerBoundCert(it->second)); 53 new DefaultServerBoundCertStore::ServerBoundCert(it->second));
54 } 54 }
55 55
56 return true; 56 return true;
57 } 57 }
58 58
59 void MockPersistentStore::AddServerBoundCert( 59 void MockPersistentStore::AddServerBoundCert(
60 const DefaultServerBoundCertStore::ServerBoundCert& cert) { 60 const DefaultServerBoundCertStore::ServerBoundCert& cert) {
61 origin_certs_[cert.server_identifier()] = cert; 61 origin_certs_[cert.server_identifier()] = cert;
62 } 62 }
63 63
64 void MockPersistentStore::DeleteServerBoundCert( 64 void MockPersistentStore::DeleteServerBoundCert(
65 const DefaultServerBoundCertStore::ServerBoundCert& cert) { 65 const DefaultServerBoundCertStore::ServerBoundCert& cert) {
66 origin_certs_.erase(cert.server_identifier()); 66 origin_certs_.erase(cert.server_identifier());
67 } 67 }
68 68
69 void MockPersistentStore::SetClearLocalStateOnExit(bool clear_local_state) {} 69 void MockPersistentStore::SetClearLocalStateOnExit(bool clear_local_state) {}
70 70
71 void MockPersistentStore::Flush(const base::Closure& completion_task) { 71 void MockPersistentStore::Flush(const base::Closure& completion_task) {
72 NOTREACHED(); 72 NOTREACHED();
73 } 73 }
74 74
75 MockPersistentStore::~MockPersistentStore() {}
76
75 TEST(DefaultServerBoundCertStoreTest, TestLoading) { 77 TEST(DefaultServerBoundCertStoreTest, TestLoading) {
76 scoped_refptr<MockPersistentStore> persistent_store(new MockPersistentStore); 78 scoped_refptr<MockPersistentStore> persistent_store(new MockPersistentStore);
77 79
78 persistent_store->AddServerBoundCert( 80 persistent_store->AddServerBoundCert(
79 DefaultServerBoundCertStore::ServerBoundCert( 81 DefaultServerBoundCertStore::ServerBoundCert(
80 "google.com", 82 "google.com",
81 CLIENT_CERT_RSA_SIGN, 83 CLIENT_CERT_RSA_SIGN,
82 base::Time(), 84 base::Time(),
83 base::Time(), 85 base::Time(),
84 "a", "b")); 86 "a", "b"));
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 base::Time(), 287 base::Time(),
286 "g", "h"); 288 "g", "h");
287 289
288 EXPECT_EQ(4, store.GetCertCount()); 290 EXPECT_EQ(4, store.GetCertCount());
289 ServerBoundCertStore::ServerBoundCertList certs; 291 ServerBoundCertStore::ServerBoundCertList certs;
290 store.GetAllServerBoundCerts(&certs); 292 store.GetAllServerBoundCerts(&certs);
291 EXPECT_EQ(4u, certs.size()); 293 EXPECT_EQ(4u, certs.size());
292 } 294 }
293 295
294 } // namespace net 296 } // namespace net
OLDNEW
« no previous file with comments | « net/base/default_server_bound_cert_store.cc ('k') | net/base/file_stream_net_log_parameters.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698