summaryrefslogtreecommitdiffstats
path: root/chrome/browser/net/sqlite_persistent_cookie_store_unittest.cc
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-09 02:33:15 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-09 02:33:15 +0000
commit4aa89e8ece48729ea064568b673ff43d19a1b40d (patch)
treef959786d66def8e80548b1393ea502291b25376b /chrome/browser/net/sqlite_persistent_cookie_store_unittest.cc
parent8ce1f6165f0ffc1564b25dc9fef90d05816ae634 (diff)
downloadchromium_src-4aa89e8ece48729ea064568b673ff43d19a1b40d.zip
chromium_src-4aa89e8ece48729ea064568b673ff43d19a1b40d.tar.gz
chromium_src-4aa89e8ece48729ea064568b673ff43d19a1b40d.tar.bz2
Revert 100188 - Finalize a CL originally by departed intern ycxiao@ that detaches the loading of cookies from the IO thread.
They are now loaded on the DB thread. Cookie operations received in the meantime are queued and executed, on the IO thread, in the order they were received, when loading completes. A few straggler clients are updated to use the asynchronous CookieStore/CookieMonster API as part of this CL, as the synchronous API is removed. BUG=68657 TEST=net_unittests / DeferredCookieTaskTest.* and CookieMonsterTest.* Review URL: http://codereview.chromium.org/7833042 TBR=erikwright@chromium.org Review URL: http://codereview.chromium.org/7860026 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@100335 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/net/sqlite_persistent_cookie_store_unittest.cc')
-rw-r--r--chrome/browser/net/sqlite_persistent_cookie_store_unittest.cc33
1 files changed, 5 insertions, 28 deletions
diff --git a/chrome/browser/net/sqlite_persistent_cookie_store_unittest.cc b/chrome/browser/net/sqlite_persistent_cookie_store_unittest.cc
index 942ca83..f3e52cc 100644
--- a/chrome/browser/net/sqlite_persistent_cookie_store_unittest.cc
+++ b/chrome/browser/net/sqlite_persistent_cookie_store_unittest.cc
@@ -2,13 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/bind.h"
#include "base/file_util.h"
#include "base/memory/ref_counted.h"
#include "base/message_loop.h"
#include "base/scoped_temp_dir.h"
#include "base/stl_util.h"
-#include "base/synchronization/waitable_event.h"
#include "base/test/thread_test_helper.h"
#include "base/time.h"
#include "chrome/browser/net/sqlite_persistent_cookie_store.h"
@@ -21,37 +19,19 @@ class SQLitePersistentCookieStoreTest : public testing::Test {
public:
SQLitePersistentCookieStoreTest()
: ui_thread_(BrowserThread::UI),
- db_thread_(BrowserThread::DB),
- io_thread_(BrowserThread::IO),
- event_(false, false) {
+ db_thread_(BrowserThread::DB) {
}
protected:
- void OnLoaded(
- const std::vector<net::CookieMonster::CanonicalCookie*>& cookies) {
- cookies_ = cookies;
- event_.Signal();
- }
-
- bool Load(std::vector<net::CookieMonster::CanonicalCookie*>* cookies) {
- bool result =
- store_->Load(base::Bind(&SQLitePersistentCookieStoreTest::OnLoaded,
- base::Unretained(this)));
- event_.Wait();
- *cookies = cookies_;
- return result;
- }
-
virtual void SetUp() {
ui_thread_.Start();
db_thread_.Start();
- io_thread_.Start();
ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
store_ = new SQLitePersistentCookieStore(
temp_dir_.path().Append(chrome::kCookieFilename));
std::vector<net::CookieMonster::CanonicalCookie*> cookies;
- ASSERT_TRUE(Load(&cookies));
- ASSERT_EQ(0u, cookies.size());
+ ASSERT_TRUE(store_->Load(&cookies));
+ ASSERT_TRUE(0 == cookies.size());
// Make sure the store gets written at least once.
store_->AddCookie(
net::CookieMonster::CanonicalCookie(GURL(), "A", "B", "http://foo.bar",
@@ -64,9 +44,6 @@ class SQLitePersistentCookieStoreTest : public testing::Test {
BrowserThread ui_thread_;
BrowserThread db_thread_;
- BrowserThread io_thread_;
- base::WaitableEvent event_;
- std::vector<net::CookieMonster::CanonicalCookie*> cookies_;
ScopedTempDir temp_dir_;
scoped_refptr<SQLitePersistentCookieStore> store_;
};
@@ -118,7 +95,7 @@ TEST_F(SQLitePersistentCookieStoreTest, TestPersistance) {
temp_dir_.path().Append(chrome::kCookieFilename));
// Reload and test for persistence
- ASSERT_TRUE(Load(&cookies));
+ ASSERT_TRUE(store_->Load(&cookies));
ASSERT_EQ(1U, cookies.size());
ASSERT_STREQ("http://foo.bar", cookies[0]->Domain().c_str());
ASSERT_STREQ("A", cookies[0]->Name().c_str());
@@ -135,7 +112,7 @@ TEST_F(SQLitePersistentCookieStoreTest, TestPersistance) {
temp_dir_.path().Append(chrome::kCookieFilename));
// Reload and check if the cookie has been removed.
- ASSERT_TRUE(Load(&cookies));
+ ASSERT_TRUE(store_->Load(&cookies));
ASSERT_EQ(0U, cookies.size());
}