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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
56 // disk on the DB thread every 30 seconds, 512 operations, or call to Flush(), | 56 // disk on the DB thread every 30 seconds, 512 operations, or call to Flush(), |
57 // whichever occurs first. | 57 // whichever occurs first. |
58 class SQLitePersistentCookieStore::Backend | 58 class SQLitePersistentCookieStore::Backend |
59 : public base::RefCountedThreadSafe<SQLitePersistentCookieStore::Backend> { | 59 : public base::RefCountedThreadSafe<SQLitePersistentCookieStore::Backend> { |
60 public: | 60 public: |
61 explicit Backend(const FilePath& path) | 61 explicit Backend(const FilePath& path) |
62 : path_(path), | 62 : path_(path), |
63 db_(NULL), | 63 db_(NULL), |
64 num_pending_(0), | 64 num_pending_(0), |
65 clear_local_state_on_exit_(false), | 65 clear_local_state_on_exit_(false), |
66 clear_session_state_on_exit_(true), | |
66 initialized_(false), | 67 initialized_(false), |
67 num_priority_waiting_(0), | 68 num_priority_waiting_(0), |
68 total_priority_requests_(0) { | 69 total_priority_requests_(0) { |
69 } | 70 } |
70 | 71 |
71 // Creates or loads the SQLite database. | 72 // Creates or loads the SQLite database. |
72 void Load(const LoadedCallback& loaded_callback); | 73 void Load(const LoadedCallback& loaded_callback); |
73 | 74 |
74 // Loads cookies for the domain key (eTLD+1). | 75 // Loads cookies for the domain key (eTLD+1). |
75 void LoadCookiesForKey(const std::string& domain, | 76 void LoadCookiesForKey(const std::string& domain, |
76 const LoadedCallback& loaded_callback); | 77 const LoadedCallback& loaded_callback); |
77 | 78 |
78 // Batch a cookie addition. | 79 // Batch a cookie addition. |
79 void AddCookie(const net::CookieMonster::CanonicalCookie& cc); | 80 void AddCookie(const net::CookieMonster::CanonicalCookie& cc); |
80 | 81 |
81 // Batch a cookie access time update. | 82 // Batch a cookie access time update. |
82 void UpdateCookieAccessTime(const net::CookieMonster::CanonicalCookie& cc); | 83 void UpdateCookieAccessTime(const net::CookieMonster::CanonicalCookie& cc); |
83 | 84 |
84 // Batch a cookie deletion. | 85 // Batch a cookie deletion. |
85 void DeleteCookie(const net::CookieMonster::CanonicalCookie& cc); | 86 void DeleteCookie(const net::CookieMonster::CanonicalCookie& cc); |
86 | 87 |
87 // Commit pending operations as soon as possible. | 88 // Commit pending operations as soon as possible. |
88 void Flush(Task* completion_task); | 89 void Flush(Task* completion_task); |
89 | 90 |
90 // Commit any pending operations and close the database. This must be called | 91 // Commit any pending operations and close the database. This must be called |
91 // before the object is destructed. | 92 // before the object is destructed. |
92 void Close(); | 93 void Close(); |
93 | 94 |
94 void SetClearLocalStateOnExit(bool clear_local_state); | 95 void SetClearLocalStateOnExit(bool clear_local_state); |
96 void SetClearSessionStateOnExit(bool clear_session_state); | |
95 | 97 |
96 private: | 98 private: |
97 friend class base::RefCountedThreadSafe<SQLitePersistentCookieStore::Backend>; | 99 friend class base::RefCountedThreadSafe<SQLitePersistentCookieStore::Backend>; |
98 | 100 |
99 // You should call Close() before destructing this object. | 101 // You should call Close() before destructing this object. |
100 ~Backend() { | 102 ~Backend() { |
101 DCHECK(!db_.get()) << "Close should have already been called."; | 103 DCHECK(!db_.get()) << "Close should have already been called."; |
102 DCHECK(num_pending_ == 0 && pending_.empty()); | 104 DCHECK(num_pending_ == 0 && pending_.empty()); |
103 } | 105 } |
104 | 106 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
178 | 180 |
179 FilePath path_; | 181 FilePath path_; |
180 scoped_ptr<sql::Connection> db_; | 182 scoped_ptr<sql::Connection> db_; |
181 sql::MetaTable meta_table_; | 183 sql::MetaTable meta_table_; |
182 | 184 |
183 typedef std::list<PendingOperation*> PendingOperationsList; | 185 typedef std::list<PendingOperation*> PendingOperationsList; |
184 PendingOperationsList pending_; | 186 PendingOperationsList pending_; |
185 PendingOperationsList::size_type num_pending_; | 187 PendingOperationsList::size_type num_pending_; |
186 // True if the persistent store should be deleted upon destruction. | 188 // True if the persistent store should be deleted upon destruction. |
187 bool clear_local_state_on_exit_; | 189 bool clear_local_state_on_exit_; |
188 // Guard |cookies_|, |pending_|, |num_pending_|, |clear_local_state_on_exit_| | 190 // True if the session cookies should be deleted upon destruction. |
191 bool clear_session_state_on_exit_; | |
192 // Guard |cookies_|, |pending_|, |num_pending_|, |clear_local_state_on_exit_|, | |
193 // |clear_session_state_on_exit_|. | |
189 base::Lock lock_; | 194 base::Lock lock_; |
190 | 195 |
191 // Temporary buffer for cookies loaded from DB. Accumulates cookies to reduce | 196 // Temporary buffer for cookies loaded from DB. Accumulates cookies to reduce |
192 // the number of messages sent to the IO thread. Sent back in response to | 197 // the number of messages sent to the IO thread. Sent back in response to |
193 // individual load requests for domain keys or when all loading completes. | 198 // individual load requests for domain keys or when all loading completes. |
194 std::vector<net::CookieMonster::CanonicalCookie*> cookies_; | 199 std::vector<net::CookieMonster::CanonicalCookie*> cookies_; |
195 | 200 |
196 // Map of domain keys(eTLD+1) to domains/hosts that are to be loaded from DB. | 201 // Map of domain keys(eTLD+1) to domains/hosts that are to be loaded from DB. |
197 std::map<std::string, std::set<std::string> > keys_to_load_; | 202 std::map<std::string, std::set<std::string> > keys_to_load_; |
198 | 203 |
(...skipping 20 matching lines...) Expand all Loading... | |
219 }; | 224 }; |
220 | 225 |
221 // Version number of the database. In version 4, we migrated the time epoch. | 226 // Version number of the database. In version 4, we migrated the time epoch. |
222 // If you open the DB with an older version on Mac or Linux, the times will | 227 // If you open the DB with an older version on Mac or Linux, the times will |
223 // look wonky, but the file will likely be usable. On Windows version 3 and 4 | 228 // look wonky, but the file will likely be usable. On Windows version 3 and 4 |
224 // are the same. | 229 // are the same. |
225 // | 230 // |
226 // Version 3 updated the database to include the last access time, so we can | 231 // Version 3 updated the database to include the last access time, so we can |
227 // expire them in decreasing order of use when we've reached the maximum | 232 // expire them in decreasing order of use when we've reached the maximum |
228 // number of cookies. | 233 // number of cookies. |
229 static const int kCurrentVersionNumber = 4; | 234 static const int kCurrentVersionNumber = 5; |
230 static const int kCompatibleVersionNumber = 3; | 235 static const int kCompatibleVersionNumber = 5; |
231 | 236 |
232 namespace { | 237 namespace { |
233 | 238 |
234 // Increments a specified TimeDelta by the duration between this object's | 239 // Increments a specified TimeDelta by the duration between this object's |
235 // constructor and destructor. Not thread safe. Multiple instances may be | 240 // constructor and destructor. Not thread safe. Multiple instances may be |
236 // created with the same delta instance as long as their lifetimes are nested. | 241 // created with the same delta instance as long as their lifetimes are nested. |
237 // The shortest lived instances have no impact. | 242 // The shortest lived instances have no impact. |
238 class IncrementTimeDelta { | 243 class IncrementTimeDelta { |
239 public: | 244 public: |
240 explicit IncrementTimeDelta(base::TimeDelta* delta) : | 245 explicit IncrementTimeDelta(base::TimeDelta* delta) : |
(...skipping 15 matching lines...) Expand all Loading... | |
256 | 261 |
257 // Initializes the cookies table, returning true on success. | 262 // Initializes the cookies table, returning true on success. |
258 bool InitTable(sql::Connection* db) { | 263 bool InitTable(sql::Connection* db) { |
259 if (!db->DoesTableExist("cookies")) { | 264 if (!db->DoesTableExist("cookies")) { |
260 if (!db->Execute("CREATE TABLE cookies (" | 265 if (!db->Execute("CREATE TABLE cookies (" |
261 "creation_utc INTEGER NOT NULL UNIQUE PRIMARY KEY," | 266 "creation_utc INTEGER NOT NULL UNIQUE PRIMARY KEY," |
262 "host_key TEXT NOT NULL," | 267 "host_key TEXT NOT NULL," |
263 "name TEXT NOT NULL," | 268 "name TEXT NOT NULL," |
264 "value TEXT NOT NULL," | 269 "value TEXT NOT NULL," |
265 "path TEXT NOT NULL," | 270 "path TEXT NOT NULL," |
266 // We only store persistent, so we know it expires | |
267 "expires_utc INTEGER NOT NULL," | 271 "expires_utc INTEGER NOT NULL," |
268 "secure INTEGER NOT NULL," | 272 "secure INTEGER NOT NULL," |
269 "httponly INTEGER NOT NULL," | 273 "httponly INTEGER NOT NULL," |
270 "last_access_utc INTEGER NOT NULL)")) | 274 "last_access_utc INTEGER NOT NULL," |
275 "has_expires INTEGER NOT NULL," | |
276 "persistent INTEGER NOT NULL)")) | |
271 return false; | 277 return false; |
272 } | 278 } |
273 | 279 |
274 // Try to create the index every time. Older versions did not have this index, | 280 // Try to create the index every time. Older versions did not have this index, |
275 // so we want those people to get it. Ignore errors, since it may exist. | 281 // so we want those people to get it. Ignore errors, since it may exist. |
276 db->Execute("CREATE INDEX IF NOT EXISTS cookie_times ON cookies" | 282 db->Execute("CREATE INDEX IF NOT EXISTS cookie_times ON cookies" |
277 " (creation_utc)"); | 283 " (creation_utc)"); |
278 | 284 |
279 db->Execute("CREATE INDEX IF NOT EXISTS domain ON cookies(host_key)"); | 285 db->Execute("CREATE INDEX IF NOT EXISTS domain ON cookies(host_key)"); |
280 | 286 |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
500 this, loaded_callback, load_success)); | 506 this, loaded_callback, load_success)); |
501 } | 507 } |
502 } | 508 } |
503 | 509 |
504 bool SQLitePersistentCookieStore::Backend::LoadCookiesForDomains( | 510 bool SQLitePersistentCookieStore::Backend::LoadCookiesForDomains( |
505 const std::set<std::string>& domains) { | 511 const std::set<std::string>& domains) { |
506 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 512 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
507 | 513 |
508 sql::Statement smt(db_->GetCachedStatement(SQL_FROM_HERE, | 514 sql::Statement smt(db_->GetCachedStatement(SQL_FROM_HERE, |
509 "SELECT creation_utc, host_key, name, value, path, expires_utc, secure, " | 515 "SELECT creation_utc, host_key, name, value, path, expires_utc, secure, " |
510 "httponly, last_access_utc FROM cookies WHERE host_key = ?")); | 516 "httponly, last_access_utc, has_expires, persistent FROM cookies " |
517 "WHERE host_key = ?")); | |
511 if (!smt) { | 518 if (!smt) { |
512 NOTREACHED() << "select statement prep failed"; | 519 NOTREACHED() << "select statement prep failed"; |
513 db_.reset(); | 520 db_.reset(); |
514 return false; | 521 return false; |
515 } | 522 } |
516 | 523 |
517 std::vector<net::CookieMonster::CanonicalCookie*> cookies; | 524 std::vector<net::CookieMonster::CanonicalCookie*> cookies; |
518 std::set<std::string>::const_iterator it = domains.begin(); | 525 std::set<std::string>::const_iterator it = domains.begin(); |
519 for (; it != domains.end(); ++it) { | 526 for (; it != domains.end(); ++it) { |
520 smt.BindString(0, *it); | 527 smt.BindString(0, *it); |
521 while (smt.Step()) { | 528 while (smt.Step()) { |
522 scoped_ptr<net::CookieMonster::CanonicalCookie> cc( | 529 scoped_ptr<net::CookieMonster::CanonicalCookie> cc( |
523 new net::CookieMonster::CanonicalCookie( | 530 new net::CookieMonster::CanonicalCookie( |
524 // The "source" URL is not used with persisted cookies. | 531 // The "source" URL is not used with persisted cookies. |
525 GURL(), // Source | 532 GURL(), // Source |
526 smt.ColumnString(2), // name | 533 smt.ColumnString(2), // name |
527 smt.ColumnString(3), // value | 534 smt.ColumnString(3), // value |
528 smt.ColumnString(1), // domain | 535 smt.ColumnString(1), // domain |
529 smt.ColumnString(4), // path | 536 smt.ColumnString(4), // path |
530 std::string(), // TODO(abarth): Persist mac_key | 537 std::string(), // TODO(abarth): Persist mac_key |
531 std::string(), // TODO(abarth): Persist mac_algorithm | 538 std::string(), // TODO(abarth): Persist mac_algorithm |
532 Time::FromInternalValue(smt.ColumnInt64(0)), // creation_utc | 539 Time::FromInternalValue(smt.ColumnInt64(0)), // creation_utc |
533 Time::FromInternalValue(smt.ColumnInt64(5)), // expires_utc | 540 Time::FromInternalValue(smt.ColumnInt64(5)), // expires_utc |
534 Time::FromInternalValue(smt.ColumnInt64(8)), // last_access_utc | 541 Time::FromInternalValue(smt.ColumnInt64(8)), // last_access_utc |
535 smt.ColumnInt(6) != 0, // secure | 542 smt.ColumnInt(6) != 0, // secure |
536 smt.ColumnInt(7) != 0, // httponly | 543 smt.ColumnInt(7) != 0, // httponly |
537 true, // has_expires | 544 smt.ColumnInt(9) != 0, // has_expires |
538 true)); // is_persistent | 545 smt.ColumnInt(10) != 0)); // is_persistent |
539 DLOG_IF(WARNING, | 546 DLOG_IF(WARNING, |
540 cc->CreationDate() > Time::Now()) << L"CreationDate too recent"; | 547 cc->CreationDate() > Time::Now()) << L"CreationDate too recent"; |
541 cookies.push_back(cc.release()); | 548 cookies.push_back(cc.release()); |
542 } | 549 } |
543 smt.Reset(); | 550 smt.Reset(); |
544 } | 551 } |
545 { | 552 { |
546 base::AutoLock locked(lock_); | 553 base::AutoLock locked(lock_); |
547 cookies_.insert(cookies_.end(), cookies.begin(), cookies.end()); | 554 cookies_.insert(cookies_.end(), cookies.begin(), cookies.end()); |
548 } | 555 } |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
606 "SET last_access_utc = last_access_utc + 11644473600000000 " | 613 "SET last_access_utc = last_access_utc + 11644473600000000 " |
607 "WHERE rowid IN " | 614 "WHERE rowid IN " |
608 "(SELECT rowid FROM cookies WHERE " | 615 "(SELECT rowid FROM cookies WHERE " |
609 "last_access_utc > 0 AND last_access_utc < 11644473600000000)"); | 616 "last_access_utc > 0 AND last_access_utc < 11644473600000000)"); |
610 #endif | 617 #endif |
611 ++cur_version; | 618 ++cur_version; |
612 meta_table_.SetVersionNumber(cur_version); | 619 meta_table_.SetVersionNumber(cur_version); |
613 transaction.Commit(); | 620 transaction.Commit(); |
614 } | 621 } |
615 | 622 |
623 if (cur_version == 4) { | |
624 sql::Transaction transaction(db_.get()); | |
625 if (!transaction.Begin()) | |
626 return false; | |
627 if (!db_->Execute("ALTER TABLE cookies " | |
628 "ADD COLUMN has_expires INTEGER DEFAULT 1") || | |
629 !db_->Execute("ALTER TABLE cookies " | |
630 "ADD COLUMN persistent INTEGER DEFAULT 1")) { | |
631 LOG(WARNING) << "Unable to update cookie database to version 5."; | |
632 return false; | |
633 } | |
634 ++cur_version; | |
635 meta_table_.SetVersionNumber(cur_version); | |
636 meta_table_.SetCompatibleVersionNumber( | |
637 std::min(cur_version, kCompatibleVersionNumber)); | |
638 transaction.Commit(); | |
639 } | |
640 | |
616 // Put future migration cases here. | 641 // Put future migration cases here. |
617 | 642 |
618 // When the version is too old, we just try to continue anyway, there should | 643 // When the version is too old, we just try to continue anyway, there should |
619 // not be a released product that makes a database too old for us to handle. | 644 // not be a released product that makes a database too old for us to handle. |
620 LOG_IF(WARNING, cur_version < kCurrentVersionNumber) << | 645 LOG_IF(WARNING, cur_version < kCurrentVersionNumber) << |
621 "Cookie database version " << cur_version << " is too old to handle."; | 646 "Cookie database version " << cur_version << " is too old to handle."; |
622 | 647 |
623 return true; | 648 return true; |
624 } | 649 } |
625 | 650 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
679 pending_.swap(ops); | 704 pending_.swap(ops); |
680 num_pending_ = 0; | 705 num_pending_ = 0; |
681 } | 706 } |
682 | 707 |
683 // Maybe an old timer fired or we are already Close()'ed. | 708 // Maybe an old timer fired or we are already Close()'ed. |
684 if (!db_.get() || ops.empty()) | 709 if (!db_.get() || ops.empty()) |
685 return; | 710 return; |
686 | 711 |
687 sql::Statement add_smt(db_->GetCachedStatement(SQL_FROM_HERE, | 712 sql::Statement add_smt(db_->GetCachedStatement(SQL_FROM_HERE, |
688 "INSERT INTO cookies (creation_utc, host_key, name, value, path, " | 713 "INSERT INTO cookies (creation_utc, host_key, name, value, path, " |
689 "expires_utc, secure, httponly, last_access_utc) " | 714 "expires_utc, secure, httponly, last_access_utc, has_expires, " |
690 "VALUES (?,?,?,?,?,?,?,?,?)")); | 715 "persistent) " |
716 "VALUES (?,?,?,?,?,?,?,?,?,?,?)")); | |
691 if (!add_smt) { | 717 if (!add_smt) { |
692 NOTREACHED(); | 718 NOTREACHED(); |
693 return; | 719 return; |
694 } | 720 } |
695 | 721 |
696 sql::Statement update_access_smt(db_->GetCachedStatement(SQL_FROM_HERE, | 722 sql::Statement update_access_smt(db_->GetCachedStatement(SQL_FROM_HERE, |
697 "UPDATE cookies SET last_access_utc=? WHERE creation_utc=?")); | 723 "UPDATE cookies SET last_access_utc=? WHERE creation_utc=?")); |
698 if (!update_access_smt) { | 724 if (!update_access_smt) { |
699 NOTREACHED(); | 725 NOTREACHED(); |
700 return; | 726 return; |
(...skipping 20 matching lines...) Expand all Loading... | |
721 add_smt.Reset(); | 747 add_smt.Reset(); |
722 add_smt.BindInt64(0, po->cc().CreationDate().ToInternalValue()); | 748 add_smt.BindInt64(0, po->cc().CreationDate().ToInternalValue()); |
723 add_smt.BindString(1, po->cc().Domain()); | 749 add_smt.BindString(1, po->cc().Domain()); |
724 add_smt.BindString(2, po->cc().Name()); | 750 add_smt.BindString(2, po->cc().Name()); |
725 add_smt.BindString(3, po->cc().Value()); | 751 add_smt.BindString(3, po->cc().Value()); |
726 add_smt.BindString(4, po->cc().Path()); | 752 add_smt.BindString(4, po->cc().Path()); |
727 add_smt.BindInt64(5, po->cc().ExpiryDate().ToInternalValue()); | 753 add_smt.BindInt64(5, po->cc().ExpiryDate().ToInternalValue()); |
728 add_smt.BindInt(6, po->cc().IsSecure()); | 754 add_smt.BindInt(6, po->cc().IsSecure()); |
729 add_smt.BindInt(7, po->cc().IsHttpOnly()); | 755 add_smt.BindInt(7, po->cc().IsHttpOnly()); |
730 add_smt.BindInt64(8, po->cc().LastAccessDate().ToInternalValue()); | 756 add_smt.BindInt64(8, po->cc().LastAccessDate().ToInternalValue()); |
757 add_smt.BindInt(9, po->cc().DoesExpire()); | |
758 add_smt.BindInt(10, po->cc().IsPersistent()); | |
731 if (!add_smt.Run()) | 759 if (!add_smt.Run()) |
732 NOTREACHED() << "Could not add a cookie to the DB."; | 760 NOTREACHED() << "Could not add a cookie to the DB."; |
733 break; | 761 break; |
734 | 762 |
735 case PendingOperation::COOKIE_UPDATEACCESS: | 763 case PendingOperation::COOKIE_UPDATEACCESS: |
736 update_access_smt.Reset(); | 764 update_access_smt.Reset(); |
737 update_access_smt.BindInt64(0, | 765 update_access_smt.BindInt64(0, |
738 po->cc().LastAccessDate().ToInternalValue()); | 766 po->cc().LastAccessDate().ToInternalValue()); |
739 update_access_smt.BindInt64(1, | 767 update_access_smt.BindInt64(1, |
740 po->cc().CreationDate().ToInternalValue()); | 768 po->cc().CreationDate().ToInternalValue()); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
783 BrowserThread::DB, FROM_HERE, | 811 BrowserThread::DB, FROM_HERE, |
784 base::Bind(&Backend::InternalBackgroundClose, this)); | 812 base::Bind(&Backend::InternalBackgroundClose, this)); |
785 } | 813 } |
786 } | 814 } |
787 | 815 |
788 void SQLitePersistentCookieStore::Backend::InternalBackgroundClose() { | 816 void SQLitePersistentCookieStore::Backend::InternalBackgroundClose() { |
789 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 817 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
790 // Commit any pending operations | 818 // Commit any pending operations |
791 Commit(); | 819 Commit(); |
792 | 820 |
821 // Delete session cookies, but only if we're not going to delete the whole DB. | |
822 if (!clear_local_state_on_exit_ && clear_session_state_on_exit_) { | |
823 if (InitializeDatabase()) { | |
824 DCHECK(db_.get()); | |
825 if (!db_->Execute("DELETE FROM cookies WHERE persistent == 0")) | |
jochen (gone - plz use gerrit)
2011/11/25 14:45:14
maybe add a field that says "discard session cooki
marja
2011/11/28 15:22:01
In the latest version, it uses the "did chrome cra
| |
826 LOG(WARNING) << "Unable to delete session cookies."; | |
827 } | |
828 } | |
829 | |
793 db_.reset(); | 830 db_.reset(); |
794 | 831 |
795 if (clear_local_state_on_exit_) | 832 if (clear_local_state_on_exit_) |
796 file_util::Delete(path_, false); | 833 file_util::Delete(path_, false); |
797 } | 834 } |
798 | 835 |
799 void SQLitePersistentCookieStore::Backend::SetClearLocalStateOnExit( | 836 void SQLitePersistentCookieStore::Backend::SetClearLocalStateOnExit( |
800 bool clear_local_state) { | 837 bool clear_local_state) { |
801 base::AutoLock locked(lock_); | 838 base::AutoLock locked(lock_); |
802 clear_local_state_on_exit_ = clear_local_state; | 839 clear_local_state_on_exit_ = clear_local_state; |
803 } | 840 } |
841 | |
842 void SQLitePersistentCookieStore::Backend::SetClearSessionStateOnExit( | |
843 bool clear_session_state) { | |
844 base::AutoLock locked(lock_); | |
845 clear_session_state_on_exit_ = clear_session_state; | |
846 } | |
847 | |
804 SQLitePersistentCookieStore::SQLitePersistentCookieStore(const FilePath& path) | 848 SQLitePersistentCookieStore::SQLitePersistentCookieStore(const FilePath& path) |
805 : backend_(new Backend(path)) { | 849 : backend_(new Backend(path)) { |
806 } | 850 } |
807 | 851 |
808 SQLitePersistentCookieStore::~SQLitePersistentCookieStore() { | 852 SQLitePersistentCookieStore::~SQLitePersistentCookieStore() { |
809 if (backend_.get()) { | 853 if (backend_.get()) { |
810 backend_->Close(); | 854 backend_->Close(); |
811 // Release our reference, it will probably still have a reference if the | 855 // Release our reference, it will probably still have a reference if the |
812 // background thread has not run Close() yet. | 856 // background thread has not run Close() yet. |
813 backend_ = NULL; | 857 backend_ = NULL; |
(...skipping 27 matching lines...) Expand all Loading... | |
841 if (backend_.get()) | 885 if (backend_.get()) |
842 backend_->DeleteCookie(cc); | 886 backend_->DeleteCookie(cc); |
843 } | 887 } |
844 | 888 |
845 void SQLitePersistentCookieStore::SetClearLocalStateOnExit( | 889 void SQLitePersistentCookieStore::SetClearLocalStateOnExit( |
846 bool clear_local_state) { | 890 bool clear_local_state) { |
847 if (backend_.get()) | 891 if (backend_.get()) |
848 backend_->SetClearLocalStateOnExit(clear_local_state); | 892 backend_->SetClearLocalStateOnExit(clear_local_state); |
849 } | 893 } |
850 | 894 |
895 void SQLitePersistentCookieStore::SetClearSessionStateOnExit( | |
896 bool clear_session_state) { | |
897 if (backend_.get()) | |
898 backend_->SetClearSessionStateOnExit(clear_session_state); | |
899 } | |
900 | |
851 void SQLitePersistentCookieStore::Flush(Task* completion_task) { | 901 void SQLitePersistentCookieStore::Flush(Task* completion_task) { |
852 if (backend_.get()) | 902 if (backend_.get()) |
853 backend_->Flush(completion_task); | 903 backend_->Flush(completion_task); |
854 else if (completion_task) | 904 else if (completion_task) |
855 MessageLoop::current()->PostTask(FROM_HERE, completion_task); | 905 MessageLoop::current()->PostTask(FROM_HERE, completion_task); |
856 } | 906 } |
OLD | NEW |