| 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 <algorithm> | 5 #include <algorithm> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/perftimer.h" | 9 #include "base/perftimer.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| 11 #include "base/stringprintf.h" | 11 #include "base/stringprintf.h" |
| 12 #include "googleurl/src/gurl.h" | 12 #include "googleurl/src/gurl.h" |
| 13 #include "net/cookies/canonical_cookie.h" |
| 13 #include "net/cookies/cookie_monster.h" | 14 #include "net/cookies/cookie_monster.h" |
| 14 #include "net/cookies/cookie_monster_store_test.h" | 15 #include "net/cookies/cookie_monster_store_test.h" |
| 15 #include "net/cookies/parsed_cookie.h" | 16 #include "net/cookies/parsed_cookie.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 17 | 18 |
| 18 namespace { | 19 namespace { |
| 19 class CookieMonsterTest : public testing::Test { | 20 class CookieMonsterTest : public testing::Test { |
| 20 public: | 21 public: |
| 21 CookieMonsterTest() : message_loop_(new MessageLoopForIO()) {} | 22 CookieMonsterTest() : message_loop_(new MessageLoopForIO()) {} |
| 22 | 23 |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 EXPECT_EQ(32, CountInString(cookie_line, '=')); | 318 EXPECT_EQ(32, CountInString(cookie_line, '=')); |
| 318 PerfTimeLogger timer2("Cookie_monster_query_domain_line"); | 319 PerfTimeLogger timer2("Cookie_monster_query_domain_line"); |
| 319 for (int i = 0; i < kNumCookies; i++) { | 320 for (int i = 0; i < kNumCookies; i++) { |
| 320 getCookiesCallback.GetCookies(cm, probe_gurl); | 321 getCookiesCallback.GetCookies(cm, probe_gurl); |
| 321 } | 322 } |
| 322 timer2.Done(); | 323 timer2.Done(); |
| 323 } | 324 } |
| 324 | 325 |
| 325 TEST_F(CookieMonsterTest, TestImport) { | 326 TEST_F(CookieMonsterTest, TestImport) { |
| 326 scoped_refptr<MockPersistentCookieStore> store(new MockPersistentCookieStore); | 327 scoped_refptr<MockPersistentCookieStore> store(new MockPersistentCookieStore); |
| 327 std::vector<CookieMonster::CanonicalCookie*> initial_cookies; | 328 std::vector<CanonicalCookie*> initial_cookies; |
| 328 GetCookiesCallback getCookiesCallback; | 329 GetCookiesCallback getCookiesCallback; |
| 329 | 330 |
| 330 // We want to setup a fairly large backing store, with 300 domains of 50 | 331 // We want to setup a fairly large backing store, with 300 domains of 50 |
| 331 // cookies each. Creation times must be unique. | 332 // cookies each. Creation times must be unique. |
| 332 int64 time_tick(base::Time::Now().ToInternalValue()); | 333 int64 time_tick(base::Time::Now().ToInternalValue()); |
| 333 | 334 |
| 334 for (int domain_num = 0; domain_num < 300; domain_num++) { | 335 for (int domain_num = 0; domain_num < 300; domain_num++) { |
| 335 std::string domain_name(base::StringPrintf(".Domain_%d.com", domain_num)); | 336 std::string domain_name(base::StringPrintf(".Domain_%d.com", domain_num)); |
| 336 std::string gurl("www" + domain_name); | 337 std::string gurl("www" + domain_name); |
| 337 for (int cookie_num = 0; cookie_num < 50; cookie_num++) { | 338 for (int cookie_num = 0; cookie_num < 50; cookie_num++) { |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 setCookieCallback.SetCookie(cm, gurl, cookie_line); | 423 setCookieCallback.SetCookie(cm, gurl, cookie_line); |
| 423 | 424 |
| 424 PerfTimeLogger timer((std::string("GC_") + test_case.name).c_str()); | 425 PerfTimeLogger timer((std::string("GC_") + test_case.name).c_str()); |
| 425 for (int i = 0; i < kNumCookies; i++) | 426 for (int i = 0; i < kNumCookies; i++) |
| 426 setCookieCallback.SetCookie(cm, gurl, cookie_line); | 427 setCookieCallback.SetCookie(cm, gurl, cookie_line); |
| 427 timer.Done(); | 428 timer.Done(); |
| 428 } | 429 } |
| 429 } | 430 } |
| 430 | 431 |
| 431 } // namespace | 432 } // namespace |
| OLD | NEW |