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 "content/browser/net/sqlite_persistent_cookie_store.h" | 5 #include "content/browser/net/sqlite_persistent_cookie_store.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
10 #include "base/sequenced_task_runner.h" | 10 #include "base/sequenced_task_runner.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 return pool_owner_->pool()->GetSequencedTaskRunner( | 60 return pool_owner_->pool()->GetSequencedTaskRunner( |
61 pool_owner_->pool()->GetNamedSequenceToken("client")); | 61 pool_owner_->pool()->GetNamedSequenceToken("client")); |
62 } | 62 } |
63 | 63 |
64 virtual void SetUp() OVERRIDE { | 64 virtual void SetUp() OVERRIDE { |
65 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 65 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
66 store_ = new SQLitePersistentCookieStore( | 66 store_ = new SQLitePersistentCookieStore( |
67 temp_dir_.path().Append(cookie_filename), | 67 temp_dir_.path().Append(cookie_filename), |
68 client_task_runner(), | 68 client_task_runner(), |
69 background_task_runner(), | 69 background_task_runner(), |
70 false, NULL, | 70 false, NULL, NULL); |
71 scoped_ptr<content::CookieCryptoDelegate>()); | |
72 std::vector<net::CanonicalCookie*> cookies; | 71 std::vector<net::CanonicalCookie*> cookies; |
73 Load(); | 72 Load(); |
74 ASSERT_EQ(0u, cookies_.size()); | 73 ASSERT_EQ(0u, cookies_.size()); |
75 // Creates 15000 cookies from 300 eTLD+1s. | 74 // Creates 15000 cookies from 300 eTLD+1s. |
76 base::Time t = base::Time::Now(); | 75 base::Time t = base::Time::Now(); |
77 for (int domain_num = 0; domain_num < 300; domain_num++) { | 76 for (int domain_num = 0; domain_num < 300; domain_num++) { |
78 std::string domain_name(base::StringPrintf(".domain_%d.com", domain_num)); | 77 std::string domain_name(base::StringPrintf(".domain_%d.com", domain_num)); |
79 GURL gurl("www" + domain_name); | 78 GURL gurl("www" + domain_name); |
80 for (int cookie_num = 0; cookie_num < 50; ++cookie_num) { | 79 for (int cookie_num = 0; cookie_num < 50; ++cookie_num) { |
81 t += base::TimeDelta::FromInternalValue(10); | 80 t += base::TimeDelta::FromInternalValue(10); |
(...skipping 10 matching lines...) Expand all Loading... |
92 | 91 |
93 // Shut down the pool, causing deferred (no-op) commits to be discarded. | 92 // Shut down the pool, causing deferred (no-op) commits to be discarded. |
94 pool_owner_->pool()->Shutdown(); | 93 pool_owner_->pool()->Shutdown(); |
95 // ~SequencedWorkerPoolOwner blocks on pool shutdown. | 94 // ~SequencedWorkerPoolOwner blocks on pool shutdown. |
96 pool_owner_.reset(new base::SequencedWorkerPoolOwner(1, "pool")); | 95 pool_owner_.reset(new base::SequencedWorkerPoolOwner(1, "pool")); |
97 | 96 |
98 store_ = new SQLitePersistentCookieStore( | 97 store_ = new SQLitePersistentCookieStore( |
99 temp_dir_.path().Append(cookie_filename), | 98 temp_dir_.path().Append(cookie_filename), |
100 client_task_runner(), | 99 client_task_runner(), |
101 background_task_runner(), | 100 background_task_runner(), |
102 false, NULL, | 101 false, NULL, NULL); |
103 scoped_ptr<content::CookieCryptoDelegate>()); | |
104 } | 102 } |
105 | 103 |
106 virtual void TearDown() OVERRIDE { | 104 virtual void TearDown() OVERRIDE { |
107 store_ = NULL; | 105 store_ = NULL; |
108 pool_owner_->pool()->Shutdown(); | 106 pool_owner_->pool()->Shutdown(); |
109 } | 107 } |
110 | 108 |
111 protected: | 109 protected: |
112 scoped_ptr<base::SequencedWorkerPoolOwner> pool_owner_; | 110 scoped_ptr<base::SequencedWorkerPoolOwner> pool_owner_; |
113 base::WaitableEvent loaded_event_; | 111 base::WaitableEvent loaded_event_; |
(...skipping 22 matching lines...) Expand all Loading... |
136 // Test the performance of load | 134 // Test the performance of load |
137 TEST_F(SQLitePersistentCookieStorePerfTest, TestLoadPerformance) { | 135 TEST_F(SQLitePersistentCookieStorePerfTest, TestLoadPerformance) { |
138 base::PerfTimeLogger timer("Load all cookies"); | 136 base::PerfTimeLogger timer("Load all cookies"); |
139 Load(); | 137 Load(); |
140 timer.Done(); | 138 timer.Done(); |
141 | 139 |
142 ASSERT_EQ(15000U, cookies_.size()); | 140 ASSERT_EQ(15000U, cookies_.size()); |
143 } | 141 } |
144 | 142 |
145 } // namespace content | 143 } // namespace content |
OLD | NEW |