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

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: Style fixes. 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) {
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(
269 BrowserThread::DB,
270 FROM_HERE,
271 NewRunnableFunction<bool(*)(const FilePath&, bool), FilePath, bool>(
272 &file_util::Delete, path_, false));
Randy Smith (Not in Mondays) 2010/12/02 21:19:26 I'm willing to accept this interface, but I think
pastarmovj 2010/12/03 16:43:02 Obsoleted because of the moved logic to Backend.
273 }
264 } 274 }
265 275
266 // Version number of the database. In version 4, we migrated the time epoch. 276 // 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 277 // 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 278 // look wonky, but the file will likely be usable. On Windows version 3 and 4
269 // are the same. 279 // are the same.
270 // 280 //
271 // Version 3 updated the database to include the last access time, so we can 281 // 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 282 // expire them in decreasing order of use when we've reached the maximum
273 // number of cookies. 283 // number of cookies.
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 const net::CookieMonster::CanonicalCookie& cc) { 442 const net::CookieMonster::CanonicalCookie& cc) {
433 if (backend_.get()) 443 if (backend_.get())
434 backend_->UpdateCookieAccessTime(cc); 444 backend_->UpdateCookieAccessTime(cc);
435 } 445 }
436 446
437 void SQLitePersistentCookieStore::DeleteCookie( 447 void SQLitePersistentCookieStore::DeleteCookie(
438 const net::CookieMonster::CanonicalCookie& cc) { 448 const net::CookieMonster::CanonicalCookie& cc) {
439 if (backend_.get()) 449 if (backend_.get())
440 backend_->DeleteCookie(cc); 450 backend_->DeleteCookie(cc);
441 } 451 }
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