Index: chrome/browser/net/sqlite_persistent_cookie_store.cc |
diff --git a/chrome/browser/net/sqlite_persistent_cookie_store.cc b/chrome/browser/net/sqlite_persistent_cookie_store.cc |
index 6b92bfd2128b45c7f2ab55b921894128727807cf..f118744291170cca27d5bdf191db3df873c85a07 100644 |
--- a/chrome/browser/net/sqlite_persistent_cookie_store.cc |
+++ b/chrome/browser/net/sqlite_persistent_cookie_store.cc |
@@ -18,6 +18,7 @@ |
#include "base/scoped_ptr.h" |
#include "base/string_util.h" |
#include "base/threading/thread.h" |
+#include "base/threading/thread_restrictions.h" |
#include "chrome/browser/diagnostics/sqlite_diagnostics.h" |
#include "content/browser/browser_thread.h" |
#include "googleurl/src/gurl.h" |
@@ -156,6 +157,15 @@ bool SQLitePersistentCookieStore::Backend::Load( |
// This function should be called only once per instance. |
DCHECK(!db_.get()); |
+ // Ensure the parent directory for storing cookies is created before reading |
+ // from it. We make an exception to allow IO on the UI thread here because |
+ // we are going to disk anyway in db_->Open. (This code will be moved to the |
+ // DB thread as part of http://crbug.com/52909.) |
+ base::ThreadRestrictions::ScopedAllowIO allow_io; |
Matt Perry
2011/03/08 21:27:56
put this new code in an indented scope to limit th
Charlie Reis
2011/03/08 22:26:58
Done.
|
+ const FilePath dir = path_.DirName(); |
+ if (!file_util::PathExists(dir) && !file_util::CreateDirectory(dir)) |
+ return false; |
+ |
db_.reset(new sql::Connection); |
if (!db_->Open(path_)) { |
NOTREACHED() << "Unable to open cookie DB."; |