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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 scoped_refptr<base::SequencedTaskRunner> background_task_runner() { | 54 scoped_refptr<base::SequencedTaskRunner> background_task_runner() { |
55 return pool_owner_->pool()->GetSequencedTaskRunner( | 55 return pool_owner_->pool()->GetSequencedTaskRunner( |
56 pool_owner_->pool()->GetNamedSequenceToken("background")); | 56 pool_owner_->pool()->GetNamedSequenceToken("background")); |
57 } | 57 } |
58 | 58 |
59 scoped_refptr<base::SequencedTaskRunner> client_task_runner() { | 59 scoped_refptr<base::SequencedTaskRunner> client_task_runner() { |
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, NULL); | 70 false, NULL, NULL); |
71 std::vector<net::CanonicalCookie*> cookies; | 71 std::vector<net::CanonicalCookie*> cookies; |
72 Load(); | 72 Load(); |
73 ASSERT_EQ(0u, cookies_.size()); | 73 ASSERT_EQ(0u, cookies_.size()); |
74 // Creates 15000 cookies from 300 eTLD+1s. | 74 // Creates 15000 cookies from 300 eTLD+1s. |
(...skipping 19 matching lines...) Expand all Loading... |
94 // ~SequencedWorkerPoolOwner blocks on pool shutdown. | 94 // ~SequencedWorkerPoolOwner blocks on pool shutdown. |
95 pool_owner_.reset(new base::SequencedWorkerPoolOwner(1, "pool")); | 95 pool_owner_.reset(new base::SequencedWorkerPoolOwner(1, "pool")); |
96 | 96 |
97 store_ = new SQLitePersistentCookieStore( | 97 store_ = new SQLitePersistentCookieStore( |
98 temp_dir_.path().Append(cookie_filename), | 98 temp_dir_.path().Append(cookie_filename), |
99 client_task_runner(), | 99 client_task_runner(), |
100 background_task_runner(), | 100 background_task_runner(), |
101 false, NULL, NULL); | 101 false, NULL, NULL); |
102 } | 102 } |
103 | 103 |
104 virtual void TearDown() OVERRIDE { | 104 virtual void TearDown() override { |
105 store_ = NULL; | 105 store_ = NULL; |
106 pool_owner_->pool()->Shutdown(); | 106 pool_owner_->pool()->Shutdown(); |
107 } | 107 } |
108 | 108 |
109 protected: | 109 protected: |
110 scoped_ptr<base::SequencedWorkerPoolOwner> pool_owner_; | 110 scoped_ptr<base::SequencedWorkerPoolOwner> pool_owner_; |
111 base::WaitableEvent loaded_event_; | 111 base::WaitableEvent loaded_event_; |
112 base::WaitableEvent key_loaded_event_; | 112 base::WaitableEvent key_loaded_event_; |
113 std::vector<net::CanonicalCookie*> cookies_; | 113 std::vector<net::CanonicalCookie*> cookies_; |
114 base::ScopedTempDir temp_dir_; | 114 base::ScopedTempDir temp_dir_; |
(...skipping 19 matching lines...) Expand all Loading... |
134 // Test the performance of load | 134 // Test the performance of load |
135 TEST_F(SQLitePersistentCookieStorePerfTest, TestLoadPerformance) { | 135 TEST_F(SQLitePersistentCookieStorePerfTest, TestLoadPerformance) { |
136 base::PerfTimeLogger timer("Load all cookies"); | 136 base::PerfTimeLogger timer("Load all cookies"); |
137 Load(); | 137 Load(); |
138 timer.Done(); | 138 timer.Done(); |
139 | 139 |
140 ASSERT_EQ(15000U, cookies_.size()); | 140 ASSERT_EQ(15000U, cookies_.size()); |
141 } | 141 } |
142 | 142 |
143 } // namespace content | 143 } // namespace content |
OLD | NEW |