OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/base/cookie_monster.h" | 5 #include "net/base/cookie_monster.h" |
6 | 6 |
7 #include "base/perftimer.h" | 7 #include "base/perftimer.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
10 #include "googleurl/src/gurl.h" | 10 #include "googleurl/src/gurl.h" |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 CookieMonster::kMaxCookies * 3 / 4, | 276 CookieMonster::kMaxCookies * 3 / 4, |
277 }, { | 277 }, { |
278 "less_than_gc_thresh", | 278 "less_than_gc_thresh", |
279 // Few enough cookies that gc shouldn't happen at all. | 279 // Few enough cookies that gc shouldn't happen at all. |
280 CookieMonster::kMaxCookies - 5, | 280 CookieMonster::kMaxCookies - 5, |
281 0, | 281 0, |
282 }, | 282 }, |
283 }; | 283 }; |
284 for (int ci = 0; ci < static_cast<int>(ARRAYSIZE_UNSAFE(test_cases)); ++ci) { | 284 for (int ci = 0; ci < static_cast<int>(ARRAYSIZE_UNSAFE(test_cases)); ++ci) { |
285 const TestCase& test_case(test_cases[ci]); | 285 const TestCase& test_case(test_cases[ci]); |
286 scoped_refptr<CookieMonster> cm = | 286 scoped_refptr<CookieMonster> cm( |
287 CreateMonsterFromStoreForGC( | 287 CreateMonsterFromStoreForGC( |
288 test_case.num_cookies, test_case.num_old_cookies, | 288 test_case.num_cookies, test_case.num_old_cookies, |
289 CookieMonster::kSafeFromGlobalPurgeDays * 2); | 289 CookieMonster::kSafeFromGlobalPurgeDays * 2)); |
290 | 290 |
291 GURL gurl("http://google.com"); | 291 GURL gurl("http://google.com"); |
292 std::string cookie_line("z=3"); | 292 std::string cookie_line("z=3"); |
293 // Trigger the Garbage collection we're allowed. | 293 // Trigger the Garbage collection we're allowed. |
294 EXPECT_TRUE(cm->SetCookie(gurl, cookie_line)); | 294 EXPECT_TRUE(cm->SetCookie(gurl, cookie_line)); |
295 | 295 |
296 PerfTimeLogger timer((std::string("GC_") + test_case.name).c_str()); | 296 PerfTimeLogger timer((std::string("GC_") + test_case.name).c_str()); |
297 for (int i = 0; i < kNumCookies; i++) | 297 for (int i = 0; i < kNumCookies; i++) |
298 EXPECT_TRUE(cm->SetCookie(gurl, cookie_line)); | 298 EXPECT_TRUE(cm->SetCookie(gurl, cookie_line)); |
299 timer.Done(); | 299 timer.Done(); |
300 } | 300 } |
301 } | 301 } |
302 | 302 |
303 } // namespace | 303 } // namespace |
OLD | NEW |