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" |
11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
12 #include "base/synchronization/waitable_event.h" | 12 #include "base/synchronization/waitable_event.h" |
13 #include "base/test/perftimer.h" | 13 #include "base/test/perf_time_logger.h" |
14 #include "base/test/sequenced_worker_pool_owner.h" | 14 #include "base/test/sequenced_worker_pool_owner.h" |
15 #include "base/threading/sequenced_worker_pool.h" | 15 #include "base/threading/sequenced_worker_pool.h" |
16 #include "net/cookies/canonical_cookie.h" | 16 #include "net/cookies/canonical_cookie.h" |
17 #include "net/cookies/cookie_constants.h" | 17 #include "net/cookies/cookie_constants.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
19 #include "url/gurl.h" | 19 #include "url/gurl.h" |
20 | 20 |
21 namespace content { | 21 namespace content { |
22 | 22 |
23 namespace { | 23 namespace { |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 base::WaitableEvent key_loaded_event_; | 111 base::WaitableEvent key_loaded_event_; |
112 std::vector<net::CanonicalCookie*> cookies_; | 112 std::vector<net::CanonicalCookie*> cookies_; |
113 base::ScopedTempDir temp_dir_; | 113 base::ScopedTempDir temp_dir_; |
114 scoped_refptr<SQLitePersistentCookieStore> store_; | 114 scoped_refptr<SQLitePersistentCookieStore> store_; |
115 }; | 115 }; |
116 | 116 |
117 // Test the performance of priority load of cookies for a specfic domain key | 117 // Test the performance of priority load of cookies for a specfic domain key |
118 TEST_F(SQLitePersistentCookieStorePerfTest, TestLoadForKeyPerformance) { | 118 TEST_F(SQLitePersistentCookieStorePerfTest, TestLoadForKeyPerformance) { |
119 for (int domain_num = 0; domain_num < 3; ++domain_num) { | 119 for (int domain_num = 0; domain_num < 3; ++domain_num) { |
120 std::string domain_name(base::StringPrintf("domain_%d.com", domain_num)); | 120 std::string domain_name(base::StringPrintf("domain_%d.com", domain_num)); |
121 PerfTimeLogger timer( | 121 base::PerfTimeLogger timer( |
122 ("Load cookies for the eTLD+1 " + domain_name).c_str()); | 122 ("Load cookies for the eTLD+1 " + domain_name).c_str()); |
123 store_->LoadCookiesForKey(domain_name, | 123 store_->LoadCookiesForKey(domain_name, |
124 base::Bind(&SQLitePersistentCookieStorePerfTest::OnKeyLoaded, | 124 base::Bind(&SQLitePersistentCookieStorePerfTest::OnKeyLoaded, |
125 base::Unretained(this))); | 125 base::Unretained(this))); |
126 key_loaded_event_.Wait(); | 126 key_loaded_event_.Wait(); |
127 timer.Done(); | 127 timer.Done(); |
128 | 128 |
129 ASSERT_EQ(50U, cookies_.size()); | 129 ASSERT_EQ(50U, cookies_.size()); |
130 } | 130 } |
131 } | 131 } |
132 | 132 |
133 // Test the performance of load | 133 // Test the performance of load |
134 TEST_F(SQLitePersistentCookieStorePerfTest, TestLoadPerformance) { | 134 TEST_F(SQLitePersistentCookieStorePerfTest, TestLoadPerformance) { |
135 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 |