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

Side by Side Diff: chrome/browser/net/sqlite_persistent_cookie_store.cc

Issue 6201005: Initial support for partitioning cookies for isolated apps. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix merge conflicts. Created 9 years, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "chrome/browser/net/sqlite_persistent_cookie_store.h" 5 #include "chrome/browser/net/sqlite_persistent_cookie_store.h"
6 6
7 #include <list> 7 #include <list>
8 8
9 #include "app/sql/meta_table.h" 9 #include "app/sql/meta_table.h"
10 #include "app/sql/statement.h" 10 #include "app/sql/statement.h"
11 #include "app/sql/transaction.h" 11 #include "app/sql/transaction.h"
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/file_path.h" 13 #include "base/file_path.h"
14 #include "base/file_util.h" 14 #include "base/file_util.h"
15 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "base/metrics/histogram.h" 16 #include "base/metrics/histogram.h"
17 #include "base/ref_counted.h" 17 #include "base/ref_counted.h"
18 #include "base/scoped_ptr.h" 18 #include "base/scoped_ptr.h"
19 #include "base/string_util.h" 19 #include "base/string_util.h"
20 #include "base/threading/thread.h" 20 #include "base/threading/thread.h"
21 #include "base/threading/thread_restrictions.h"
21 #include "chrome/browser/diagnostics/sqlite_diagnostics.h" 22 #include "chrome/browser/diagnostics/sqlite_diagnostics.h"
22 #include "content/browser/browser_thread.h" 23 #include "content/browser/browser_thread.h"
23 #include "googleurl/src/gurl.h" 24 #include "googleurl/src/gurl.h"
24 25
25 using base::Time; 26 using base::Time;
26 27
27 // This class is designed to be shared between any calling threads and the 28 // This class is designed to be shared between any calling threads and the
28 // database thread. It batches operations and commits them on a timer. 29 // database thread. It batches operations and commits them on a timer.
29 class SQLitePersistentCookieStore::Backend 30 class SQLitePersistentCookieStore::Backend
30 : public base::RefCountedThreadSafe<SQLitePersistentCookieStore::Backend> { 31 : public base::RefCountedThreadSafe<SQLitePersistentCookieStore::Backend> {
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 return true; 150 return true;
150 } 151 }
151 152
152 } // namespace 153 } // namespace
153 154
154 bool SQLitePersistentCookieStore::Backend::Load( 155 bool SQLitePersistentCookieStore::Backend::Load(
155 std::vector<net::CookieMonster::CanonicalCookie*>* cookies) { 156 std::vector<net::CookieMonster::CanonicalCookie*>* cookies) {
156 // This function should be called only once per instance. 157 // This function should be called only once per instance.
157 DCHECK(!db_.get()); 158 DCHECK(!db_.get());
158 159
160 // Ensure the parent directory for storing cookies is created before reading
161 // from it. We make an exception to allow IO on the UI thread here because
162 // we are going to disk anyway in db_->Open. (This code will be moved to the
163 // DB thread as part of http://crbug.com/52909.)
164 {
165 base::ThreadRestrictions::ScopedAllowIO allow_io;
166 const FilePath dir = path_.DirName();
167 if (!file_util::PathExists(dir) && !file_util::CreateDirectory(dir))
168 return false;
169 }
170
159 db_.reset(new sql::Connection); 171 db_.reset(new sql::Connection);
160 if (!db_->Open(path_)) { 172 if (!db_->Open(path_)) {
161 NOTREACHED() << "Unable to open cookie DB."; 173 NOTREACHED() << "Unable to open cookie DB.";
162 db_.reset(); 174 db_.reset();
163 return false; 175 return false;
164 } 176 }
165 177
166 db_->set_error_delegate(GetErrorHandlerForCookieDb()); 178 db_->set_error_delegate(GetErrorHandlerForCookieDb());
167 179
168 if (!EnsureDatabaseVersion() || !InitTable(db_.get())) { 180 if (!EnsureDatabaseVersion() || !InitTable(db_.get())) {
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 if (backend_.get()) 508 if (backend_.get())
497 backend_->SetClearLocalStateOnExit(clear_local_state); 509 backend_->SetClearLocalStateOnExit(clear_local_state);
498 } 510 }
499 511
500 void SQLitePersistentCookieStore::Flush(Task* completion_task) { 512 void SQLitePersistentCookieStore::Flush(Task* completion_task) {
501 if (backend_.get()) 513 if (backend_.get())
502 backend_->Flush(completion_task); 514 backend_->Flush(completion_task);
503 else if (completion_task) 515 else if (completion_task)
504 MessageLoop::current()->PostTask(FROM_HERE, completion_task); 516 MessageLoop::current()->PostTask(FROM_HERE, completion_task);
505 } 517 }
OLDNEW
« no previous file with comments | « chrome/browser/net/chrome_url_request_context.cc ('k') | chrome/browser/notifications/balloon_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698