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

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

Issue 9602001: Reinitialize the cookie database if the meta table gets corrupted. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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
« no previous file with comments | « no previous file | chrome/browser/net/sqlite_persistent_cookie_store_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 750 matching lines...) Expand 10 before | Expand all | Expand 10 after
761 meta_table_.SetVersionNumber(cur_version); 761 meta_table_.SetVersionNumber(cur_version);
762 meta_table_.SetCompatibleVersionNumber( 762 meta_table_.SetCompatibleVersionNumber(
763 std::min(cur_version, kCompatibleVersionNumber)); 763 std::min(cur_version, kCompatibleVersionNumber));
764 transaction.Commit(); 764 transaction.Commit();
765 UMA_HISTOGRAM_TIMES("Cookie.TimeDatabaseMigrationToV5", 765 UMA_HISTOGRAM_TIMES("Cookie.TimeDatabaseMigrationToV5",
766 base::TimeTicks::Now() - start_time); 766 base::TimeTicks::Now() - start_time);
767 } 767 }
768 768
769 // Put future migration cases here. 769 // Put future migration cases here.
770 770
771 // When the version is too old, we just try to continue anyway, there should 771 if (cur_version < kCurrentVersionNumber) {
772 // not be a released product that makes a database too old for us to handle. 772 UMA_HISTOGRAM_COUNTS_100("Cookie.CorruptMetaTable", 1);
773 LOG_IF(WARNING, cur_version < kCurrentVersionNumber) << 773
774 "Cookie database version " << cur_version << " is too old to handle."; 774 meta_table_.Reset();
775 db_.reset(new sql::Connection);
776 if (!file_util::Delete(path_, false) ||
777 !db_->Open(path_) ||
778 !meta_table_.Init(
779 db_.get(), kCurrentVersionNumber, kCompatibleVersionNumber)) {
780 UMA_HISTOGRAM_COUNTS_100("Cookie.CorruptMetaTableRecoveryFailed", 1);
781 NOTREACHED() << "Unable to reset the cookie DB.";
782 meta_table_.Reset();
783 db_.reset();
784 return false;
785 }
786 }
775 787
776 return true; 788 return true;
777 } 789 }
778 790
779 void SQLitePersistentCookieStore::Backend::AddCookie( 791 void SQLitePersistentCookieStore::Backend::AddCookie(
780 const net::CookieMonster::CanonicalCookie& cc) { 792 const net::CookieMonster::CanonicalCookie& cc) {
781 BatchOperation(PendingOperation::COOKIE_ADD, cc); 793 BatchOperation(PendingOperation::COOKIE_ADD, cc);
782 } 794 }
783 795
784 void SQLitePersistentCookieStore::Backend::UpdateCookieAccessTime( 796 void SQLitePersistentCookieStore::Backend::UpdateCookieAccessTime(
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
1006 if (backend_.get()) 1018 if (backend_.get())
1007 backend_->SetClearLocalStateOnExit(clear_local_state); 1019 backend_->SetClearLocalStateOnExit(clear_local_state);
1008 } 1020 }
1009 1021
1010 void SQLitePersistentCookieStore::Flush(const base::Closure& callback) { 1022 void SQLitePersistentCookieStore::Flush(const base::Closure& callback) {
1011 if (backend_.get()) 1023 if (backend_.get())
1012 backend_->Flush(callback); 1024 backend_->Flush(callback);
1013 else if (!callback.is_null()) 1025 else if (!callback.is_null())
1014 MessageLoop::current()->PostTask(FROM_HERE, callback); 1026 MessageLoop::current()->PostTask(FROM_HERE, callback);
1015 } 1027 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/net/sqlite_persistent_cookie_store_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698