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