| OLD | NEW |
| 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/cookies/cookie_monster_store_test.h" | 5 #include "net/cookies/cookie_monster_store_test.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 } | 189 } |
| 190 | 190 |
| 191 void MockSimplePersistentCookieStore::Flush(const base::Closure& callback) { | 191 void MockSimplePersistentCookieStore::Flush(const base::Closure& callback) { |
| 192 if (!callback.is_null()) | 192 if (!callback.is_null()) |
| 193 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, callback); | 193 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, callback); |
| 194 } | 194 } |
| 195 | 195 |
| 196 void MockSimplePersistentCookieStore::SetForceKeepSessionState() { | 196 void MockSimplePersistentCookieStore::SetForceKeepSessionState() { |
| 197 } | 197 } |
| 198 | 198 |
| 199 CookieMonster* CreateMonsterFromStoreForGC(int num_secure_cookies, | 199 scoped_ptr<CookieMonster> CreateMonsterFromStoreForGC( |
| 200 int num_old_secure_cookies, | 200 int num_secure_cookies, |
| 201 int num_non_secure_cookies, | 201 int num_old_secure_cookies, |
| 202 int num_old_non_secure_cookies, | 202 int num_non_secure_cookies, |
| 203 int days_old) { | 203 int num_old_non_secure_cookies, |
| 204 int days_old) { |
| 204 base::Time current(base::Time::Now()); | 205 base::Time current(base::Time::Now()); |
| 205 base::Time past_creation(base::Time::Now() - base::TimeDelta::FromDays(1000)); | 206 base::Time past_creation(base::Time::Now() - base::TimeDelta::FromDays(1000)); |
| 206 scoped_refptr<MockSimplePersistentCookieStore> store( | 207 scoped_refptr<MockSimplePersistentCookieStore> store( |
| 207 new MockSimplePersistentCookieStore); | 208 new MockSimplePersistentCookieStore); |
| 208 int total_cookies = num_secure_cookies + num_non_secure_cookies; | 209 int total_cookies = num_secure_cookies + num_non_secure_cookies; |
| 209 int base = 0; | 210 int base = 0; |
| 210 // Must expire to be persistent | 211 // Must expire to be persistent |
| 211 for (int i = 0; i < total_cookies; i++) { | 212 for (int i = 0; i < total_cookies; i++) { |
| 212 int num_old_cookies; | 213 int num_old_cookies; |
| 213 bool secure; | 214 bool secure; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 227 ? current - base::TimeDelta::FromDays(days_old) | 228 ? current - base::TimeDelta::FromDays(days_old) |
| 228 : current; | 229 : current; |
| 229 | 230 |
| 230 CanonicalCookie cc(GURL(), "a", "1", base::StringPrintf("h%05d.izzle", i), | 231 CanonicalCookie cc(GURL(), "a", "1", base::StringPrintf("h%05d.izzle", i), |
| 231 "/path", creation_time, expiration_time, | 232 "/path", creation_time, expiration_time, |
| 232 last_access_time, secure, false, false, | 233 last_access_time, secure, false, false, |
| 233 COOKIE_PRIORITY_DEFAULT); | 234 COOKIE_PRIORITY_DEFAULT); |
| 234 store->AddCookie(cc); | 235 store->AddCookie(cc); |
| 235 } | 236 } |
| 236 | 237 |
| 237 return new CookieMonster(store.get(), NULL); | 238 return make_scoped_ptr(new CookieMonster(store.get(), nullptr)); |
| 238 } | 239 } |
| 239 | 240 |
| 240 MockSimplePersistentCookieStore::~MockSimplePersistentCookieStore() { | 241 MockSimplePersistentCookieStore::~MockSimplePersistentCookieStore() { |
| 241 } | 242 } |
| 242 | 243 |
| 243 } // namespace net | 244 } // namespace net |
| OLD | NEW |