| 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 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 613 Time::FromInternalValue(smt.ColumnInt64(8)), // last_access_utc | 613 Time::FromInternalValue(smt.ColumnInt64(8)), // last_access_utc |
| 614 smt.ColumnInt(6) != 0, // secure | 614 smt.ColumnInt(6) != 0, // secure |
| 615 smt.ColumnInt(7) != 0, // httponly | 615 smt.ColumnInt(7) != 0, // httponly |
| 616 smt.ColumnInt(9) != 0, // has_expires | 616 smt.ColumnInt(9) != 0, // has_expires |
| 617 smt.ColumnInt(10) != 0)); // is_persistent | 617 smt.ColumnInt(10) != 0)); // is_persistent |
| 618 DLOG_IF(WARNING, | 618 DLOG_IF(WARNING, |
| 619 cc->CreationDate() > Time::Now()) << L"CreationDate too recent"; | 619 cc->CreationDate() > Time::Now()) << L"CreationDate too recent"; |
| 620 cookies.push_back(cc.release()); | 620 cookies.push_back(cc.release()); |
| 621 ++num_cookies_read_; | 621 ++num_cookies_read_; |
| 622 } | 622 } |
| 623 smt.Reset(); | 623 smt.Reset(true); |
| 624 } | 624 } |
| 625 { | 625 { |
| 626 base::AutoLock locked(lock_); | 626 base::AutoLock locked(lock_); |
| 627 cookies_.insert(cookies_.end(), cookies.begin(), cookies.end()); | 627 cookies_.insert(cookies_.end(), cookies.begin(), cookies.end()); |
| 628 } | 628 } |
| 629 return true; | 629 return true; |
| 630 } | 630 } |
| 631 | 631 |
| 632 bool SQLitePersistentCookieStore::Backend::EnsureDatabaseVersion() { | 632 bool SQLitePersistentCookieStore::Backend::EnsureDatabaseVersion() { |
| 633 // Version check. | 633 // Version check. |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 819 sql::Transaction transaction(db_.get()); | 819 sql::Transaction transaction(db_.get()); |
| 820 if (!transaction.Begin()) | 820 if (!transaction.Begin()) |
| 821 return; | 821 return; |
| 822 | 822 |
| 823 for (PendingOperationsList::iterator it = ops.begin(); | 823 for (PendingOperationsList::iterator it = ops.begin(); |
| 824 it != ops.end(); ++it) { | 824 it != ops.end(); ++it) { |
| 825 // Free the cookies as we commit them to the database. | 825 // Free the cookies as we commit them to the database. |
| 826 scoped_ptr<PendingOperation> po(*it); | 826 scoped_ptr<PendingOperation> po(*it); |
| 827 switch (po->op()) { | 827 switch (po->op()) { |
| 828 case PendingOperation::COOKIE_ADD: | 828 case PendingOperation::COOKIE_ADD: |
| 829 add_smt.Reset(); | 829 add_smt.Reset(true); |
| 830 add_smt.BindInt64(0, po->cc().CreationDate().ToInternalValue()); | 830 add_smt.BindInt64(0, po->cc().CreationDate().ToInternalValue()); |
| 831 add_smt.BindString(1, po->cc().Domain()); | 831 add_smt.BindString(1, po->cc().Domain()); |
| 832 add_smt.BindString(2, po->cc().Name()); | 832 add_smt.BindString(2, po->cc().Name()); |
| 833 add_smt.BindString(3, po->cc().Value()); | 833 add_smt.BindString(3, po->cc().Value()); |
| 834 add_smt.BindString(4, po->cc().Path()); | 834 add_smt.BindString(4, po->cc().Path()); |
| 835 add_smt.BindInt64(5, po->cc().ExpiryDate().ToInternalValue()); | 835 add_smt.BindInt64(5, po->cc().ExpiryDate().ToInternalValue()); |
| 836 add_smt.BindInt(6, po->cc().IsSecure()); | 836 add_smt.BindInt(6, po->cc().IsSecure()); |
| 837 add_smt.BindInt(7, po->cc().IsHttpOnly()); | 837 add_smt.BindInt(7, po->cc().IsHttpOnly()); |
| 838 add_smt.BindInt64(8, po->cc().LastAccessDate().ToInternalValue()); | 838 add_smt.BindInt64(8, po->cc().LastAccessDate().ToInternalValue()); |
| 839 add_smt.BindInt(9, po->cc().DoesExpire()); | 839 add_smt.BindInt(9, po->cc().DoesExpire()); |
| 840 add_smt.BindInt(10, po->cc().IsPersistent()); | 840 add_smt.BindInt(10, po->cc().IsPersistent()); |
| 841 if (!add_smt.Run()) | 841 if (!add_smt.Run()) |
| 842 NOTREACHED() << "Could not add a cookie to the DB."; | 842 NOTREACHED() << "Could not add a cookie to the DB."; |
| 843 break; | 843 break; |
| 844 | 844 |
| 845 case PendingOperation::COOKIE_UPDATEACCESS: | 845 case PendingOperation::COOKIE_UPDATEACCESS: |
| 846 update_access_smt.Reset(); | 846 update_access_smt.Reset(true); |
| 847 update_access_smt.BindInt64(0, | 847 update_access_smt.BindInt64(0, |
| 848 po->cc().LastAccessDate().ToInternalValue()); | 848 po->cc().LastAccessDate().ToInternalValue()); |
| 849 update_access_smt.BindInt64(1, | 849 update_access_smt.BindInt64(1, |
| 850 po->cc().CreationDate().ToInternalValue()); | 850 po->cc().CreationDate().ToInternalValue()); |
| 851 if (!update_access_smt.Run()) | 851 if (!update_access_smt.Run()) |
| 852 NOTREACHED() << "Could not update cookie last access time in the DB."; | 852 NOTREACHED() << "Could not update cookie last access time in the DB."; |
| 853 break; | 853 break; |
| 854 | 854 |
| 855 case PendingOperation::COOKIE_DELETE: | 855 case PendingOperation::COOKIE_DELETE: |
| 856 del_smt.Reset(); | 856 del_smt.Reset(true); |
| 857 del_smt.BindInt64(0, po->cc().CreationDate().ToInternalValue()); | 857 del_smt.BindInt64(0, po->cc().CreationDate().ToInternalValue()); |
| 858 if (!del_smt.Run()) | 858 if (!del_smt.Run()) |
| 859 NOTREACHED() << "Could not delete a cookie from the DB."; | 859 NOTREACHED() << "Could not delete a cookie from the DB."; |
| 860 break; | 860 break; |
| 861 | 861 |
| 862 default: | 862 default: |
| 863 NOTREACHED(); | 863 NOTREACHED(); |
| 864 break; | 864 break; |
| 865 } | 865 } |
| 866 } | 866 } |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 967 if (backend_.get()) | 967 if (backend_.get()) |
| 968 backend_->SetClearLocalStateOnExit(clear_local_state); | 968 backend_->SetClearLocalStateOnExit(clear_local_state); |
| 969 } | 969 } |
| 970 | 970 |
| 971 void SQLitePersistentCookieStore::Flush(const base::Closure& callback) { | 971 void SQLitePersistentCookieStore::Flush(const base::Closure& callback) { |
| 972 if (backend_.get()) | 972 if (backend_.get()) |
| 973 backend_->Flush(callback); | 973 backend_->Flush(callback); |
| 974 else if (!callback.is_null()) | 974 else if (!callback.is_null()) |
| 975 MessageLoop::current()->PostTask(FROM_HERE, callback); | 975 MessageLoop::current()->PostTask(FROM_HERE, callback); |
| 976 } | 976 } |
| OLD | NEW |