Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 540 if (file_util::GetFileSize(path_, &db_size)) | 540 if (file_util::GetFileSize(path_, &db_size)) |
| 541 UMA_HISTOGRAM_COUNTS("Cookie.DBSizeInKB", db_size / 1024 ); | 541 UMA_HISTOGRAM_COUNTS("Cookie.DBSizeInKB", db_size / 1024 ); |
| 542 | 542 |
| 543 db_.reset(new sql::Connection); | 543 db_.reset(new sql::Connection); |
| 544 db_->set_error_histogram_name("Sqlite.Cookie.Error"); | 544 db_->set_error_histogram_name("Sqlite.Cookie.Error"); |
| 545 db_->set_error_delegate(new KillDatabaseErrorDelegate(this)); | 545 db_->set_error_delegate(new KillDatabaseErrorDelegate(this)); |
| 546 | 546 |
| 547 if (!db_->Open(path_)) { | 547 if (!db_->Open(path_)) { |
| 548 NOTREACHED() << "Unable to open cookie DB."; | 548 NOTREACHED() << "Unable to open cookie DB."; |
| 549 if (corruption_detected_) | 549 if (corruption_detected_) |
| 550 db_->Raze(); | 550 db_->Raze(); |
|
pkotwicz
2013/01/31 19:22:00
Comment: In a future CL, it would be nice to be ab
Scott Hess - ex-Googler
2013/02/05 01:20:25
I think the long-term goal for this code (and othe
| |
| 551 meta_table_.Reset(); | 551 meta_table_.Reset(); |
| 552 db_.reset(); | 552 db_.reset(); |
| 553 return false; | 553 return false; |
| 554 } | 554 } |
| 555 | 555 |
| 556 if (!EnsureDatabaseVersion() || !InitTable(db_.get())) { | 556 if (!EnsureDatabaseVersion() || !InitTable(db_.get())) { |
| 557 NOTREACHED() << "Unable to open cookie DB."; | 557 NOTREACHED() << "Unable to open cookie DB."; |
| 558 if (corruption_detected_) | 558 if (corruption_detected_) |
| 559 db_->Raze(); | 559 db_->Raze(); |
| 560 meta_table_.Reset(); | 560 meta_table_.Reset(); |
| (...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1037 MessageLoop::current()->PostTask( | 1037 MessageLoop::current()->PostTask( |
| 1038 FROM_HERE, base::Bind(&Backend::KillDatabase, this)); | 1038 FROM_HERE, base::Bind(&Backend::KillDatabase, this)); |
| 1039 } | 1039 } |
| 1040 | 1040 |
| 1041 void SQLitePersistentCookieStore::Backend::KillDatabase() { | 1041 void SQLitePersistentCookieStore::Backend::KillDatabase() { |
| 1042 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 1042 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
| 1043 | 1043 |
| 1044 if (db_.get()) { | 1044 if (db_.get()) { |
| 1045 // This Backend will now be in-memory only. In a future run we will recreate | 1045 // This Backend will now be in-memory only. In a future run we will recreate |
| 1046 // the database. Hopefully things go better then! | 1046 // the database. Hopefully things go better then! |
| 1047 bool success = db_->Raze(); | 1047 bool success = db_->RazeAndClose(); |
| 1048 UMA_HISTOGRAM_BOOLEAN("Cookie.KillDatabaseResult", success); | 1048 UMA_HISTOGRAM_BOOLEAN("Cookie.KillDatabaseResult", success); |
| 1049 db_->Close(); | |
| 1050 meta_table_.Reset(); | 1049 meta_table_.Reset(); |
| 1051 db_.reset(); | 1050 db_.reset(); |
| 1052 } | 1051 } |
| 1053 } | 1052 } |
| 1054 | 1053 |
| 1055 void SQLitePersistentCookieStore::Backend::SetForceKeepSessionState() { | 1054 void SQLitePersistentCookieStore::Backend::SetForceKeepSessionState() { |
| 1056 base::AutoLock locked(lock_); | 1055 base::AutoLock locked(lock_); |
| 1057 force_keep_session_state_ = true; | 1056 force_keep_session_state_ = true; |
| 1058 } | 1057 } |
| 1059 | 1058 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1100 | 1099 |
| 1101 void SQLitePersistentCookieStore::Flush(const base::Closure& callback) { | 1100 void SQLitePersistentCookieStore::Flush(const base::Closure& callback) { |
| 1102 backend_->Flush(callback); | 1101 backend_->Flush(callback); |
| 1103 } | 1102 } |
| 1104 | 1103 |
| 1105 SQLitePersistentCookieStore::~SQLitePersistentCookieStore() { | 1104 SQLitePersistentCookieStore::~SQLitePersistentCookieStore() { |
| 1106 backend_->Close(); | 1105 backend_->Close(); |
| 1107 // We release our reference to the Backend, though it will probably still have | 1106 // We release our reference to the Backend, though it will probably still have |
| 1108 // a reference if the background thread has not run Close() yet. | 1107 // a reference if the background thread has not run Close() yet. |
| 1109 } | 1108 } |
| OLD | NEW |