| OLD | NEW |
| 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 "chrome/browser/browsing_data/mock_browsing_data_channel_id_helper.h" | 5 #include "chrome/browser/browsing_data/mock_browsing_data_channel_id_helper.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 | 9 |
| 10 MockBrowsingDataChannelIDHelper::MockBrowsingDataChannelIDHelper() | 10 MockBrowsingDataChannelIDHelper::MockBrowsingDataChannelIDHelper() |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 void MockBrowsingDataChannelIDHelper::DeleteChannelID( | 23 void MockBrowsingDataChannelIDHelper::DeleteChannelID( |
| 24 const std::string& server_id) { | 24 const std::string& server_id) { |
| 25 ASSERT_FALSE(callback_.is_null()); | 25 ASSERT_FALSE(callback_.is_null()); |
| 26 ASSERT_TRUE(channel_ids_.find(server_id) != channel_ids_.end()); | 26 ASSERT_TRUE(channel_ids_.find(server_id) != channel_ids_.end()); |
| 27 channel_ids_[server_id] = false; | 27 channel_ids_[server_id] = false; |
| 28 } | 28 } |
| 29 | 29 |
| 30 void MockBrowsingDataChannelIDHelper::AddChannelIDSample( | 30 void MockBrowsingDataChannelIDHelper::AddChannelIDSample( |
| 31 const std::string& server_id) { | 31 const std::string& server_id) { |
| 32 ASSERT_TRUE(channel_ids_.find(server_id) == channel_ids_.end()); | 32 ASSERT_TRUE(channel_ids_.find(server_id) == channel_ids_.end()); |
| 33 scoped_ptr<crypto::ECPrivateKey> key(crypto::ECPrivateKey::Create()); |
| 33 channel_id_list_.push_back( | 34 channel_id_list_.push_back( |
| 34 net::ChannelIDStore::ChannelID( | 35 net::ChannelIDStore::ChannelID(server_id, base::Time(), key.Pass())); |
| 35 server_id, base::Time(), base::Time(), "key", "cert")); | |
| 36 channel_ids_[server_id] = true; | 36 channel_ids_[server_id] = true; |
| 37 } | 37 } |
| 38 | 38 |
| 39 void MockBrowsingDataChannelIDHelper::Notify() { | 39 void MockBrowsingDataChannelIDHelper::Notify() { |
| 40 net::ChannelIDStore::ChannelIDList channel_id_list; | 40 net::ChannelIDStore::ChannelIDList channel_id_list; |
| 41 for (net::ChannelIDStore::ChannelIDList::iterator i = | 41 for (net::ChannelIDStore::ChannelIDList::iterator i = |
| 42 channel_id_list_.begin(); | 42 channel_id_list_.begin(); |
| 43 i != channel_id_list_.end(); ++i) { | 43 i != channel_id_list_.end(); ++i) { |
| 44 if (channel_ids_[i->server_identifier()]) | 44 if (channel_ids_[i->server_identifier()]) |
| 45 channel_id_list.push_back(*i); | 45 channel_id_list.push_back(*i); |
| 46 } | 46 } |
| 47 callback_.Run(channel_id_list); | 47 callback_.Run(channel_id_list); |
| 48 } | 48 } |
| 49 | 49 |
| 50 void MockBrowsingDataChannelIDHelper::Reset() { | 50 void MockBrowsingDataChannelIDHelper::Reset() { |
| 51 for (std::map<const std::string, bool>::iterator i = | 51 for (std::map<const std::string, bool>::iterator i = |
| 52 channel_ids_.begin(); | 52 channel_ids_.begin(); |
| 53 i != channel_ids_.end(); ++i) | 53 i != channel_ids_.end(); ++i) |
| 54 i->second = true; | 54 i->second = true; |
| 55 } | 55 } |
| 56 | 56 |
| 57 bool MockBrowsingDataChannelIDHelper::AllDeleted() { | 57 bool MockBrowsingDataChannelIDHelper::AllDeleted() { |
| 58 for (std::map<const std::string, bool>::const_iterator i = | 58 for (std::map<const std::string, bool>::const_iterator i = |
| 59 channel_ids_.begin(); | 59 channel_ids_.begin(); |
| 60 i != channel_ids_.end(); ++i) | 60 i != channel_ids_.end(); ++i) |
| 61 if (i->second) | 61 if (i->second) |
| 62 return false; | 62 return false; |
| 63 return true; | 63 return true; |
| 64 } | 64 } |
| OLD | NEW |