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

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

Issue 24734007: Encrypt all stored cookies on selected operating systems. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed perftest Created 7 years, 2 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
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 "content/browser/net/sqlite_persistent_cookie_store.h" 5 #include "content/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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 // disk on the BG runner every 30 seconds, 512 operations, or call to Flush(), 67 // disk on the BG runner every 30 seconds, 512 operations, or call to Flush(),
68 // whichever occurs first. 68 // whichever occurs first.
69 class SQLitePersistentCookieStore::Backend 69 class SQLitePersistentCookieStore::Backend
70 : public base::RefCountedThreadSafe<SQLitePersistentCookieStore::Backend> { 70 : public base::RefCountedThreadSafe<SQLitePersistentCookieStore::Backend> {
71 public: 71 public:
72 Backend( 72 Backend(
73 const base::FilePath& path, 73 const base::FilePath& path,
74 const scoped_refptr<base::SequencedTaskRunner>& client_task_runner, 74 const scoped_refptr<base::SequencedTaskRunner>& client_task_runner,
75 const scoped_refptr<base::SequencedTaskRunner>& background_task_runner, 75 const scoped_refptr<base::SequencedTaskRunner>& background_task_runner,
76 bool restore_old_session_cookies, 76 bool restore_old_session_cookies,
77 quota::SpecialStoragePolicy* special_storage_policy) 77 quota::SpecialStoragePolicy* special_storage_policy,
78 CookieCryptoDelegate* crypto_delegate)
78 : path_(path), 79 : path_(path),
79 num_pending_(0), 80 num_pending_(0),
80 force_keep_session_state_(false), 81 force_keep_session_state_(false),
81 initialized_(false), 82 initialized_(false),
82 corruption_detected_(false), 83 corruption_detected_(false),
83 restore_old_session_cookies_(restore_old_session_cookies), 84 restore_old_session_cookies_(restore_old_session_cookies),
84 special_storage_policy_(special_storage_policy), 85 special_storage_policy_(special_storage_policy),
85 num_cookies_read_(0), 86 num_cookies_read_(0),
86 client_task_runner_(client_task_runner), 87 client_task_runner_(client_task_runner),
87 background_task_runner_(background_task_runner), 88 background_task_runner_(background_task_runner),
88 num_priority_waiting_(0), 89 num_priority_waiting_(0),
89 total_priority_requests_(0) {} 90 total_priority_requests_(0),
91 crypto_(crypto_delegate) {}
90 92
91 // Creates or loads the SQLite database. 93 // Creates or loads the SQLite database.
92 void Load(const LoadedCallback& loaded_callback); 94 void Load(const LoadedCallback& loaded_callback);
93 95
94 // Loads cookies for the domain key (eTLD+1). 96 // Loads cookies for the domain key (eTLD+1).
95 void LoadCookiesForKey(const std::string& domain, 97 void LoadCookiesForKey(const std::string& domain,
96 const LoadedCallback& loaded_callback); 98 const LoadedCallback& loaded_callback);
97 99
98 // Batch a cookie addition. 100 // Batch a cookie addition.
99 void AddCookie(const net::CanonicalCookie& cc); 101 void AddCookie(const net::CanonicalCookie& cc);
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 // starting/completing priority loads or completing the total load). 264 // starting/completing priority loads or completing the total load).
263 base::Lock metrics_lock_; 265 base::Lock metrics_lock_;
264 int num_priority_waiting_; 266 int num_priority_waiting_;
265 // The total number of priority requests. 267 // The total number of priority requests.
266 int total_priority_requests_; 268 int total_priority_requests_;
267 // The time when |num_priority_waiting_| incremented to 1. 269 // The time when |num_priority_waiting_| incremented to 1.
268 base::Time current_priority_wait_start_; 270 base::Time current_priority_wait_start_;
269 // The cumulative duration of time when |num_priority_waiting_| was greater 271 // The cumulative duration of time when |num_priority_waiting_| was greater
270 // than 1. 272 // than 1.
271 base::TimeDelta priority_wait_duration_; 273 base::TimeDelta priority_wait_duration_;
274 // Class with functions that do cryptographic operations (for protecting
275 // cookies stored persistently).
276 scoped_ptr<CookieCryptoDelegate> crypto_;
272 277
273 DISALLOW_COPY_AND_ASSIGN(Backend); 278 DISALLOW_COPY_AND_ASSIGN(Backend);
274 }; 279 };
275 280
276 namespace { 281 namespace {
277 282
278 // Version number of the database. 283 // Version number of the database.
279 // 284 //
285 // Version 7 adds encrypted values. Old values will continue to be used but
286 // all new values written will be encrypted on selected operating systems.
287 //
280 // Version 6 adds cookie priorities. This allows developers to influence the 288 // Version 6 adds cookie priorities. This allows developers to influence the
281 // order in which cookies are evicted in order to meet domain cookie limits. 289 // order in which cookies are evicted in order to meet domain cookie limits.
282 // 290 //
283 // Version 5 adds the columns has_expires and is_persistent, so that the 291 // Version 5 adds the columns has_expires and is_persistent, so that the
284 // database can store session cookies as well as persistent cookies. Databases 292 // database can store session cookies as well as persistent cookies. Databases
285 // of version 5 are incompatible with older versions of code. If a database of 293 // of version 5 are incompatible with older versions of code. If a database of
286 // version 5 is read by older code, session cookies will be treated as normal 294 // version 5 is read by older code, session cookies will be treated as normal
287 // cookies. Currently, these fields are written, but not read anymore. 295 // cookies. Currently, these fields are written, but not read anymore.
288 // 296 //
289 // In version 4, we migrated the time epoch. If you open the DB with an older 297 // In version 4, we migrated the time epoch. If you open the DB with an older
290 // version on Mac or Linux, the times will look wonky, but the file will likely 298 // version on Mac or Linux, the times will look wonky, but the file will likely
291 // be usable. On Windows version 3 and 4 are the same. 299 // be usable. On Windows version 3 and 4 are the same.
292 // 300 //
293 // Version 3 updated the database to include the last access time, so we can 301 // Version 3 updated the database to include the last access time, so we can
294 // expire them in decreasing order of use when we've reached the maximum 302 // expire them in decreasing order of use when we've reached the maximum
295 // number of cookies. 303 // number of cookies.
296 const int kCurrentVersionNumber = 6; 304 const int kCurrentVersionNumber = 7;
297 const int kCompatibleVersionNumber = 5; 305 const int kCompatibleVersionNumber = 5;
erikwright (departed) 2013/10/07 20:39:25 This needs to be 7. Some of the cookies will have
bcwhite 2013/10/08 16:10:25 If an encrypted value was written, the cookie "val
Scott Hess - ex-Googler 2013/10/08 17:11:54 If the database compatible version is too new, I b
bcwhite 2013/10/08 18:23:36 Yes, older code writes data that is correct for ne
erikwright (departed) 2013/10/08 18:41:52 Either way, I'm not sure that it is a good idea to
bcwhite 2013/10/08 20:18:09 A down-grade would mean sending empty cookie value
298 306
299 // Possible values for the 'priority' column. 307 // Possible values for the 'priority' column.
300 enum DBCookiePriority { 308 enum DBCookiePriority {
301 kCookiePriorityLow = 0, 309 kCookiePriorityLow = 0,
302 kCookiePriorityMedium = 1, 310 kCookiePriorityMedium = 1,
303 kCookiePriorityHigh = 2, 311 kCookiePriorityHigh = 2,
304 }; 312 };
305 313
306 DBCookiePriority CookiePriorityToDBCookiePriority(net::CookiePriority value) { 314 DBCookiePriority CookiePriorityToDBCookiePriority(net::CookiePriority value) {
307 switch (value) { 315 switch (value) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 std::string stmt(base::StringPrintf( 368 std::string stmt(base::StringPrintf(
361 "CREATE TABLE cookies (" 369 "CREATE TABLE cookies ("
362 "creation_utc INTEGER NOT NULL UNIQUE PRIMARY KEY," 370 "creation_utc INTEGER NOT NULL UNIQUE PRIMARY KEY,"
363 "host_key TEXT NOT NULL," 371 "host_key TEXT NOT NULL,"
364 "name TEXT NOT NULL," 372 "name TEXT NOT NULL,"
365 "value TEXT NOT NULL," 373 "value TEXT NOT NULL,"
366 "path TEXT NOT NULL," 374 "path TEXT NOT NULL,"
367 "expires_utc INTEGER NOT NULL," 375 "expires_utc INTEGER NOT NULL,"
368 "secure INTEGER NOT NULL," 376 "secure INTEGER NOT NULL,"
369 "httponly INTEGER NOT NULL," 377 "httponly INTEGER NOT NULL,"
370 "last_access_utc INTEGER NOT NULL, " 378 "last_access_utc INTEGER NOT NULL,"
371 "has_expires INTEGER NOT NULL DEFAULT 1, " 379 "has_expires INTEGER NOT NULL DEFAULT 1,"
372 "persistent INTEGER NOT NULL DEFAULT 1," 380 "persistent INTEGER NOT NULL DEFAULT 1,"
373 "priority INTEGER NOT NULL DEFAULT %d)", 381 "priority INTEGER NOT NULL DEFAULT %d,"
382 "encrypted_value BLOB NOT NULL)",
Scott Hess - ex-Googler 2013/10/08 17:11:54 This will result in different schema depending on
bcwhite 2013/10/08 18:23:36 It never will. The existing upgrades add columns
Scott Hess - ex-Googler 2013/10/08 19:13:51 Unfortunately, I didn't review those, or didn't ca
bcwhite 2013/10/08 20:18:09 So... to be sure I understand what you're saying..
Scott Hess - ex-Googler 2013/10/08 21:22:12 Yes. I want the semantics of the field you are ad
bcwhite 2013/10/10 17:19:30 Done. I just wanted to be sure I understood your
374 CookiePriorityToDBCookiePriority(net::COOKIE_PRIORITY_DEFAULT))); 383 CookiePriorityToDBCookiePriority(net::COOKIE_PRIORITY_DEFAULT)));
375 if (!db->Execute(stmt.c_str())) 384 if (!db->Execute(stmt.c_str()))
376 return false; 385 return false;
377 } 386 }
378 387
379 // Older code created an index on creation_utc, which is already 388 // Older code created an index on creation_utc, which is already
380 // primary key for the table. 389 // primary key for the table.
381 if (!db->Execute("DROP INDEX IF EXISTS cookie_times")) 390 if (!db->Execute("DROP INDEX IF EXISTS cookie_times"))
382 return false; 391 return false;
383 392
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 } 681 }
673 682
674 bool SQLitePersistentCookieStore::Backend::LoadCookiesForDomains( 683 bool SQLitePersistentCookieStore::Backend::LoadCookiesForDomains(
675 const std::set<std::string>& domains) { 684 const std::set<std::string>& domains) {
676 DCHECK(background_task_runner_->RunsTasksOnCurrentThread()); 685 DCHECK(background_task_runner_->RunsTasksOnCurrentThread());
677 686
678 sql::Statement smt; 687 sql::Statement smt;
679 if (restore_old_session_cookies_) { 688 if (restore_old_session_cookies_) {
680 smt.Assign(db_->GetCachedStatement( 689 smt.Assign(db_->GetCachedStatement(
681 SQL_FROM_HERE, 690 SQL_FROM_HERE,
682 "SELECT creation_utc, host_key, name, value, path, expires_utc, " 691 "SELECT creation_utc, host_key, name, value, encrypted_value, path, "
683 "secure, httponly, last_access_utc, has_expires, persistent, priority " 692 "expires_utc, secure, httponly, last_access_utc, has_expires, "
684 "FROM cookies WHERE host_key = ?")); 693 "persistent, priority FROM cookies WHERE host_key = ?"));
685 } else { 694 } else {
686 smt.Assign(db_->GetCachedStatement( 695 smt.Assign(db_->GetCachedStatement(
687 SQL_FROM_HERE, 696 SQL_FROM_HERE,
688 "SELECT creation_utc, host_key, name, value, path, expires_utc, " 697 "SELECT creation_utc, host_key, name, value, encrypted_value, path, "
689 "secure, httponly, last_access_utc, has_expires, persistent, priority " 698 "expires_utc, secure, httponly, last_access_utc, has_expires, "
690 "FROM cookies WHERE host_key = ? AND persistent = 1")); 699 "persistent, priority FROM cookies WHERE host_key = ? "
700 "AND persistent = 1"));
691 } 701 }
692 if (!smt.is_valid()) { 702 if (!smt.is_valid()) {
693 smt.Clear(); // Disconnect smt_ref from db_. 703 smt.Clear(); // Disconnect smt_ref from db_.
694 meta_table_.Reset(); 704 meta_table_.Reset();
695 db_.reset(); 705 db_.reset();
696 return false; 706 return false;
697 } 707 }
698 708
699 std::vector<net::CanonicalCookie*> cookies; 709 std::vector<net::CanonicalCookie*> cookies;
700 std::set<std::string>::const_iterator it = domains.begin(); 710 std::set<std::string>::const_iterator it = domains.begin();
701 for (; it != domains.end(); ++it) { 711 for (; it != domains.end(); ++it) {
702 smt.BindString(0, *it); 712 smt.BindString(0, *it);
703 while (smt.Step()) { 713 while (smt.Step()) {
714 std::string value = smt.ColumnString(3);
erikwright (departed) 2013/10/07 20:39:25 How about accessing smt.ColumnString(3) only if en
bcwhite 2013/10/08 20:18:09 Done.
715 std::string encrypted_value = smt.ColumnString(4);
716 if (!encrypted_value.empty() && crypto_.get())
erikwright (departed) 2013/10/07 20:39:25 I think it's a serious error condition if there is
bcwhite 2013/10/08 16:10:25 Done.
717 crypto_->DecryptString(encrypted_value, &value);
704 scoped_ptr<net::CanonicalCookie> cc(new net::CanonicalCookie( 718 scoped_ptr<net::CanonicalCookie> cc(new net::CanonicalCookie(
705 // The "source" URL is not used with persisted cookies. 719 // The "source" URL is not used with persisted cookies.
706 GURL(), // Source 720 GURL(), // Source
707 smt.ColumnString(2), // name 721 smt.ColumnString(2), // name
708 smt.ColumnString(3), // value 722 value, // value
709 smt.ColumnString(1), // domain 723 smt.ColumnString(1), // domain
710 smt.ColumnString(4), // path 724 smt.ColumnString(5), // path
711 Time::FromInternalValue(smt.ColumnInt64(0)), // creation_utc 725 Time::FromInternalValue(smt.ColumnInt64(0)), // creation_utc
712 Time::FromInternalValue(smt.ColumnInt64(5)), // expires_utc 726 Time::FromInternalValue(smt.ColumnInt64(6)), // expires_utc
713 Time::FromInternalValue(smt.ColumnInt64(8)), // last_access_utc 727 Time::FromInternalValue(smt.ColumnInt64(9)), // last_access_utc
714 smt.ColumnInt(6) != 0, // secure 728 smt.ColumnInt(7) != 0, // secure
715 smt.ColumnInt(7) != 0, // httponly 729 smt.ColumnInt(8) != 0, // httponly
716 DBCookiePriorityToCookiePriority( 730 DBCookiePriorityToCookiePriority(
717 static_cast<DBCookiePriority>(smt.ColumnInt(11))))); // priority 731 static_cast<DBCookiePriority>(smt.ColumnInt(12))))); // priority
718 DLOG_IF(WARNING, 732 DLOG_IF(WARNING,
719 cc->CreationDate() > Time::Now()) << L"CreationDate too recent"; 733 cc->CreationDate() > Time::Now()) << L"CreationDate too recent";
720 cookies_per_origin_[CookieOrigin(cc->Domain(), cc->IsSecure())]++; 734 cookies_per_origin_[CookieOrigin(cc->Domain(), cc->IsSecure())]++;
721 cookies.push_back(cc.release()); 735 cookies.push_back(cc.release());
722 ++num_cookies_read_; 736 ++num_cookies_read_;
723 } 737 }
724 smt.Reset(true); 738 smt.Reset(true);
725 } 739 }
726 { 740 {
727 base::AutoLock locked(lock_); 741 base::AutoLock locked(lock_);
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
830 } 844 }
831 ++cur_version; 845 ++cur_version;
832 meta_table_.SetVersionNumber(cur_version); 846 meta_table_.SetVersionNumber(cur_version);
833 meta_table_.SetCompatibleVersionNumber( 847 meta_table_.SetCompatibleVersionNumber(
834 std::min(cur_version, kCompatibleVersionNumber)); 848 std::min(cur_version, kCompatibleVersionNumber));
835 transaction.Commit(); 849 transaction.Commit();
836 UMA_HISTOGRAM_TIMES("Cookie.TimeDatabaseMigrationToV6", 850 UMA_HISTOGRAM_TIMES("Cookie.TimeDatabaseMigrationToV6",
837 base::TimeTicks::Now() - start_time); 851 base::TimeTicks::Now() - start_time);
838 } 852 }
839 853
854 if (cur_version == 6) {
855 const base::TimeTicks start_time = base::TimeTicks::Now();
856 sql::Transaction transaction(db_.get());
857 if (!transaction.Begin())
858 return false;
859 // Alter the table to add empty "encrypted value" column.
860 std::string stmt(base::StringPrintf(
861 "ALTER TABLE cookies ADD COLUMN encrypted_value BLOB DEFAULT ''"));
erikwright (departed) 2013/10/07 20:39:25 IIUC the migration path makes this nullable with d
bcwhite 2013/10/08 16:10:25 The other upgrade blocks don't include "not null"
Scott Hess - ex-Googler 2013/10/08 17:11:54 ALTER...ADD changes the schema info, but does not
862 if (!db_->Execute(stmt.c_str())) {
863 LOG(WARNING) << "Unable to update cookie database to version 7.";
864 return false;
865 }
866 ++cur_version;
867 meta_table_.SetVersionNumber(cur_version);
868 meta_table_.SetCompatibleVersionNumber(
869 std::min(cur_version, kCompatibleVersionNumber));
870 transaction.Commit();
871 UMA_HISTOGRAM_TIMES("Cookie.TimeDatabaseMigrationToV7",
872 base::TimeTicks::Now() - start_time);
873 }
874
840 // Put future migration cases here. 875 // Put future migration cases here.
841 876
842 if (cur_version < kCurrentVersionNumber) { 877 if (cur_version < kCurrentVersionNumber) {
843 UMA_HISTOGRAM_COUNTS_100("Cookie.CorruptMetaTable", 1); 878 UMA_HISTOGRAM_COUNTS_100("Cookie.CorruptMetaTable", 1);
844 879
845 meta_table_.Reset(); 880 meta_table_.Reset();
846 db_.reset(new sql::Connection); 881 db_.reset(new sql::Connection);
847 if (!base::DeleteFile(path_, false) || 882 if (!base::DeleteFile(path_, false) ||
848 !db_->Open(path_) || 883 !db_->Open(path_) ||
849 !meta_table_.Init( 884 !meta_table_.Init(
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
914 base::AutoLock locked(lock_); 949 base::AutoLock locked(lock_);
915 pending_.swap(ops); 950 pending_.swap(ops);
916 num_pending_ = 0; 951 num_pending_ = 0;
917 } 952 }
918 953
919 // Maybe an old timer fired or we are already Close()'ed. 954 // Maybe an old timer fired or we are already Close()'ed.
920 if (!db_.get() || ops.empty()) 955 if (!db_.get() || ops.empty())
921 return; 956 return;
922 957
923 sql::Statement add_smt(db_->GetCachedStatement(SQL_FROM_HERE, 958 sql::Statement add_smt(db_->GetCachedStatement(SQL_FROM_HERE,
924 "INSERT INTO cookies (creation_utc, host_key, name, value, path, " 959 "INSERT INTO cookies (creation_utc, host_key, name, value, "
925 "expires_utc, secure, httponly, last_access_utc, has_expires, " 960 "encrypted_value, path, expires_utc, secure, httponly, last_access_utc, "
926 "persistent, priority) " 961 "has_expires, persistent, priority) "
927 "VALUES (?,?,?,?,?,?,?,?,?,?,?,?)")); 962 "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)"));
928 if (!add_smt.is_valid()) 963 if (!add_smt.is_valid())
929 return; 964 return;
930 965
931 sql::Statement update_access_smt(db_->GetCachedStatement(SQL_FROM_HERE, 966 sql::Statement update_access_smt(db_->GetCachedStatement(SQL_FROM_HERE,
932 "UPDATE cookies SET last_access_utc=? WHERE creation_utc=?")); 967 "UPDATE cookies SET last_access_utc=? WHERE creation_utc=?"));
933 if (!update_access_smt.is_valid()) 968 if (!update_access_smt.is_valid())
934 return; 969 return;
935 970
936 sql::Statement del_smt(db_->GetCachedStatement(SQL_FROM_HERE, 971 sql::Statement del_smt(db_->GetCachedStatement(SQL_FROM_HERE,
937 "DELETE FROM cookies WHERE creation_utc=?")); 972 "DELETE FROM cookies WHERE creation_utc=?"));
938 if (!del_smt.is_valid()) 973 if (!del_smt.is_valid())
939 return; 974 return;
940 975
941 sql::Transaction transaction(db_.get()); 976 sql::Transaction transaction(db_.get());
942 if (!transaction.Begin()) 977 if (!transaction.Begin())
943 return; 978 return;
944 979
945 for (PendingOperationsList::iterator it = ops.begin(); 980 for (PendingOperationsList::iterator it = ops.begin();
946 it != ops.end(); ++it) { 981 it != ops.end(); ++it) {
947 // Free the cookies as we commit them to the database. 982 // Free the cookies as we commit them to the database.
948 scoped_ptr<PendingOperation> po(*it); 983 scoped_ptr<PendingOperation> po(*it);
949 switch (po->op()) { 984 switch (po->op()) {
950 case PendingOperation::COOKIE_ADD: 985 case PendingOperation::COOKIE_ADD:
951 cookies_per_origin_[ 986 cookies_per_origin_[
952 CookieOrigin(po->cc().Domain(), po->cc().IsSecure())]++; 987 CookieOrigin(po->cc().Domain(), po->cc().IsSecure())]++;
953 add_smt.Reset(true); 988 add_smt.Reset(true);
954 add_smt.BindInt64(0, po->cc().CreationDate().ToInternalValue()); 989 add_smt.BindInt64(0, po->cc().CreationDate().ToInternalValue());
955 add_smt.BindString(1, po->cc().Domain()); 990 add_smt.BindString(1, po->cc().Domain());
956 add_smt.BindString(2, po->cc().Name()); 991 add_smt.BindString(2, po->cc().Name());
957 add_smt.BindString(3, po->cc().Value()); 992 if (crypto_.get()) {
958 add_smt.BindString(4, po->cc().Path()); 993 std::string encrypted_value;
959 add_smt.BindInt64(5, po->cc().ExpiryDate().ToInternalValue()); 994 add_smt.BindString(3, std::string()); // value
960 add_smt.BindInt(6, po->cc().IsSecure()); 995 crypto_->EncryptString(po->cc().Value(), &encrypted_value);
961 add_smt.BindInt(7, po->cc().IsHttpOnly()); 996 add_smt.BindBlob(4, encrypted_value.data(),
erikwright (departed) 2013/10/07 20:39:25 This looks like it's refering to memory that will
bcwhite 2013/10/08 16:10:25 Excellent catch! I missed that when I moved the v
Scott Hess - ex-Googler 2013/10/08 17:11:54 BindBlob() uses SQLITE_TRANSIENT, which means SQLi
962 add_smt.BindInt64(8, po->cc().LastAccessDate().ToInternalValue()); 997 static_cast<int>(encrypted_value.length()));
963 add_smt.BindInt(9, po->cc().IsPersistent()); 998 } else {
999 add_smt.BindString(3, po->cc().Value());
1000 add_smt.BindBlob(4, "", 0); // encrypted_value
erikwright (departed) 2013/10/07 20:39:25 Presumably NULL could be used in place of '\0' sin
bcwhite 2013/10/08 16:10:25 Doing this will try to set the value of the field
1001 }
1002 add_smt.BindString(5, po->cc().Path());
1003 add_smt.BindInt64(6, po->cc().ExpiryDate().ToInternalValue());
1004 add_smt.BindInt(7, po->cc().IsSecure());
1005 add_smt.BindInt(8, po->cc().IsHttpOnly());
1006 add_smt.BindInt64(9, po->cc().LastAccessDate().ToInternalValue());
964 add_smt.BindInt(10, po->cc().IsPersistent()); 1007 add_smt.BindInt(10, po->cc().IsPersistent());
1008 add_smt.BindInt(11, po->cc().IsPersistent());
965 add_smt.BindInt( 1009 add_smt.BindInt(
966 11, CookiePriorityToDBCookiePriority(po->cc().Priority())); 1010 12, CookiePriorityToDBCookiePriority(po->cc().Priority()));
967 if (!add_smt.Run()) 1011 if (!add_smt.Run())
968 NOTREACHED() << "Could not add a cookie to the DB."; 1012 NOTREACHED() << "Could not add a cookie to the DB.";
969 break; 1013 break;
970 1014
971 case PendingOperation::COOKIE_UPDATEACCESS: 1015 case PendingOperation::COOKIE_UPDATEACCESS:
972 update_access_smt.Reset(true); 1016 update_access_smt.Reset(true);
973 update_access_smt.BindInt64(0, 1017 update_access_smt.BindInt64(0,
974 po->cc().LastAccessDate().ToInternalValue()); 1018 po->cc().LastAccessDate().ToInternalValue());
975 update_access_smt.BindInt64(1, 1019 update_access_smt.BindInt64(1,
976 po->cc().CreationDate().ToInternalValue()); 1020 po->cc().CreationDate().ToInternalValue());
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
1142 LOG(WARNING) << "Failed to post task from " << origin.ToString() 1186 LOG(WARNING) << "Failed to post task from " << origin.ToString()
1143 << " to client_task_runner_."; 1187 << " to client_task_runner_.";
1144 } 1188 }
1145 } 1189 }
1146 1190
1147 SQLitePersistentCookieStore::SQLitePersistentCookieStore( 1191 SQLitePersistentCookieStore::SQLitePersistentCookieStore(
1148 const base::FilePath& path, 1192 const base::FilePath& path,
1149 const scoped_refptr<base::SequencedTaskRunner>& client_task_runner, 1193 const scoped_refptr<base::SequencedTaskRunner>& client_task_runner,
1150 const scoped_refptr<base::SequencedTaskRunner>& background_task_runner, 1194 const scoped_refptr<base::SequencedTaskRunner>& background_task_runner,
1151 bool restore_old_session_cookies, 1195 bool restore_old_session_cookies,
1152 quota::SpecialStoragePolicy* special_storage_policy) 1196 quota::SpecialStoragePolicy* special_storage_policy,
1197 CookieCryptoDelegate* crypto_delegate)
1153 : backend_(new Backend(path, 1198 : backend_(new Backend(path,
1154 client_task_runner, 1199 client_task_runner,
1155 background_task_runner, 1200 background_task_runner,
1156 restore_old_session_cookies, 1201 restore_old_session_cookies,
1157 special_storage_policy)) { 1202 special_storage_policy,
1203 crypto_delegate)) {
1158 } 1204 }
1159 1205
1160 void SQLitePersistentCookieStore::Load(const LoadedCallback& loaded_callback) { 1206 void SQLitePersistentCookieStore::Load(const LoadedCallback& loaded_callback) {
1161 backend_->Load(loaded_callback); 1207 backend_->Load(loaded_callback);
1162 } 1208 }
1163 1209
1164 void SQLitePersistentCookieStore::LoadCookiesForKey( 1210 void SQLitePersistentCookieStore::LoadCookiesForKey(
1165 const std::string& key, 1211 const std::string& key,
1166 const LoadedCallback& loaded_callback) { 1212 const LoadedCallback& loaded_callback) {
1167 backend_->LoadCookiesForKey(key, loaded_callback); 1213 backend_->LoadCookiesForKey(key, loaded_callback);
(...skipping 24 matching lines...) Expand all
1192 backend_->Close(); 1238 backend_->Close();
1193 // We release our reference to the Backend, though it will probably still have 1239 // We release our reference to the Backend, though it will probably still have
1194 // a reference if the background runner has not run Close() yet. 1240 // a reference if the background runner has not run Close() yet.
1195 } 1241 }
1196 1242
1197 net::CookieStore* CreatePersistentCookieStore( 1243 net::CookieStore* CreatePersistentCookieStore(
1198 const base::FilePath& path, 1244 const base::FilePath& path,
1199 bool restore_old_session_cookies, 1245 bool restore_old_session_cookies,
1200 quota::SpecialStoragePolicy* storage_policy, 1246 quota::SpecialStoragePolicy* storage_policy,
1201 net::CookieMonster::Delegate* cookie_monster_delegate, 1247 net::CookieMonster::Delegate* cookie_monster_delegate,
1202 const scoped_refptr<base::SequencedTaskRunner>& background_task_runner) { 1248 const scoped_refptr<base::SequencedTaskRunner>& background_task_runner,
1249 CookieCryptoDelegate* crypto_delegate) {
1203 SQLitePersistentCookieStore* persistent_store = 1250 SQLitePersistentCookieStore* persistent_store =
1204 new SQLitePersistentCookieStore( 1251 new SQLitePersistentCookieStore(
1205 path, 1252 path,
1206 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), 1253 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO),
1207 background_task_runner.get() ? background_task_runner : 1254 background_task_runner.get() ? background_task_runner :
1208 BrowserThread::GetBlockingPool()->GetSequencedTaskRunner( 1255 BrowserThread::GetBlockingPool()->GetSequencedTaskRunner(
1209 BrowserThread::GetBlockingPool()->GetSequenceToken()), 1256 BrowserThread::GetBlockingPool()->GetSequenceToken()),
1210 restore_old_session_cookies, 1257 restore_old_session_cookies,
1211 storage_policy); 1258 storage_policy,
1259 crypto_delegate);
1212 net::CookieMonster* cookie_monster = 1260 net::CookieMonster* cookie_monster =
1213 new net::CookieMonster(persistent_store, cookie_monster_delegate); 1261 new net::CookieMonster(persistent_store, cookie_monster_delegate);
1214 1262
1215 const std::string cookie_priority_experiment_group = 1263 const std::string cookie_priority_experiment_group =
1216 base::FieldTrialList::FindFullName("CookieRetentionPriorityStudy"); 1264 base::FieldTrialList::FindFullName("CookieRetentionPriorityStudy");
1217 cookie_monster->SetPriorityAwareGarbageCollection( 1265 cookie_monster->SetPriorityAwareGarbageCollection(
1218 cookie_priority_experiment_group == "ExperimentOn"); 1266 cookie_priority_experiment_group == "ExperimentOn");
1219 1267
1220 return cookie_monster; 1268 return cookie_monster;
1221 } 1269 }
1222 1270
1223 } // namespace content 1271 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698