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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/files/file_util.h" | 6 #include "base/files/file_util.h" |
7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
171 // to write its data to disk. Then we can see if after loading it again it | 171 // to write its data to disk. Then we can see if after loading it again it |
172 // is still there. | 172 // is still there. |
173 store_ = NULL; | 173 store_ = NULL; |
174 // Make sure we wait until the destructor has run. | 174 // Make sure we wait until the destructor has run. |
175 base::RunLoop().RunUntilIdle(); | 175 base::RunLoop().RunUntilIdle(); |
176 // Specify storage policy that makes "foo.com" session only. | 176 // Specify storage policy that makes "foo.com" session only. |
177 scoped_refptr<content::MockSpecialStoragePolicy> storage_policy = | 177 scoped_refptr<content::MockSpecialStoragePolicy> storage_policy = |
178 new content::MockSpecialStoragePolicy(); | 178 new content::MockSpecialStoragePolicy(); |
179 storage_policy->AddSessionOnly( | 179 storage_policy->AddSessionOnly( |
180 net::cookie_util::CookieOriginToURL("foo.com", true)); | 180 net::cookie_util::CookieOriginToURL("foo.com", true)); |
181 storage_policy->AddSessionOnly( | |
182 net::cookie_util::CookieOriginToURL("nonpersistent.com", true)); | |
Ryan Sleevi
2015/04/06 18:09:57
How is this distinct from foo.com, which is nonper
rohitrao (ping after 24h)
2015/04/06 18:42:22
I wasn't sure if I could add two IDs with the same
Ryan Sleevi
2015/04/06 18:46:55
I guess that wasn't quite what I meant, and still
| |
181 // Reload store, it should still have both channel ids. | 183 // Reload store, it should still have both channel ids. |
182 store_ = new QuotaPolicyChannelIDStore( | 184 store_ = new QuotaPolicyChannelIDStore( |
183 temp_dir_.path().Append(kTestChannelIDFilename), | 185 temp_dir_.path().Append(kTestChannelIDFilename), |
184 base::MessageLoopProxy::current(), | 186 base::MessageLoopProxy::current(), |
185 storage_policy); | 187 storage_policy); |
186 Load(&channel_ids); | 188 Load(&channel_ids); |
187 ASSERT_EQ(2U, channel_ids.size()); | 189 ASSERT_EQ(2U, channel_ids.size()); |
188 | 190 |
189 // Now close the store, and "foo.com" should be deleted according to policy. | 191 store_->AddChannelID(net::DefaultChannelIDStore::ChannelID( |
192 "nonpersistent.com", base::Time::FromInternalValue(5), | |
193 base::Time::FromInternalValue(6), "e", "f")); | |
194 store_->AddChannelID(net::DefaultChannelIDStore::ChannelID( | |
195 "persistent.com", base::Time::FromInternalValue(7), | |
196 base::Time::FromInternalValue(8), "g", "h")); | |
Ryan Sleevi
2015/04/06 18:09:57
Not clear what you're trying to do here. Could you
rohitrao (ping after 24h)
2015/04/06 18:42:22
Added a comment to this block. The goal was to do
| |
197 | |
198 // Now close the store, and the session-only IDs should be deleted according | |
199 // to policy. | |
190 store_ = NULL; | 200 store_ = NULL; |
191 // Make sure we wait until the destructor has run. | 201 // Make sure we wait until the destructor has run. |
192 base::RunLoop().RunUntilIdle(); | 202 base::RunLoop().RunUntilIdle(); |
193 channel_ids.clear(); | 203 channel_ids.clear(); |
194 store_ = new QuotaPolicyChannelIDStore( | 204 store_ = new QuotaPolicyChannelIDStore( |
195 temp_dir_.path().Append(kTestChannelIDFilename), | 205 temp_dir_.path().Append(kTestChannelIDFilename), |
196 base::MessageLoopProxy::current(), | 206 base::MessageLoopProxy::current(), |
197 NULL); | 207 NULL); |
198 | 208 |
199 // Reload and check that the "foo.com" cert has been removed. | 209 // Reload and check that the proper IDs have been removed. |
200 Load(&channel_ids); | 210 Load(&channel_ids); |
201 ASSERT_EQ(1U, channel_ids.size()); | 211 ASSERT_EQ(2U, channel_ids.size()); |
202 ASSERT_EQ("google.com", channel_ids[0]->server_identifier()); | 212 for (const auto& id : channel_ids) { |
213 ASSERT_NE("foo.com", id->server_identifier()); | |
214 ASSERT_NE("nonpersistent.com", id->server_identifier()); | |
215 } | |
203 } | 216 } |
OLD | NEW |