| 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 "net/extras/sqlite/sqlite_persistent_cookie_store.h" | 5 #include "net/extras/sqlite/sqlite_persistent_cookie_store.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 | 26 |
| 27 namespace { | 27 namespace { |
| 28 | 28 |
| 29 const base::FilePath::CharType cookie_filename[] = FILE_PATH_LITERAL("Cookies"); | 29 const base::FilePath::CharType cookie_filename[] = FILE_PATH_LITERAL("Cookies"); |
| 30 | 30 |
| 31 } // namespace | 31 } // namespace |
| 32 | 32 |
| 33 class SQLitePersistentCookieStorePerfTest : public testing::Test { | 33 class SQLitePersistentCookieStorePerfTest : public testing::Test { |
| 34 public: | 34 public: |
| 35 SQLitePersistentCookieStorePerfTest() | 35 SQLitePersistentCookieStorePerfTest() |
| 36 : pool_owner_(new base::SequencedWorkerPoolOwner(1, "Background Pool")), | 36 : pool_owner_(new base::SequencedWorkerPoolOwner(2, "SetupPool")), |
| 37 loaded_event_(base::WaitableEvent::ResetPolicy::AUTOMATIC, | 37 loaded_event_(base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 38 base::WaitableEvent::InitialState::NOT_SIGNALED), | 38 base::WaitableEvent::InitialState::NOT_SIGNALED), |
| 39 key_loaded_event_(base::WaitableEvent::ResetPolicy::AUTOMATIC, | 39 key_loaded_event_(base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 40 base::WaitableEvent::InitialState::NOT_SIGNALED) {} | 40 base::WaitableEvent::InitialState::NOT_SIGNALED) {} |
| 41 | 41 |
| 42 void OnLoaded(const std::vector<CanonicalCookie*>& cookies) { | 42 void OnLoaded(const std::vector<CanonicalCookie*>& cookies) { |
| 43 cookies_ = cookies; | 43 cookies_ = cookies; |
| 44 loaded_event_.Signal(); | 44 loaded_event_.Signal(); |
| 45 } | 45 } |
| 46 | 46 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 COOKIE_PRIORITY_DEFAULT)); | 86 COOKIE_PRIORITY_DEFAULT)); |
| 87 } | 87 } |
| 88 } | 88 } |
| 89 // Replace the store effectively destroying the current one and forcing it | 89 // Replace the store effectively destroying the current one and forcing it |
| 90 // to write its data to disk. | 90 // to write its data to disk. |
| 91 store_ = NULL; | 91 store_ = NULL; |
| 92 | 92 |
| 93 // Shut down the pool, causing deferred (no-op) commits to be discarded. | 93 // Shut down the pool, causing deferred (no-op) commits to be discarded. |
| 94 pool_owner_->pool()->Shutdown(); | 94 pool_owner_->pool()->Shutdown(); |
| 95 // ~SequencedWorkerPoolOwner blocks on pool shutdown. | 95 // ~SequencedWorkerPoolOwner blocks on pool shutdown. |
| 96 pool_owner_.reset(new base::SequencedWorkerPoolOwner(1, "pool")); | 96 pool_owner_.reset(new base::SequencedWorkerPoolOwner(2, "TestPool")); |
| 97 | 97 |
| 98 store_ = new SQLitePersistentCookieStore( | 98 store_ = new SQLitePersistentCookieStore( |
| 99 temp_dir_.path().Append(cookie_filename), client_task_runner(), | 99 temp_dir_.path().Append(cookie_filename), client_task_runner(), |
| 100 background_task_runner(), false, NULL); | 100 background_task_runner(), false, NULL); |
| 101 } | 101 } |
| 102 | 102 |
| 103 void TearDown() override { | 103 void TearDown() override { |
| 104 store_ = NULL; | 104 store_ = NULL; |
| 105 } | 105 } |
| 106 | 106 |
| (...skipping 27 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 net | 143 } // namespace net |
| OLD | NEW |