| 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 #include <memory> | 6 #include <memory> |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 EXPECT_EQ(32, CountInString(cookie_line, '=')); | 275 EXPECT_EQ(32, CountInString(cookie_line, '=')); |
| 276 base::PerfTimeLogger timer2("Cookie_monster_query_domain_line"); | 276 base::PerfTimeLogger timer2("Cookie_monster_query_domain_line"); |
| 277 for (int i = 0; i < kNumCookies; i++) { | 277 for (int i = 0; i < kNumCookies; i++) { |
| 278 getCookiesCallback.GetCookies(cm.get(), probe_gurl); | 278 getCookiesCallback.GetCookies(cm.get(), probe_gurl); |
| 279 } | 279 } |
| 280 timer2.Done(); | 280 timer2.Done(); |
| 281 } | 281 } |
| 282 | 282 |
| 283 TEST_F(CookieMonsterTest, TestImport) { | 283 TEST_F(CookieMonsterTest, TestImport) { |
| 284 scoped_refptr<MockPersistentCookieStore> store(new MockPersistentCookieStore); | 284 scoped_refptr<MockPersistentCookieStore> store(new MockPersistentCookieStore); |
| 285 std::vector<CanonicalCookie*> initial_cookies; | 285 std::vector<std::unique_ptr<CanonicalCookie>> initial_cookies; |
| 286 GetCookiesCallback getCookiesCallback; | 286 GetCookiesCallback getCookiesCallback; |
| 287 | 287 |
| 288 // We want to setup a fairly large backing store, with 300 domains of 50 | 288 // We want to setup a fairly large backing store, with 300 domains of 50 |
| 289 // cookies each. Creation times must be unique. | 289 // cookies each. Creation times must be unique. |
| 290 int64_t time_tick(base::Time::Now().ToInternalValue()); | 290 int64_t time_tick(base::Time::Now().ToInternalValue()); |
| 291 | 291 |
| 292 for (int domain_num = 0; domain_num < 300; domain_num++) { | 292 for (int domain_num = 0; domain_num < 300; domain_num++) { |
| 293 GURL gurl(base::StringPrintf("http://www.Domain_%d.com", domain_num)); | 293 GURL gurl(base::StringPrintf("http://www.Domain_%d.com", domain_num)); |
| 294 for (int cookie_num = 0; cookie_num < 50; cookie_num++) { | 294 for (int cookie_num = 0; cookie_num < 50; cookie_num++) { |
| 295 std::string cookie_line( | 295 std::string cookie_line( |
| 296 base::StringPrintf("Cookie_%d=1; Path=/", cookie_num)); | 296 base::StringPrintf("Cookie_%d=1; Path=/", cookie_num)); |
| 297 AddCookieToList(gurl, cookie_line, | 297 AddCookieToList(gurl, cookie_line, |
| 298 base::Time::FromInternalValue(time_tick++), | 298 base::Time::FromInternalValue(time_tick++), |
| 299 &initial_cookies); | 299 &initial_cookies); |
| 300 } | 300 } |
| 301 } | 301 } |
| 302 | 302 |
| 303 store->SetLoadExpectation(true, initial_cookies); | 303 store->SetLoadExpectation(true, std::move(initial_cookies)); |
| 304 | 304 |
| 305 std::unique_ptr<CookieMonster> cm(new CookieMonster(store.get(), nullptr)); | 305 std::unique_ptr<CookieMonster> cm(new CookieMonster(store.get(), nullptr)); |
| 306 | 306 |
| 307 // Import will happen on first access. | 307 // Import will happen on first access. |
| 308 GURL gurl("www.google.com"); | 308 GURL gurl("www.google.com"); |
| 309 CookieOptions options; | 309 CookieOptions options; |
| 310 base::PerfTimeLogger timer("Cookie_monster_import_from_store"); | 310 base::PerfTimeLogger timer("Cookie_monster_import_from_store"); |
| 311 getCookiesCallback.GetCookies(cm.get(), gurl); | 311 getCookiesCallback.GetCookies(cm.get(), gurl); |
| 312 timer.Done(); | 312 timer.Done(); |
| 313 | 313 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 setCookieCallback.SetCookie(cm.get(), gurl, cookie_line); | 382 setCookieCallback.SetCookie(cm.get(), gurl, cookie_line); |
| 383 | 383 |
| 384 base::PerfTimeLogger timer((std::string("GC_") + test_case.name).c_str()); | 384 base::PerfTimeLogger timer((std::string("GC_") + test_case.name).c_str()); |
| 385 for (int i = 0; i < kNumCookies; i++) | 385 for (int i = 0; i < kNumCookies; i++) |
| 386 setCookieCallback.SetCookie(cm.get(), gurl, cookie_line); | 386 setCookieCallback.SetCookie(cm.get(), gurl, cookie_line); |
| 387 timer.Done(); | 387 timer.Done(); |
| 388 } | 388 } |
| 389 } | 389 } |
| 390 | 390 |
| 391 } // namespace net | 391 } // namespace net |
| OLD | NEW |