| 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 // Portions of this code based on Mozilla: | 5 // Portions of this code based on Mozilla: |
| 6 // (netwerk/cookie/src/nsCookieService.cpp) | 6 // (netwerk/cookie/src/nsCookieService.cpp) |
| 7 /* ***** BEGIN LICENSE BLOCK ***** | 7 /* ***** BEGIN LICENSE BLOCK ***** |
| 8 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 | 8 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
| 9 * | 9 * |
| 10 * The contents of this file are subject to the Mozilla Public License Version | 10 * The contents of this file are subject to the Mozilla Public License Version |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 * | 42 * |
| 43 * ***** END LICENSE BLOCK ***** */ | 43 * ***** END LICENSE BLOCK ***** */ |
| 44 | 44 |
| 45 #include "net/base/cookie_monster.h" | 45 #include "net/base/cookie_monster.h" |
| 46 | 46 |
| 47 #include <algorithm> | 47 #include <algorithm> |
| 48 #include <set> | 48 #include <set> |
| 49 | 49 |
| 50 #include "base/basictypes.h" | 50 #include "base/basictypes.h" |
| 51 #include "base/bind.h" | 51 #include "base/bind.h" |
| 52 #include "base/callback.h" | |
| 53 #include "base/format_macros.h" | 52 #include "base/format_macros.h" |
| 54 #include "base/logging.h" | 53 #include "base/logging.h" |
| 55 #include "base/memory/scoped_ptr.h" | 54 #include "base/memory/scoped_ptr.h" |
| 56 #include "base/message_loop.h" | 55 #include "base/message_loop.h" |
| 57 #include "base/message_loop_proxy.h" | 56 #include "base/message_loop_proxy.h" |
| 58 #include "base/metrics/histogram.h" | 57 #include "base/metrics/histogram.h" |
| 59 #include "base/string_tokenizer.h" | 58 #include "base/string_tokenizer.h" |
| 60 #include "base/string_util.h" | 59 #include "base/string_util.h" |
| 61 #include "base/stringprintf.h" | 60 #include "base/stringprintf.h" |
| 62 #include "googleurl/src/gurl.h" | 61 #include "googleurl/src/gurl.h" |
| 63 #include "googleurl/src/url_canon.h" | 62 #include "googleurl/src/url_canon.h" |
| 64 #include "net/base/net_util.h" | 63 #include "net/base/net_util.h" |
| 65 #include "net/base/registry_controlled_domain.h" | 64 #include "net/base/registry_controlled_domain.h" |
| 66 | 65 |
| 67 using base::Time; | 66 using base::Time; |
| 68 using base::TimeDelta; | 67 using base::TimeDelta; |
| 69 using base::TimeTicks; | 68 using base::TimeTicks; |
| 70 | 69 |
| 71 // In steady state, most cookie requests can be satisfied by the in memory | |
| 72 // cookie monster store. However, if a request comes in during the initial | |
| 73 // cookie load, it must be delayed until that load completes. That is done by | |
| 74 // queueing it on CookieMonster::queue_ and running it when notification of | |
| 75 // cookie load completion is received via CookieMonster::OnLoaded. This callback | |
| 76 // is passed to the persistent store from CookieMonster::InitStore(), which is | |
| 77 // called on the first operation invoked on the CookieMonster. | |
| 78 // | |
| 79 // On the browser critical paths (e.g. for loading initial web pages in a | |
| 80 // session restore) it may take too long to wait for the full load. If a cookie | |
| 81 // request is for a specific URL, DoCookieTaskForURL is called, which triggers a | |
| 82 // priority load if the key is not loaded yet by calling PersistentCookieStore | |
| 83 // :: LoadCookiesForKey. The request is queued in CookieMonster::tasks_queued | |
| 84 // and executed upon receiving notification of key load completion via | |
| 85 // CookieMonster::OnKeyLoaded(). If multiple requests for the same eTLD+1 are | |
| 86 // received before key load completion, only the first request calls | |
| 87 // PersistentCookieStore::LoadCookiesForKey, all subsequent requests are queued | |
| 88 // in CookieMonster::tasks_queued and executed upon receiving notification of | |
| 89 // key load completion triggered by the first request for the same eTLD+1. | |
| 90 | |
| 91 static const int kMinutesInTenYears = 10 * 365 * 24 * 60; | 70 static const int kMinutesInTenYears = 10 * 365 * 24 * 60; |
| 92 | 71 |
| 93 namespace net { | 72 namespace net { |
| 94 | 73 |
| 95 // See comments at declaration of these variables in cookie_monster.h | 74 // See comments at declaration of these variables in cookie_monster.h |
| 96 // for details. | 75 // for details. |
| 97 const size_t CookieMonster::kDomainMaxCookies = 180; | 76 const size_t CookieMonster::kDomainMaxCookies = 180; |
| 98 const size_t CookieMonster::kDomainPurgeCookies = 30; | 77 const size_t CookieMonster::kDomainPurgeCookies = 30; |
| 99 const size_t CookieMonster::kMaxCookies = 3300; | 78 const size_t CookieMonster::kMaxCookies = 3300; |
| 100 const size_t CookieMonster::kPurgeCookies = 300; | 79 const size_t CookieMonster::kPurgeCookies = 300; |
| (...skipping 906 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1007 void CookieMonster::SetCookieWithDetailsAsync( | 986 void CookieMonster::SetCookieWithDetailsAsync( |
| 1008 const GURL& url, const std::string& name, const std::string& value, | 987 const GURL& url, const std::string& name, const std::string& value, |
| 1009 const std::string& domain, const std::string& path, | 988 const std::string& domain, const std::string& path, |
| 1010 const base::Time& expiration_time, bool secure, bool http_only, | 989 const base::Time& expiration_time, bool secure, bool http_only, |
| 1011 const SetCookiesCallback& callback) { | 990 const SetCookiesCallback& callback) { |
| 1012 scoped_refptr<SetCookieWithDetailsTask> task = | 991 scoped_refptr<SetCookieWithDetailsTask> task = |
| 1013 new SetCookieWithDetailsTask(this, url, name, value, domain, path, | 992 new SetCookieWithDetailsTask(this, url, name, value, domain, path, |
| 1014 expiration_time, secure, http_only, | 993 expiration_time, secure, http_only, |
| 1015 callback); | 994 callback); |
| 1016 | 995 |
| 1017 DoCookieTaskForURL(task, url); | 996 DoCookieTask(task); |
| 1018 } | 997 } |
| 1019 | 998 |
| 1020 void CookieMonster::GetAllCookiesAsync(const GetCookieListCallback& callback) { | 999 void CookieMonster::GetAllCookiesAsync(const GetCookieListCallback& callback) { |
| 1021 scoped_refptr<GetAllCookiesTask> task = | 1000 scoped_refptr<GetAllCookiesTask> task = |
| 1022 new GetAllCookiesTask(this, callback); | 1001 new GetAllCookiesTask(this, callback); |
| 1023 | 1002 |
| 1024 DoCookieTask(task); | 1003 DoCookieTask(task); |
| 1025 } | 1004 } |
| 1026 | 1005 |
| 1027 | 1006 |
| 1028 void CookieMonster::GetAllCookiesForURLWithOptionsAsync( | 1007 void CookieMonster::GetAllCookiesForURLWithOptionsAsync( |
| 1029 const GURL& url, | 1008 const GURL& url, |
| 1030 const CookieOptions& options, | 1009 const CookieOptions& options, |
| 1031 const GetCookieListCallback& callback) { | 1010 const GetCookieListCallback& callback) { |
| 1032 scoped_refptr<GetAllCookiesForURLWithOptionsTask> task = | 1011 scoped_refptr<GetAllCookiesForURLWithOptionsTask> task = |
| 1033 new GetAllCookiesForURLWithOptionsTask(this, url, options, callback); | 1012 new GetAllCookiesForURLWithOptionsTask(this, url, options, callback); |
| 1034 | 1013 |
| 1035 DoCookieTaskForURL(task, url); | 1014 DoCookieTask(task); |
| 1036 } | 1015 } |
| 1037 | 1016 |
| 1038 void CookieMonster::GetAllCookiesForURLAsync( | 1017 void CookieMonster::GetAllCookiesForURLAsync( |
| 1039 const GURL& url, const GetCookieListCallback& callback) { | 1018 const GURL& url, const GetCookieListCallback& callback) { |
| 1040 CookieOptions options; | 1019 CookieOptions options; |
| 1041 options.set_include_httponly(); | 1020 options.set_include_httponly(); |
| 1042 scoped_refptr<GetAllCookiesForURLWithOptionsTask> task = | 1021 scoped_refptr<GetAllCookiesForURLWithOptionsTask> task = |
| 1043 new GetAllCookiesForURLWithOptionsTask(this, url, options, callback); | 1022 new GetAllCookiesForURLWithOptionsTask(this, url, options, callback); |
| 1044 | 1023 |
| 1045 DoCookieTaskForURL(task, url); | 1024 DoCookieTask(task); |
| 1046 } | 1025 } |
| 1047 | 1026 |
| 1048 void CookieMonster::DeleteAllAsync(const DeleteCallback& callback) { | 1027 void CookieMonster::DeleteAllAsync(const DeleteCallback& callback) { |
| 1049 scoped_refptr<DeleteAllTask> task = | 1028 scoped_refptr<DeleteAllTask> task = |
| 1050 new DeleteAllTask(this, callback); | 1029 new DeleteAllTask(this, callback); |
| 1051 | 1030 |
| 1052 DoCookieTask(task); | 1031 DoCookieTask(task); |
| 1053 } | 1032 } |
| 1054 | 1033 |
| 1055 void CookieMonster::DeleteAllCreatedBetweenAsync( | 1034 void CookieMonster::DeleteAllCreatedBetweenAsync( |
| 1056 const Time& delete_begin, const Time& delete_end, | 1035 const Time& delete_begin, const Time& delete_end, |
| 1057 const DeleteCallback& callback) { | 1036 const DeleteCallback& callback) { |
| 1058 scoped_refptr<DeleteAllCreatedBetweenTask> task = | 1037 scoped_refptr<DeleteAllCreatedBetweenTask> task = |
| 1059 new DeleteAllCreatedBetweenTask(this, delete_begin, delete_end, | 1038 new DeleteAllCreatedBetweenTask(this, delete_begin, delete_end, |
| 1060 callback); | 1039 callback); |
| 1061 | 1040 |
| 1062 DoCookieTask(task); | 1041 DoCookieTask(task); |
| 1063 } | 1042 } |
| 1064 | 1043 |
| 1065 void CookieMonster::DeleteAllForHostAsync( | 1044 void CookieMonster::DeleteAllForHostAsync( |
| 1066 const GURL& url, const DeleteCallback& callback) { | 1045 const GURL& url, const DeleteCallback& callback) { |
| 1067 scoped_refptr<DeleteAllForHostTask> task = | 1046 scoped_refptr<DeleteAllForHostTask> task = |
| 1068 new DeleteAllForHostTask(this, url, callback); | 1047 new DeleteAllForHostTask(this, url, callback); |
| 1069 | 1048 |
| 1070 DoCookieTaskForURL(task, url); | 1049 DoCookieTask(task); |
| 1071 } | 1050 } |
| 1072 | 1051 |
| 1073 void CookieMonster::DeleteCanonicalCookieAsync( | 1052 void CookieMonster::DeleteCanonicalCookieAsync( |
| 1074 const CanonicalCookie& cookie, | 1053 const CanonicalCookie& cookie, |
| 1075 const DeleteCookieCallback& callback) { | 1054 const DeleteCookieCallback& callback) { |
| 1076 scoped_refptr<DeleteCanonicalCookieTask> task = | 1055 scoped_refptr<DeleteCanonicalCookieTask> task = |
| 1077 new DeleteCanonicalCookieTask(this, cookie, callback); | 1056 new DeleteCanonicalCookieTask(this, cookie, callback); |
| 1078 | 1057 |
| 1079 DoCookieTask(task); | 1058 DoCookieTask(task); |
| 1080 } | 1059 } |
| 1081 | 1060 |
| 1082 void CookieMonster::SetCookieWithOptionsAsync( | 1061 void CookieMonster::SetCookieWithOptionsAsync( |
| 1083 const GURL& url, | 1062 const GURL& url, |
| 1084 const std::string& cookie_line, | 1063 const std::string& cookie_line, |
| 1085 const CookieOptions& options, | 1064 const CookieOptions& options, |
| 1086 const SetCookiesCallback& callback) { | 1065 const SetCookiesCallback& callback) { |
| 1087 scoped_refptr<SetCookieWithOptionsTask> task = | 1066 scoped_refptr<SetCookieWithOptionsTask> task = |
| 1088 new SetCookieWithOptionsTask(this, url, cookie_line, options, callback); | 1067 new SetCookieWithOptionsTask(this, url, cookie_line, options, callback); |
| 1089 | 1068 |
| 1090 DoCookieTaskForURL(task, url); | 1069 DoCookieTask(task); |
| 1091 } | 1070 } |
| 1092 | 1071 |
| 1093 void CookieMonster::GetCookiesWithOptionsAsync( | 1072 void CookieMonster::GetCookiesWithOptionsAsync( |
| 1094 const GURL& url, | 1073 const GURL& url, |
| 1095 const CookieOptions& options, | 1074 const CookieOptions& options, |
| 1096 const GetCookiesCallback& callback) { | 1075 const GetCookiesCallback& callback) { |
| 1097 scoped_refptr<GetCookiesWithOptionsTask> task = | 1076 scoped_refptr<GetCookiesWithOptionsTask> task = |
| 1098 new GetCookiesWithOptionsTask(this, url, options, callback); | 1077 new GetCookiesWithOptionsTask(this, url, options, callback); |
| 1099 | 1078 |
| 1100 DoCookieTaskForURL(task, url); | 1079 DoCookieTask(task); |
| 1101 } | 1080 } |
| 1102 | 1081 |
| 1103 void CookieMonster::GetCookiesWithInfoAsync( | 1082 void CookieMonster::GetCookiesWithInfoAsync( |
| 1104 const GURL& url, | 1083 const GURL& url, |
| 1105 const CookieOptions& options, | 1084 const CookieOptions& options, |
| 1106 const GetCookieInfoCallback& callback) { | 1085 const GetCookieInfoCallback& callback) { |
| 1107 scoped_refptr<GetCookiesWithInfoTask> task = | 1086 scoped_refptr<GetCookiesWithInfoTask> task = |
| 1108 new GetCookiesWithInfoTask(this, url, options, callback); | 1087 new GetCookiesWithInfoTask(this, url, options, callback); |
| 1109 | 1088 |
| 1110 DoCookieTaskForURL(task, url); | 1089 DoCookieTask(task); |
| 1111 } | 1090 } |
| 1112 | 1091 |
| 1113 void CookieMonster::DeleteCookieAsync(const GURL& url, | 1092 void CookieMonster::DeleteCookieAsync(const GURL& url, |
| 1114 const std::string& cookie_name, | 1093 const std::string& cookie_name, |
| 1115 const base::Closure& callback) { | 1094 const base::Closure& callback) { |
| 1116 scoped_refptr<DeleteCookieTask> task = | 1095 scoped_refptr<DeleteCookieTask> task = |
| 1117 new DeleteCookieTask(this, url, cookie_name, callback); | 1096 new DeleteCookieTask(this, url, cookie_name, callback); |
| 1118 | 1097 |
| 1119 DoCookieTaskForURL(task, url); | 1098 DoCookieTask(task); |
| 1120 } | 1099 } |
| 1121 | 1100 |
| 1122 void CookieMonster::DoCookieTask( | 1101 void CookieMonster::DoCookieTask( |
| 1123 const scoped_refptr<CookieMonsterTask>& task_item) { | 1102 const scoped_refptr<CookieMonsterTask>& task_item) { |
| 1103 InitIfNecessary(); |
| 1104 |
| 1124 { | 1105 { |
| 1125 base::AutoLock autolock(lock_); | 1106 base::AutoLock autolock(lock_); |
| 1126 InitIfNecessary(); | |
| 1127 if (!loaded_) { | 1107 if (!loaded_) { |
| 1128 queue_.push(task_item); | 1108 queue_.push(task_item); |
| 1129 return; | 1109 return; |
| 1130 } | 1110 } |
| 1131 } | 1111 } |
| 1132 | 1112 |
| 1133 task_item->Run(); | 1113 task_item->Run(); |
| 1134 } | 1114 } |
| 1135 | 1115 |
| 1136 void CookieMonster::DoCookieTaskForURL( | |
| 1137 const scoped_refptr<CookieMonsterTask>& task_item, | |
| 1138 const GURL& url) { | |
| 1139 { | |
| 1140 base::AutoLock autolock(lock_); | |
| 1141 InitIfNecessary(); | |
| 1142 // If cookies for the requested domain key (eTLD+1) have been loaded from DB | |
| 1143 // then run the task, otherwise load from DB. | |
| 1144 if (!loaded_) { | |
| 1145 // Checks if the domain key has been loaded. | |
| 1146 std::string key(GetEffectiveDomain(url.scheme(), url.host())); | |
| 1147 if (keys_loaded_.find(key) == keys_loaded_.end()) { | |
| 1148 std::map<std::string, std::deque<scoped_refptr<CookieMonsterTask> > > | |
| 1149 ::iterator it = tasks_queued_.find(key); | |
| 1150 if (it == tasks_queued_.end()) { | |
| 1151 store_->LoadCookiesForKey(key, | |
| 1152 base::Bind(&CookieMonster::OnKeyLoaded, this, key)); | |
| 1153 it = tasks_queued_.insert(std::make_pair(key, | |
| 1154 std::deque<scoped_refptr<CookieMonsterTask> >())).first; | |
| 1155 } | |
| 1156 it->second.push_back(task_item); | |
| 1157 return; | |
| 1158 } | |
| 1159 } | |
| 1160 } | |
| 1161 task_item->Run(); | |
| 1162 } | |
| 1163 | |
| 1164 bool CookieMonster::SetCookieWithDetails( | 1116 bool CookieMonster::SetCookieWithDetails( |
| 1165 const GURL& url, const std::string& name, const std::string& value, | 1117 const GURL& url, const std::string& name, const std::string& value, |
| 1166 const std::string& domain, const std::string& path, | 1118 const std::string& domain, const std::string& path, |
| 1167 const base::Time& expiration_time, bool secure, bool http_only) { | 1119 const base::Time& expiration_time, bool secure, bool http_only) { |
| 1168 base::AutoLock autolock(lock_); | 1120 base::AutoLock autolock(lock_); |
| 1169 | 1121 |
| 1170 if (!HasCookieableScheme(url)) | 1122 if (!HasCookieableScheme(url)) |
| 1171 return false; | 1123 return false; |
| 1172 | 1124 |
| 1173 Time creation_time = CurrentTime(); | 1125 Time creation_time = CurrentTime(); |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1511 | 1463 |
| 1512 void CookieMonster::OnLoaded(TimeTicks beginning_time, | 1464 void CookieMonster::OnLoaded(TimeTicks beginning_time, |
| 1513 const std::vector<CanonicalCookie*>& cookies) { | 1465 const std::vector<CanonicalCookie*>& cookies) { |
| 1514 StoreLoadedCookies(cookies); | 1466 StoreLoadedCookies(cookies); |
| 1515 histogram_time_load_->AddTime(TimeTicks::Now() - beginning_time); | 1467 histogram_time_load_->AddTime(TimeTicks::Now() - beginning_time); |
| 1516 | 1468 |
| 1517 // Invoke the task queue of cookie request. | 1469 // Invoke the task queue of cookie request. |
| 1518 InvokeQueue(); | 1470 InvokeQueue(); |
| 1519 } | 1471 } |
| 1520 | 1472 |
| 1521 void CookieMonster::OnKeyLoaded(const std::string& key, | |
| 1522 const std::vector<CanonicalCookie*>& cookies) { | |
| 1523 // This function does its own separate locking. | |
| 1524 StoreLoadedCookies(cookies); | |
| 1525 | |
| 1526 std::deque<scoped_refptr<CookieMonsterTask> > tasks_queued; | |
| 1527 { | |
| 1528 base::AutoLock autolock(lock_); | |
| 1529 keys_loaded_.insert(key); | |
| 1530 std::map<std::string, std::deque<scoped_refptr<CookieMonsterTask> > > | |
| 1531 ::iterator it = tasks_queued_.find(key); | |
| 1532 if (it == tasks_queued_.end()) | |
| 1533 return; | |
| 1534 it->second.swap(tasks_queued); | |
| 1535 tasks_queued_.erase(it); | |
| 1536 } | |
| 1537 | |
| 1538 while (!tasks_queued.empty()) { | |
| 1539 scoped_refptr<CookieMonsterTask> task = tasks_queued.front(); | |
| 1540 task->Run(); | |
| 1541 tasks_queued.pop_front(); | |
| 1542 } | |
| 1543 } | |
| 1544 | |
| 1545 void CookieMonster::StoreLoadedCookies( | 1473 void CookieMonster::StoreLoadedCookies( |
| 1546 const std::vector<CanonicalCookie*>& cookies) { | 1474 const std::vector<CanonicalCookie*>& cookies) { |
| 1547 // Initialize the store and sync in any saved persistent cookies. We don't | 1475 // Initialize the store and sync in any saved persistent cookies. We don't |
| 1548 // care if it's expired, insert it so it can be garbage collected, removed, | 1476 // care if it's expired, insert it so it can be garbage collected, removed, |
| 1549 // and sync'd. | 1477 // and sync'd. |
| 1550 base::AutoLock autolock(lock_); | 1478 base::AutoLock autolock(lock_); |
| 1551 | 1479 |
| 1480 // Avoid ever letting cookies with duplicate creation times into the store; |
| 1481 // that way we don't have to worry about what sections of code are safe |
| 1482 // to call while it's in that state. |
| 1483 std::set<int64> creation_times; |
| 1484 |
| 1485 // Presumably later than any access time in the store. |
| 1486 Time earliest_access_time; |
| 1487 |
| 1552 for (std::vector<CanonicalCookie*>::const_iterator it = cookies.begin(); | 1488 for (std::vector<CanonicalCookie*>::const_iterator it = cookies.begin(); |
| 1553 it != cookies.end(); ++it) { | 1489 it != cookies.end(); ++it) { |
| 1554 int64 cookie_creation_time = (*it)->CreationDate().ToInternalValue(); | 1490 int64 cookie_creation_time = (*it)->CreationDate().ToInternalValue(); |
| 1555 | 1491 |
| 1556 if (creation_times_.insert(cookie_creation_time).second) { | 1492 if (creation_times.insert(cookie_creation_time).second) { |
| 1557 InternalInsertCookie(GetKey((*it)->Domain()), *it, false); | 1493 InternalInsertCookie(GetKey((*it)->Domain()), *it, false); |
| 1558 const Time cookie_access_time((*it)->LastAccessDate()); | 1494 const Time cookie_access_time((*it)->LastAccessDate()); |
| 1559 if (earliest_access_time_.is_null() || | 1495 if (earliest_access_time.is_null() || |
| 1560 cookie_access_time < earliest_access_time_) | 1496 cookie_access_time < earliest_access_time) |
| 1561 earliest_access_time_ = cookie_access_time; | 1497 earliest_access_time = cookie_access_time; |
| 1562 } else { | 1498 } else { |
| 1563 LOG(ERROR) << base::StringPrintf("Found cookies with duplicate creation " | 1499 LOG(ERROR) << base::StringPrintf("Found cookies with duplicate creation " |
| 1564 "times in backing store: " | 1500 "times in backing store: " |
| 1565 "{name='%s', domain='%s', path='%s'}", | 1501 "{name='%s', domain='%s', path='%s'}", |
| 1566 (*it)->Name().c_str(), | 1502 (*it)->Name().c_str(), |
| 1567 (*it)->Domain().c_str(), | 1503 (*it)->Domain().c_str(), |
| 1568 (*it)->Path().c_str()); | 1504 (*it)->Path().c_str()); |
| 1569 // We've been given ownership of the cookie and are throwing it | 1505 // We've been given ownership of the cookie and are throwing it |
| 1570 // away; reclaim the space. | 1506 // away; reclaim the space. |
| 1571 delete (*it); | 1507 delete (*it); |
| 1572 } | 1508 } |
| 1573 } | 1509 } |
| 1510 earliest_access_time_= earliest_access_time; |
| 1574 | 1511 |
| 1575 // After importing cookies from the PersistentCookieStore, verify that | 1512 // After importing cookies from the PersistentCookieStore, verify that |
| 1576 // none of our other constraints are violated. | 1513 // none of our other constraints are violated. |
| 1514 // |
| 1577 // In particular, the backing store might have given us duplicate cookies. | 1515 // In particular, the backing store might have given us duplicate cookies. |
| 1578 | |
| 1579 // This method could be called multiple times due to priority loading, thus | |
| 1580 // cookies loaded in previous runs will be validated again, but this is OK | |
| 1581 // since they are expected to be much fewer than total DB. | |
| 1582 EnsureCookiesMapIsValid(); | 1516 EnsureCookiesMapIsValid(); |
| 1583 } | 1517 } |
| 1584 | 1518 |
| 1585 void CookieMonster::InvokeQueue() { | 1519 void CookieMonster::InvokeQueue() { |
| 1586 while (true) { | 1520 while (true) { |
| 1587 scoped_refptr<CookieMonsterTask> request_task; | 1521 scoped_refptr<CookieMonsterTask> request_task; |
| 1588 { | 1522 { |
| 1589 base::AutoLock autolock(lock_); | 1523 base::AutoLock autolock(lock_); |
| 1590 if (queue_.empty()) { | 1524 if (queue_.empty()) { |
| 1591 loaded_ = true; | 1525 loaded_ = true; |
| 1592 creation_times_.clear(); | |
| 1593 keys_loaded_.clear(); | |
| 1594 break; | 1526 break; |
| 1595 } | 1527 } |
| 1596 request_task = queue_.front(); | 1528 request_task = queue_.front(); |
| 1597 queue_.pop(); | 1529 queue_.pop(); |
| 1598 } | 1530 } |
| 1599 request_task->Run(); | 1531 request_task->Run(); |
| 1600 } | 1532 } |
| 1601 } | 1533 } |
| 1602 | 1534 |
| 1603 void CookieMonster::EnsureCookiesMapIsValid() { | 1535 void CookieMonster::EnsureCookiesMapIsValid() { |
| (...skipping 1228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2832 std::string CookieMonster::CanonicalCookie::DebugString() const { | 2764 std::string CookieMonster::CanonicalCookie::DebugString() const { |
| 2833 return base::StringPrintf( | 2765 return base::StringPrintf( |
| 2834 "name: %s value: %s domain: %s path: %s creation: %" | 2766 "name: %s value: %s domain: %s path: %s creation: %" |
| 2835 PRId64, | 2767 PRId64, |
| 2836 name_.c_str(), value_.c_str(), | 2768 name_.c_str(), value_.c_str(), |
| 2837 domain_.c_str(), path_.c_str(), | 2769 domain_.c_str(), path_.c_str(), |
| 2838 static_cast<int64>(creation_date_.ToTimeT())); | 2770 static_cast<int64>(creation_date_.ToTimeT())); |
| 2839 } | 2771 } |
| 2840 | 2772 |
| 2841 } // namespace | 2773 } // namespace |
| OLD | NEW |