OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
562 this, loaded_callback, load_success)); | 562 this, loaded_callback, load_success)); |
563 if (!restore_old_session_cookies_) | 563 if (!restore_old_session_cookies_) |
564 DeleteSessionCookies(); | 564 DeleteSessionCookies(); |
565 } | 565 } |
566 } | 566 } |
567 | 567 |
568 bool SQLitePersistentCookieStore::Backend::LoadCookiesForDomains( | 568 bool SQLitePersistentCookieStore::Backend::LoadCookiesForDomains( |
569 const std::set<std::string>& domains) { | 569 const std::set<std::string>& domains) { |
570 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 570 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
571 | 571 |
572 const char* sql; | 572 sql::Statement smt; |
573 if (restore_old_session_cookies_) { | 573 if (restore_old_session_cookies_) { |
574 sql = | 574 smt.Assign(db_->GetCachedStatement( |
575 "SELECT creation_utc, host_key, name, value, path, expires_utc, " | 575 SQL_FROM_HERE, |
576 "secure, httponly, last_access_utc, has_expires, persistent " | 576 "SELECT creation_utc, host_key, name, value, path, expires_utc, " |
577 "FROM cookies WHERE host_key = ?"; | 577 "secure, httponly, last_access_utc, has_expires, persistent " |
| 578 "FROM cookies WHERE host_key = ?")); |
578 } else { | 579 } else { |
579 sql = | 580 smt.Assign(db_->GetCachedStatement( |
580 "SELECT creation_utc, host_key, name, value, path, expires_utc, " | 581 SQL_FROM_HERE, |
581 "secure, httponly, last_access_utc, has_expires, persistent " | 582 "SELECT creation_utc, host_key, name, value, path, expires_utc, " |
582 "FROM cookies WHERE host_key = ? AND persistent == 1"; | 583 "secure, httponly, last_access_utc, has_expires, persistent " |
| 584 "FROM cookies WHERE host_key = ? AND persistent = 1")); |
583 } | 585 } |
584 sql::Statement smt(db_->GetCachedStatement(SQL_FROM_HERE, sql)); | |
585 if (!smt) { | 586 if (!smt) { |
586 NOTREACHED() << "select statement prep failed"; | 587 NOTREACHED() << "select statement prep failed"; |
587 db_.reset(); | 588 db_.reset(); |
588 return false; | 589 return false; |
589 } | 590 } |
590 | 591 |
591 std::vector<net::CookieMonster::CanonicalCookie*> cookies; | 592 std::vector<net::CookieMonster::CanonicalCookie*> cookies; |
592 std::set<std::string>::const_iterator it = domains.begin(); | 593 std::set<std::string>::const_iterator it = domains.begin(); |
593 for (; it != domains.end(); ++it) { | 594 for (; it != domains.end(); ++it) { |
594 smt.BindString(0, *it); | 595 smt.BindString(0, *it); |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
955 if (backend_.get()) | 956 if (backend_.get()) |
956 backend_->SetClearLocalStateOnExit(clear_local_state); | 957 backend_->SetClearLocalStateOnExit(clear_local_state); |
957 } | 958 } |
958 | 959 |
959 void SQLitePersistentCookieStore::Flush(Task* completion_task) { | 960 void SQLitePersistentCookieStore::Flush(Task* completion_task) { |
960 if (backend_.get()) | 961 if (backend_.get()) |
961 backend_->Flush(completion_task); | 962 backend_->Flush(completion_task); |
962 else if (completion_task) | 963 else if (completion_task) |
963 MessageLoop::current()->PostTask(FROM_HERE, completion_task); | 964 MessageLoop::current()->PostTask(FROM_HERE, completion_task); |
964 } | 965 } |
OLD | NEW |