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

Side by Side Diff: net/ssl/default_channel_id_store_unittest.cc

Issue 381073002: Move sqlite_channel_id_store from chrome/browser/net to net/extras. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add DeleteAll(server_identifiers) method. Created 6 years, 4 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/ssl/default_channel_id_store.h" 5 #include "net/ssl/default_channel_id_store.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 : public DefaultChannelIDStore::PersistentStore { 67 : public DefaultChannelIDStore::PersistentStore {
68 public: 68 public:
69 MockPersistentStore(); 69 MockPersistentStore();
70 70
71 // DefaultChannelIDStore::PersistentStore implementation. 71 // DefaultChannelIDStore::PersistentStore implementation.
72 virtual void Load(const LoadedCallback& loaded_callback) OVERRIDE; 72 virtual void Load(const LoadedCallback& loaded_callback) OVERRIDE;
73 virtual void AddChannelID( 73 virtual void AddChannelID(
74 const DefaultChannelIDStore::ChannelID& channel_id) OVERRIDE; 74 const DefaultChannelIDStore::ChannelID& channel_id) OVERRIDE;
75 virtual void DeleteChannelID( 75 virtual void DeleteChannelID(
76 const DefaultChannelIDStore::ChannelID& channel_id) OVERRIDE; 76 const DefaultChannelIDStore::ChannelID& channel_id) OVERRIDE;
77 virtual void DeleteAll(
78 const std::vector<std::string>& server_identifiers) OVERRIDE;
77 virtual void SetForceKeepSessionState() OVERRIDE; 79 virtual void SetForceKeepSessionState() OVERRIDE;
78 80
79 protected: 81 protected:
80 virtual ~MockPersistentStore(); 82 virtual ~MockPersistentStore();
81 83
82 private: 84 private:
83 typedef std::map<std::string, DefaultChannelIDStore::ChannelID> 85 typedef std::map<std::string, DefaultChannelIDStore::ChannelID>
84 ChannelIDMap; 86 ChannelIDMap;
85 87
86 ChannelIDMap channel_ids_; 88 ChannelIDMap channel_ids_;
(...skipping 18 matching lines...) Expand all
105 void MockPersistentStore::AddChannelID( 107 void MockPersistentStore::AddChannelID(
106 const DefaultChannelIDStore::ChannelID& channel_id) { 108 const DefaultChannelIDStore::ChannelID& channel_id) {
107 channel_ids_[channel_id.server_identifier()] = channel_id; 109 channel_ids_[channel_id.server_identifier()] = channel_id;
108 } 110 }
109 111
110 void MockPersistentStore::DeleteChannelID( 112 void MockPersistentStore::DeleteChannelID(
111 const DefaultChannelIDStore::ChannelID& channel_id) { 113 const DefaultChannelIDStore::ChannelID& channel_id) {
112 channel_ids_.erase(channel_id.server_identifier()); 114 channel_ids_.erase(channel_id.server_identifier());
113 } 115 }
114 116
117 void MockPersistentStore::DeleteAll(
118 const std::vector<std::string>& server_identifiers) {
119 for (std::vector<std::string>::const_iterator it = server_identifiers.begin();
120 it != server_identifiers.end();
121 ++it) {
122 channel_ids_.erase(*it);
123 }
124 }
125
115 void MockPersistentStore::SetForceKeepSessionState() {} 126 void MockPersistentStore::SetForceKeepSessionState() {}
116 127
117 MockPersistentStore::~MockPersistentStore() {} 128 MockPersistentStore::~MockPersistentStore() {}
118 129
119 } // namespace 130 } // namespace
120 131
121 TEST(DefaultChannelIDStoreTest, TestLoading) { 132 TEST(DefaultChannelIDStoreTest, TestLoading) {
122 scoped_refptr<MockPersistentStore> persistent_store(new MockPersistentStore); 133 scoped_refptr<MockPersistentStore> persistent_store(new MockPersistentStore);
123 134
124 persistent_store->AddChannelID( 135 persistent_store->AddChannelID(
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 ++channel_id; 557 ++channel_id;
547 EXPECT_EQ("copied.com", channel_id->server_identifier()); 558 EXPECT_EQ("copied.com", channel_id->server_identifier());
548 EXPECT_EQ("g", channel_id->private_key()); 559 EXPECT_EQ("g", channel_id->private_key());
549 560
550 ++channel_id; 561 ++channel_id;
551 EXPECT_EQ("preexisting.com", channel_id->server_identifier()); 562 EXPECT_EQ("preexisting.com", channel_id->server_identifier());
552 EXPECT_EQ("a", channel_id->private_key()); 563 EXPECT_EQ("a", channel_id->private_key());
553 } 564 }
554 565
555 } // namespace net 566 } // namespace net
OLDNEW
« net/extras/sqlite/sqlite_channel_id_store.cc ('K') | « net/ssl/default_channel_id_store.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698