Abort in-flight load tasks if the DB has been closed.

I suspect that the crashes reported in M17 are because the SQLitePersistentCookieStore is closed while it was still loading.

This CL adds checks that should abort all tasks that access db_, if db_ is NULL.

R=rdsmith@chromium.org
BUG=106722
TEST=None


Review URL: http://codereview.chromium.org/8855009

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@113498 0039d316-1c4b-4281-b951-d872f2087c98
parent f5344983
......@@ -458,7 +458,9 @@ bool SQLitePersistentCookieStore::Backend::InitializeDatabase() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
if (initialized_) {
return true;
// Return false if we were previously initialized but the DB has since been
// closed.
return db_.get() ? true : false;
}
base::Time start = base::Time::Now();
......@@ -540,7 +542,10 @@ void SQLitePersistentCookieStore::Backend::ChainLoadCookies(
bool load_success = true;
if (keys_to_load_.size() > 0) {
if (!db_.get()) {
// Close() has been called on this store.
load_success = false;
} else if (keys_to_load_.size() > 0) {
// Load cookies for the first domain key.
std::map<std::string, std::set<std::string> >::iterator
it = keys_to_load_.begin();
......@@ -871,7 +876,7 @@ void SQLitePersistentCookieStore::Backend::Flush(Task* completion_task) {
}
// Fire off a close message to the background thread. We could still have a
// pending commit timer that will be holding a reference on us, but if/when
// pending commit timer or Load operations holding references on us, but if/when
// this fires we will already have been cleaned up and it will be ignored.
void SQLitePersistentCookieStore::Backend::Close() {
if (BrowserThread::CurrentlyOn(BrowserThread::DB)) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment