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

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

Issue 10407124: Don't force non-session only cookies to be session only cookies, instead delete on shutdown (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updates Created 8 years, 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/message_loop.h" 6 #include "base/message_loop.h"
7 #include "base/perftimer.h" 7 #include "base/perftimer.h"
8 #include "base/scoped_temp_dir.h" 8 #include "base/scoped_temp_dir.h"
9 #include "base/stringprintf.h" 9 #include "base/stringprintf.h"
10 #include "base/synchronization/waitable_event.h" 10 #include "base/synchronization/waitable_event.h"
11 #include "base/test/thread_test_helper.h" 11 #include "base/test/thread_test_helper.h"
(...skipping 30 matching lines...) Expand all
42 store_->Load(base::Bind(&SQLitePersistentCookieStorePerfTest::OnLoaded, 42 store_->Load(base::Bind(&SQLitePersistentCookieStorePerfTest::OnLoaded,
43 base::Unretained(this))); 43 base::Unretained(this)));
44 loaded_event_.Wait(); 44 loaded_event_.Wait();
45 } 45 }
46 46
47 virtual void SetUp() { 47 virtual void SetUp() {
48 db_thread_.Start(); 48 db_thread_.Start();
49 io_thread_.Start(); 49 io_thread_.Start();
50 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 50 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
51 store_ = new SQLitePersistentCookieStore( 51 store_ = new SQLitePersistentCookieStore(
52 temp_dir_.path().Append(chrome::kCookieFilename)); 52 temp_dir_.path().Append(chrome::kCookieFilename),
53 false, NULL);
53 std::vector<net::CookieMonster::CanonicalCookie*> cookies; 54 std::vector<net::CookieMonster::CanonicalCookie*> cookies;
54 Load(); 55 Load();
55 ASSERT_EQ(0u, cookies_.size()); 56 ASSERT_EQ(0u, cookies_.size());
56 // Creates 15000 cookies from 300 eTLD+1s. 57 // Creates 15000 cookies from 300 eTLD+1s.
57 base::Time t = base::Time::Now(); 58 base::Time t = base::Time::Now();
58 for (int domain_num = 0; domain_num < 300; domain_num++) { 59 for (int domain_num = 0; domain_num < 300; domain_num++) {
59 std::string domain_name(base::StringPrintf(".domain_%d.com", domain_num)); 60 std::string domain_name(base::StringPrintf(".domain_%d.com", domain_num));
60 GURL gurl("www" + domain_name); 61 GURL gurl("www" + domain_name);
61 for (int cookie_num = 0; cookie_num < 50; ++cookie_num) { 62 for (int cookie_num = 0; cookie_num < 50; ++cookie_num) {
62 t += base::TimeDelta::FromInternalValue(10); 63 t += base::TimeDelta::FromInternalValue(10);
63 store_->AddCookie( 64 store_->AddCookie(
64 net::CookieMonster::CanonicalCookie(gurl, 65 net::CookieMonster::CanonicalCookie(gurl,
65 base::StringPrintf("Cookie_%d", cookie_num), "1", 66 base::StringPrintf("Cookie_%d", cookie_num), "1",
66 domain_name, "/", std::string(), std::string(), 67 domain_name, "/", std::string(), std::string(),
67 t, t, t, false, false, true)); 68 t, t, t, false, false, true, true));
68 } 69 }
69 } 70 }
70 // Replace the store effectively destroying the current one and forcing it 71 // Replace the store effectively destroying the current one and forcing it
71 // to write its data to disk. 72 // to write its data to disk.
72 store_ = NULL; 73 store_ = NULL;
73 scoped_refptr<base::ThreadTestHelper> helper( 74 scoped_refptr<base::ThreadTestHelper> helper(
74 new base::ThreadTestHelper( 75 new base::ThreadTestHelper(
75 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB))); 76 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB)));
76 // Make sure we wait until the destructor has run. 77 // Make sure we wait until the destructor has run.
77 ASSERT_TRUE(helper->Run()); 78 ASSERT_TRUE(helper->Run());
78 79
79 store_ = new SQLitePersistentCookieStore( 80 store_ = new SQLitePersistentCookieStore(
80 temp_dir_.path().Append(chrome::kCookieFilename)); 81 temp_dir_.path().Append(chrome::kCookieFilename), false, NULL);
81 } 82 }
82 83
83 protected: 84 protected:
84 content::TestBrowserThread db_thread_; 85 content::TestBrowserThread db_thread_;
85 content::TestBrowserThread io_thread_; 86 content::TestBrowserThread io_thread_;
86 base::WaitableEvent loaded_event_; 87 base::WaitableEvent loaded_event_;
87 base::WaitableEvent key_loaded_event_; 88 base::WaitableEvent key_loaded_event_;
88 std::vector<net::CookieMonster::CanonicalCookie*> cookies_; 89 std::vector<net::CookieMonster::CanonicalCookie*> cookies_;
89 ScopedTempDir temp_dir_; 90 ScopedTempDir temp_dir_;
90 scoped_refptr<SQLitePersistentCookieStore> store_; 91 scoped_refptr<SQLitePersistentCookieStore> store_;
(...skipping 16 matching lines...) Expand all
107 } 108 }
108 109
109 // Test the performance of load 110 // Test the performance of load
110 TEST_F(SQLitePersistentCookieStorePerfTest, TestLoadPerformance) { 111 TEST_F(SQLitePersistentCookieStorePerfTest, TestLoadPerformance) {
111 PerfTimeLogger timer("Load all cookies"); 112 PerfTimeLogger timer("Load all cookies");
112 Load(); 113 Load();
113 timer.Done(); 114 timer.Done();
114 115
115 ASSERT_EQ(15000U, cookies_.size()); 116 ASSERT_EQ(15000U, cookies_.size());
116 } 117 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698