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 750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 meta_table_.Reset(); |
773 LOG_IF(WARNING, cur_version < kCurrentVersionNumber) << | 773 db_.reset(new sql::Connection); |
774 "Cookie database version " << cur_version << " is too old to handle."; | 774 if (!file_util::Delete(path_, false) || |
Scott Hess - ex-Googler
2012/03/01 22:15:15
I am a small bit concerned about whether we'll see
erikwright (departed)
2012/03/02 01:04:27
Done.
| |
775 !db_->Open(path_) || | |
776 !meta_table_.Init( | |
777 db_.get(), kCurrentVersionNumber, kCompatibleVersionNumber)) { | |
Scott Hess - ex-Googler
2012/03/01 22:15:15
I wish this wasn't replicating other code. It als
erikwright (departed)
2012/03/02 01:04:27
The caller actually calls InitTable only if this f
| |
778 NOTREACHED() << "Unable to reset the cookie DB."; | |
779 meta_table_.Reset(); | |
780 db_.reset(); | |
781 return false; | |
782 } | |
783 } | |
775 | 784 |
776 return true; | 785 return true; |
777 } | 786 } |
778 | 787 |
779 void SQLitePersistentCookieStore::Backend::AddCookie( | 788 void SQLitePersistentCookieStore::Backend::AddCookie( |
780 const net::CookieMonster::CanonicalCookie& cc) { | 789 const net::CookieMonster::CanonicalCookie& cc) { |
781 BatchOperation(PendingOperation::COOKIE_ADD, cc); | 790 BatchOperation(PendingOperation::COOKIE_ADD, cc); |
782 } | 791 } |
783 | 792 |
784 void SQLitePersistentCookieStore::Backend::UpdateCookieAccessTime( | 793 void SQLitePersistentCookieStore::Backend::UpdateCookieAccessTime( |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1006 if (backend_.get()) | 1015 if (backend_.get()) |
1007 backend_->SetClearLocalStateOnExit(clear_local_state); | 1016 backend_->SetClearLocalStateOnExit(clear_local_state); |
1008 } | 1017 } |
1009 | 1018 |
1010 void SQLitePersistentCookieStore::Flush(const base::Closure& callback) { | 1019 void SQLitePersistentCookieStore::Flush(const base::Closure& callback) { |
1011 if (backend_.get()) | 1020 if (backend_.get()) |
1012 backend_->Flush(callback); | 1021 backend_->Flush(callback); |
1013 else if (!callback.is_null()) | 1022 else if (!callback.is_null()) |
1014 MessageLoop::current()->PostTask(FROM_HERE, callback); | 1023 MessageLoop::current()->PostTask(FROM_HERE, callback); |
1015 } | 1024 } |
OLD | NEW |