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

Side by Side Diff: chrome/browser/net/quota_policy_channel_id_store_unittest.cc

Issue 1015233002: Fixes a bug where QuotaPolicyChannelIDStore would ignore some deletes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: With fix. Created 5 years, 9 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 "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
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));
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
191 store_->AddChannelID(
192 net::DefaultChannelIDStore::ChannelID("nonpersistent.com",
193 base::Time::FromInternalValue(5),
194 base::Time::FromInternalValue(6),
195 "e",
196 "f"));
197
189 // Now close the store, and "foo.com" should be deleted according to policy. 198 // Now close the store, and "foo.com" should be deleted according to policy.
190 store_ = NULL; 199 store_ = NULL;
191 // Make sure we wait until the destructor has run. 200 // Make sure we wait until the destructor has run.
192 base::RunLoop().RunUntilIdle(); 201 base::RunLoop().RunUntilIdle();
193 channel_ids.clear(); 202 channel_ids.clear();
194 store_ = new QuotaPolicyChannelIDStore( 203 store_ = new QuotaPolicyChannelIDStore(
195 temp_dir_.path().Append(kTestChannelIDFilename), 204 temp_dir_.path().Append(kTestChannelIDFilename),
196 base::MessageLoopProxy::current(), 205 base::MessageLoopProxy::current(),
197 NULL); 206 NULL);
198 207
199 // Reload and check that the "foo.com" cert has been removed. 208 // Reload and check that the "foo.com" cert has been removed.
200 Load(&channel_ids); 209 Load(&channel_ids);
201 ASSERT_EQ(1U, channel_ids.size()); 210 ASSERT_EQ(1U, channel_ids.size());
202 ASSERT_EQ("google.com", channel_ids[0]->server_identifier()); 211 ASSERT_EQ("google.com", channel_ids[0]->server_identifier());
203 } 212 }
OLDNEW
« no previous file with comments | « no previous file | net/extras/sqlite/sqlite_channel_id_store.cc » ('j') | net/extras/sqlite/sqlite_channel_id_store.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698