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

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

Issue 5430004: Refactored cookies persistent store clean-up on shutdown. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added unit test and moved flag to the persistence store itself. Created 10 years 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/statement.h" 9 #include "app/sql/statement.h"
10 #include "app/sql/transaction.h" 10 #include "app/sql/transaction.h"
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 void SQLitePersistentCookieStore::Backend::InternalBackgroundClose() { 244 void SQLitePersistentCookieStore::Backend::InternalBackgroundClose() {
245 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); 245 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
246 // Commit any pending operations 246 // Commit any pending operations
247 Commit(); 247 Commit();
248 248
249 delete db_; 249 delete db_;
250 db_ = NULL; 250 db_ = NULL;
251 } 251 }
252 252
253 SQLitePersistentCookieStore::SQLitePersistentCookieStore(const FilePath& path) 253 SQLitePersistentCookieStore::SQLitePersistentCookieStore(const FilePath& path)
254 : path_(path) { 254 : path_(path),
255 clear_local_state_on_exit_(false) {
jochen (gone - plz use gerrit) 2010/12/02 15:09:51 i'd push this even further down to the backend. in
pastarmovj 2010/12/02 16:29:07 The backend doesn't know the file name now and I d
255 } 256 }
256 257
257 SQLitePersistentCookieStore::~SQLitePersistentCookieStore() { 258 SQLitePersistentCookieStore::~SQLitePersistentCookieStore() {
258 if (backend_.get()) { 259 if (backend_.get()) {
259 backend_->Close(); 260 backend_->Close();
260 // Release our reference, it will probably still have a reference if the 261 // Release our reference, it will probably still have a reference if the
261 // background thread has not run Close() yet. 262 // background thread has not run Close() yet.
262 backend_ = NULL; 263 backend_ = NULL;
263 } 264 }
265 if (clear_local_state_on_exit_) {
266 // To avoid concurrent run with possibly not finished file close op on the
267 // DB thread we delete the file on the same thread as well.
268 BrowserThread::PostTask(BrowserThread::DB,
269 FROM_HERE,
270 NewRunnableFunction(
271 &file_util::Delete, path_, false));
272 }
264 } 273 }
265 274
266 // Version number of the database. In version 4, we migrated the time epoch. 275 // Version number of the database. In version 4, we migrated the time epoch.
267 // If you open the DB with an older version on Mac or Linux, the times will 276 // If you open the DB with an older version on Mac or Linux, the times will
268 // look wonky, but the file will likely be usable. On Windows version 3 and 4 277 // look wonky, but the file will likely be usable. On Windows version 3 and 4
269 // are the same. 278 // are the same.
270 // 279 //
271 // Version 3 updated the database to include the last access time, so we can 280 // Version 3 updated the database to include the last access time, so we can
272 // expire them in decreasing order of use when we've reached the maximum 281 // expire them in decreasing order of use when we've reached the maximum
273 // number of cookies. 282 // number of cookies.
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 const net::CookieMonster::CanonicalCookie& cc) { 441 const net::CookieMonster::CanonicalCookie& cc) {
433 if (backend_.get()) 442 if (backend_.get())
434 backend_->UpdateCookieAccessTime(cc); 443 backend_->UpdateCookieAccessTime(cc);
435 } 444 }
436 445
437 void SQLitePersistentCookieStore::DeleteCookie( 446 void SQLitePersistentCookieStore::DeleteCookie(
438 const net::CookieMonster::CanonicalCookie& cc) { 447 const net::CookieMonster::CanonicalCookie& cc) {
439 if (backend_.get()) 448 if (backend_.get())
440 backend_->DeleteCookie(cc); 449 backend_->DeleteCookie(cc);
441 } 450 }
442
443 // static
444 void SQLitePersistentCookieStore::ClearLocalState(
445 const FilePath& path) {
446 file_util::Delete(path, false);
447 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698