Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4697)

Unified Diff: chrome/browser/fast_shutdown_uitest.cc

Issue 7833042: Finalize a CL originally by departed intern ycxiao@ that detaches the loading of cookies from the... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/browsing_data_remover.cc ('k') | chrome/browser/net/cookie_policy_browsertest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/fast_shutdown_uitest.cc
===================================================================
--- chrome/browser/fast_shutdown_uitest.cc (revision 99705)
+++ chrome/browser/fast_shutdown_uitest.cc (working copy)
@@ -2,6 +2,7 @@
// 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_path.h"
#include "base/stl_util.h"
#include "base/test/thread_test_helper.h"
@@ -18,6 +19,7 @@
protected:
FastShutdown()
: db_thread_(BrowserThread::DB),
+ io_thread_(BrowserThread::IO),
thread_helper_(new base::ThreadTestHelper(
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB))) {
dom_automation_enabled_ = true;
@@ -25,7 +27,7 @@
void Init() {
ASSERT_TRUE(db_thread_.Start());
-
+ ASSERT_TRUE(io_thread_.Start());
// Cache this, so that we can still access it after the browser exits.
user_data_dir_ = user_data_dir();
}
@@ -36,11 +38,17 @@
void GetCookie(const net::CookieMonster::CanonicalCookie& cookie,
bool* has_cookie, std::string* cookie_value) {
scoped_refptr<SQLitePersistentCookieStore> cookie_store(
- new SQLitePersistentCookieStore(
- user_data_dir_.AppendASCII(chrome::kInitialProfile)
- .Append(chrome::kCookieFilename)));
+ new SQLitePersistentCookieStore(
+ user_data_dir_.AppendASCII(chrome::kInitialProfile)
+ .Append(chrome::kCookieFilename)));
std::vector<net::CookieMonster::CanonicalCookie*> cookies;
- ASSERT_TRUE(cookie_store->Load(&cookies));
+ ASSERT_TRUE(cookie_store->Load(
+ base::Bind(&FastShutdown::LoadCookiesCallback,
+ base::Unretained(this),
+ MessageLoop::current(),
+ base::Unretained(&cookies))));
+ // Will receive a QuitTask when LoadCookiesCallback is invoked.
+ MessageLoop::current()->Run();
*has_cookie = false;
for (size_t i = 0; i < cookies.size(); ++i) {
if (cookies[i]->IsEquivalent(cookie)) {
@@ -54,7 +62,16 @@
}
private:
- BrowserThread db_thread_; // Used by the cookie store during its clean up.
+ void LoadCookiesCallback(
+ MessageLoop* to_notify,
+ std::vector<net::CookieMonster::CanonicalCookie*>* cookies,
+ const std::vector<net::CookieMonster::CanonicalCookie*>& cookies_get) {
+ *cookies = cookies_get;
+ to_notify->PostTask(FROM_HERE, new MessageLoop::QuitTask());
+ }
+
+ BrowserThread db_thread_;
+ BrowserThread io_thread_;
scoped_refptr<base::ThreadTestHelper> thread_helper_;
FilePath user_data_dir_;
@@ -83,14 +100,6 @@
false, // httponly
false); // has_expires
- bool has_cookie = false;
- std::string cookie_value;
-
- // Check that the cookie (to be set during unload) doesn't exist already.
- GetCookie(cookie, &has_cookie, &cookie_value);
- EXPECT_FALSE(has_cookie);
- EXPECT_EQ("", cookie_value);
-
// This page has an unload handler.
const FilePath dir(FILE_PATH_LITERAL("fast_shutdown"));
const FilePath file(FILE_PATH_LITERAL("on_unloader.html"));
@@ -111,6 +120,8 @@
// cookie that's stored to disk.
QuitBrowser();
+ bool has_cookie = false;
+ std::string cookie_value;
// Read the cookie and check that it has the expected value.
GetCookie(cookie, &has_cookie, &cookie_value);
EXPECT_TRUE(has_cookie);
« no previous file with comments | « chrome/browser/browsing_data_remover.cc ('k') | chrome/browser/net/cookie_policy_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698