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

Side by Side Diff: net/base/cookie_monster.cc

Issue 8533013: SessionRestore: Store session cookies and restore them if chrome crashes or auto-restarts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years 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) 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 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 // DELETE_COOKIE_EVICTED_DOMAIN 313 // DELETE_COOKIE_EVICTED_DOMAIN
314 { CookieMonster::Delegate::CHANGE_COOKIE_EVICTED, true }, 314 { CookieMonster::Delegate::CHANGE_COOKIE_EVICTED, true },
315 // DELETE_COOKIE_EVICTED_GLOBAL 315 // DELETE_COOKIE_EVICTED_GLOBAL
316 { CookieMonster::Delegate::CHANGE_COOKIE_EVICTED, true }, 316 { CookieMonster::Delegate::CHANGE_COOKIE_EVICTED, true },
317 // DELETE_COOKIE_EVICTED_DOMAIN_PRE_SAFE 317 // DELETE_COOKIE_EVICTED_DOMAIN_PRE_SAFE
318 { CookieMonster::Delegate::CHANGE_COOKIE_EVICTED, true }, 318 { CookieMonster::Delegate::CHANGE_COOKIE_EVICTED, true },
319 // DELETE_COOKIE_EVICTED_DOMAIN_POST_SAFE 319 // DELETE_COOKIE_EVICTED_DOMAIN_POST_SAFE
320 { CookieMonster::Delegate::CHANGE_COOKIE_EVICTED, true }, 320 { CookieMonster::Delegate::CHANGE_COOKIE_EVICTED, true },
321 // DELETE_COOKIE_EXPIRED_OVERWRITE 321 // DELETE_COOKIE_EXPIRED_OVERWRITE
322 { CookieMonster::Delegate::CHANGE_COOKIE_EXPIRED_OVERWRITE, true }, 322 { CookieMonster::Delegate::CHANGE_COOKIE_EXPIRED_OVERWRITE, true },
323 // DELETE_COOKIE_OLD_SESSION_COOKIE
324 { CookieMonster::Delegate::CHANGE_COOKIE_EXPLICIT, false },
323 // DELETE_COOKIE_LAST_ENTRY 325 // DELETE_COOKIE_LAST_ENTRY
324 { CookieMonster::Delegate::CHANGE_COOKIE_EXPLICIT, false } 326 { CookieMonster::Delegate::CHANGE_COOKIE_EXPLICIT, false }
325 }; 327 };
326 328
327 std::string BuildCookieLine(const CanonicalCookieVector& cookies) { 329 std::string BuildCookieLine(const CanonicalCookieVector& cookies) {
328 std::string cookie_line; 330 std::string cookie_line;
329 for (CanonicalCookieVector::const_iterator it = cookies.begin(); 331 for (CanonicalCookieVector::const_iterator it = cookies.begin();
330 it != cookies.end(); ++it) { 332 it != cookies.end(); ++it) {
331 if (it != cookies.begin()) 333 if (it != cookies.begin())
332 cookie_line += "; "; 334 cookie_line += "; ";
(...skipping 30 matching lines...) Expand all
363 365
364 CookieMonster::CookieMonster(PersistentCookieStore* store, Delegate* delegate) 366 CookieMonster::CookieMonster(PersistentCookieStore* store, Delegate* delegate)
365 : initialized_(false), 367 : initialized_(false),
366 loaded_(false), 368 loaded_(false),
367 expiry_and_key_scheme_(expiry_and_key_default_), 369 expiry_and_key_scheme_(expiry_and_key_default_),
368 store_(store), 370 store_(store),
369 last_access_threshold_( 371 last_access_threshold_(
370 TimeDelta::FromSeconds(kDefaultAccessUpdateThresholdSeconds)), 372 TimeDelta::FromSeconds(kDefaultAccessUpdateThresholdSeconds)),
371 delegate_(delegate), 373 delegate_(delegate),
372 last_statistic_record_time_(Time::Now()), 374 last_statistic_record_time_(Time::Now()),
373 keep_expired_cookies_(false) { 375 keep_expired_cookies_(false),
376 keep_old_session_cookies_(false),
377 sync_session_cookies_(false) {
374 InitializeHistograms(); 378 InitializeHistograms();
375 SetDefaultCookieableSchemes(); 379 SetDefaultCookieableSchemes();
376 } 380 }
377 381
378 CookieMonster::CookieMonster(PersistentCookieStore* store, 382 CookieMonster::CookieMonster(PersistentCookieStore* store,
379 Delegate* delegate, 383 Delegate* delegate,
380 int last_access_threshold_milliseconds) 384 int last_access_threshold_milliseconds)
381 : initialized_(false), 385 : initialized_(false),
382 loaded_(false), 386 loaded_(false),
383 expiry_and_key_scheme_(expiry_and_key_default_), 387 expiry_and_key_scheme_(expiry_and_key_default_),
384 store_(store), 388 store_(store),
385 last_access_threshold_(base::TimeDelta::FromMilliseconds( 389 last_access_threshold_(base::TimeDelta::FromMilliseconds(
386 last_access_threshold_milliseconds)), 390 last_access_threshold_milliseconds)),
387 delegate_(delegate), 391 delegate_(delegate),
388 last_statistic_record_time_(base::Time::Now()), 392 last_statistic_record_time_(base::Time::Now()),
389 keep_expired_cookies_(false) { 393 keep_expired_cookies_(false),
394 keep_old_session_cookies_(false),
395 sync_session_cookies_(false) {
390 InitializeHistograms(); 396 InitializeHistograms();
391 SetDefaultCookieableSchemes(); 397 SetDefaultCookieableSchemes();
392 } 398 }
393 399
394 // Parse a cookie expiration time. We try to be lenient, but we need to 400 // Parse a cookie expiration time. We try to be lenient, but we need to
395 // assume some order to distinguish the fields. The basic rules: 401 // assume some order to distinguish the fields. The basic rules:
396 // - The month name must be present and prefix the first 3 letters of the 402 // - The month name must be present and prefix the first 3 letters of the
397 // full month name (jan for January, jun for June). 403 // full month name (jan for January, jun for June).
398 // - If the year is <= 2 digits, it must occur after the day of month. 404 // - If the year is <= 2 digits, it must occur after the day of month.
399 // - The time must be of the format hh:mm:ss. 405 // - The time must be of the format hh:mm:ss.
(...skipping 992 matching lines...) Expand 10 before | Expand all | Expand 10 after
1392 if (matching_cookies.find(curit->second) != matching_cookies.end()) { 1398 if (matching_cookies.find(curit->second) != matching_cookies.end()) {
1393 InternalDeleteCookie(curit, true, DELETE_COOKIE_EXPLICIT); 1399 InternalDeleteCookie(curit, true, DELETE_COOKIE_EXPLICIT);
1394 } 1400 }
1395 } 1401 }
1396 } 1402 }
1397 1403
1398 CookieMonster* CookieMonster::GetCookieMonster() { 1404 CookieMonster* CookieMonster::GetCookieMonster() {
1399 return this; 1405 return this;
1400 } 1406 }
1401 1407
1408 void CookieMonster::SetSyncSessionCookies(bool sync_session_cookies) {
1409 sync_session_cookies_ = sync_session_cookies;
1410 }
1411
1412 void CookieMonster::SaveSessionCookies() {
1413 if (store_) {
1414 store_->SetClearSessionStateOnExit(false);
1415 store_->SetClearLocalStateOnExit(false);
1416 }
1417 }
1418
1419 void CookieMonster::RestoreOldSessionCookies() {
1420 keep_old_session_cookies_ = true;
1421 for (CookieMap::iterator it = cookies_.begin(); it != cookies_.end(); ++it) {
1422 it->second->SetIsOldSessionCookie(false);
jochen (gone - plz use gerrit) 2011/11/25 14:45:14 this should notify the delegate about the cookie b
marja 2011/11/28 15:22:01 Done. (And made it so that StoreLoadedCookies won'
1423 }
1424 }
1425
1426 void CookieMonster::DiscardOldSessionCookies() {
1427 for (CookieMap::iterator it = cookies_.begin(); it != cookies_.end();) {
1428 CookieMap::iterator curit = it;
1429 ++it;
1430 if (curit->second->IsOldSessionCookie()) {
1431 InternalDeleteCookie(curit, true, DELETE_COOKIE_OLD_SESSION_COOKIE);
jochen (gone - plz use gerrit) 2011/11/25 14:45:14 we need to make sure that this doesn't call the co
marja 2011/11/28 15:22:01 Should already work since the notifications are se
1432 }
1433 }
1434 }
1435
1402 CookieMonster::~CookieMonster() { 1436 CookieMonster::~CookieMonster() {
1403 DeleteAll(false); 1437 DeleteAll(false);
1404 } 1438 }
1405 1439
1406 bool CookieMonster::SetCookieWithCreationTime(const GURL& url, 1440 bool CookieMonster::SetCookieWithCreationTime(const GURL& url,
1407 const std::string& cookie_line, 1441 const std::string& cookie_line,
1408 const base::Time& creation_time) { 1442 const base::Time& creation_time) {
1409 DCHECK(!store_) << "This method is only to be used by unit-tests."; 1443 DCHECK(!store_) << "This method is only to be used by unit-tests.";
1410 base::AutoLock autolock(lock_); 1444 base::AutoLock autolock(lock_);
1411 1445
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1461 1495
1462 void CookieMonster::StoreLoadedCookies( 1496 void CookieMonster::StoreLoadedCookies(
1463 const std::vector<CanonicalCookie*>& cookies) { 1497 const std::vector<CanonicalCookie*>& cookies) {
1464 // Initialize the store and sync in any saved persistent cookies. We don't 1498 // Initialize the store and sync in any saved persistent cookies. We don't
1465 // care if it's expired, insert it so it can be garbage collected, removed, 1499 // care if it's expired, insert it so it can be garbage collected, removed,
1466 // and sync'd. 1500 // and sync'd.
1467 base::AutoLock autolock(lock_); 1501 base::AutoLock autolock(lock_);
1468 1502
1469 for (std::vector<CanonicalCookie*>::const_iterator it = cookies.begin(); 1503 for (std::vector<CanonicalCookie*>::const_iterator it = cookies.begin();
1470 it != cookies.end(); ++it) { 1504 it != cookies.end(); ++it) {
1505 // Mark restored session cookies as old session cookies, so they can be
1506 // discarded if needed.
1507 if (!keep_old_session_cookies_ && !(*it)->IsPersistent())
1508 (*it)->SetIsOldSessionCookie(true);
1509
1471 int64 cookie_creation_time = (*it)->CreationDate().ToInternalValue(); 1510 int64 cookie_creation_time = (*it)->CreationDate().ToInternalValue();
1472 1511
1473 if (creation_times_.insert(cookie_creation_time).second) { 1512 if (creation_times_.insert(cookie_creation_time).second) {
1474 InternalInsertCookie(GetKey((*it)->Domain()), *it, false); 1513 InternalInsertCookie(GetKey((*it)->Domain()), *it, false);
1475 const Time cookie_access_time((*it)->LastAccessDate()); 1514 const Time cookie_access_time((*it)->LastAccessDate());
1476 if (earliest_access_time_.is_null() || 1515 if (earliest_access_time_.is_null() ||
1477 cookie_access_time < earliest_access_time_) 1516 cookie_access_time < earliest_access_time_)
1478 earliest_access_time_ = cookie_access_time; 1517 earliest_access_time_ = cookie_access_time;
1479 } else { 1518 } else {
1480 LOG(ERROR) << base::StringPrintf("Found cookies with duplicate creation " 1519 LOG(ERROR) << base::StringPrintf("Found cookies with duplicate creation "
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
1706 CookieMap::iterator curit = its.first; 1745 CookieMap::iterator curit = its.first;
1707 CanonicalCookie* cc = curit->second; 1746 CanonicalCookie* cc = curit->second;
1708 ++its.first; 1747 ++its.first;
1709 1748
1710 // If the cookie is expired, delete it. 1749 // If the cookie is expired, delete it.
1711 if (cc->IsExpired(current) && !keep_expired_cookies_) { 1750 if (cc->IsExpired(current) && !keep_expired_cookies_) {
1712 InternalDeleteCookie(curit, true, DELETE_COOKIE_EXPIRED); 1751 InternalDeleteCookie(curit, true, DELETE_COOKIE_EXPIRED);
1713 continue; 1752 continue;
1714 } 1753 }
1715 1754
1755 // If the cookie is an old session cookie, and we are not supposed to keep
1756 // them, delete it.
1757 if (!keep_old_session_cookies_ && cc->IsOldSessionCookie()) {
1758 InternalDeleteCookie(curit, true, DELETE_COOKIE_OLD_SESSION_COOKIE);
jochen (gone - plz use gerrit) 2011/11/25 14:45:14 again, this shouldn't notify
marja 2011/11/28 15:22:01 Same here.
1759 continue;
1760 }
1761
1716 // Filter out HttpOnly cookies, per options. 1762 // Filter out HttpOnly cookies, per options.
1717 if (options.exclude_httponly() && cc->IsHttpOnly()) 1763 if (options.exclude_httponly() && cc->IsHttpOnly())
1718 continue; 1764 continue;
1719 1765
1720 // Filter out secure cookies unless we're https. 1766 // Filter out secure cookies unless we're https.
1721 if (!secure && cc->IsSecure()) 1767 if (!secure && cc->IsSecure())
1722 continue; 1768 continue;
1723 1769
1724 // Filter out cookies that don't apply to this domain. 1770 // Filter out cookies that don't apply to this domain.
1725 if (expiry_and_key_scheme_ == EKS_KEEP_RECENT_AND_PURGE_ETLDP1 1771 if (expiry_and_key_scheme_ == EKS_KEEP_RECENT_AND_PURGE_ETLDP1
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1767 } 1813 }
1768 } 1814 }
1769 return skipped_httponly; 1815 return skipped_httponly;
1770 } 1816 }
1771 1817
1772 void CookieMonster::InternalInsertCookie(const std::string& key, 1818 void CookieMonster::InternalInsertCookie(const std::string& key,
1773 CanonicalCookie* cc, 1819 CanonicalCookie* cc,
1774 bool sync_to_store) { 1820 bool sync_to_store) {
1775 lock_.AssertAcquired(); 1821 lock_.AssertAcquired();
1776 1822
1777 if (cc->IsPersistent() && store_ && sync_to_store) 1823 if ((cc->IsPersistent() || sync_session_cookies_) && store_ && sync_to_store)
1778 store_->AddCookie(*cc); 1824 store_->AddCookie(*cc);
1779 cookies_.insert(CookieMap::value_type(key, cc)); 1825 cookies_.insert(CookieMap::value_type(key, cc));
1780 if (delegate_.get()) { 1826 if (delegate_.get()) {
1781 delegate_->OnCookieChanged( 1827 delegate_->OnCookieChanged(
1782 *cc, false, CookieMonster::Delegate::CHANGE_COOKIE_EXPLICIT); 1828 *cc, false, CookieMonster::Delegate::CHANGE_COOKIE_EXPLICIT);
1783 } 1829 }
1784 } 1830 }
1785 1831
1786 bool CookieMonster::SetCookieWithCreationTimeAndOptions( 1832 bool CookieMonster::SetCookieWithCreationTimeAndOptions(
1787 const GURL& url, 1833 const GURL& url,
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1846 bool already_expired = (*cc)->IsExpired(creation_time); 1892 bool already_expired = (*cc)->IsExpired(creation_time);
1847 if (DeleteAnyEquivalentCookie(key, **cc, options.exclude_httponly(), 1893 if (DeleteAnyEquivalentCookie(key, **cc, options.exclude_httponly(),
1848 already_expired)) { 1894 already_expired)) {
1849 VLOG(kVlogSetCookies) << "SetCookie() not clobbering httponly cookie"; 1895 VLOG(kVlogSetCookies) << "SetCookie() not clobbering httponly cookie";
1850 return false; 1896 return false;
1851 } 1897 }
1852 1898
1853 VLOG(kVlogSetCookies) << "SetCookie() key: " << key << " cc: " 1899 VLOG(kVlogSetCookies) << "SetCookie() key: " << key << " cc: "
1854 << (*cc)->DebugString(); 1900 << (*cc)->DebugString();
1855 1901
1902 if (!keep_old_session_cookies_ && sync_session_cookies_) {
1903 // Delete all old session cookies for that key.
1904 CookieMapItPair its = cookies_.equal_range(key);
1905 while (its.first != its.second) {
1906 CookieMap::iterator curit = its.first;
1907 ++its.first;
1908 if (curit->second->IsOldSessionCookie()) {
1909 InternalDeleteCookie(curit, true, DELETE_COOKIE_EXPLICIT);
1910 }
1911 }
1912 }
1913
1856 // Realize that we might be setting an expired cookie, and the only point 1914 // Realize that we might be setting an expired cookie, and the only point
1857 // was to delete the cookie which we've already done. 1915 // was to delete the cookie which we've already done.
1858 if (!already_expired || keep_expired_cookies_) { 1916 if (!already_expired || keep_expired_cookies_) {
1859 // See InitializeHistograms() for details. 1917 // See InitializeHistograms() for details.
1860 if ((*cc)->DoesExpire()) { 1918 if ((*cc)->DoesExpire()) {
1861 histogram_expiration_duration_minutes_->Add( 1919 histogram_expiration_duration_minutes_->Add(
1862 ((*cc)->ExpiryDate() - creation_time).InMinutes()); 1920 ((*cc)->ExpiryDate() - creation_time).InMinutes());
1863 } 1921 }
1864 1922
1865 InternalInsertCookie(key, cc->release(), true); 1923 InternalInsertCookie(key, cc->release(), true);
(...skipping 18 matching lines...) Expand all
1884 // updates we do during pageload, which in turn reduces the chance our storage 1942 // updates we do during pageload, which in turn reduces the chance our storage
1885 // backend will hit its batch thresholds and be forced to update. 1943 // backend will hit its batch thresholds and be forced to update.
1886 if ((current - cc->LastAccessDate()) < last_access_threshold_) 1944 if ((current - cc->LastAccessDate()) < last_access_threshold_)
1887 return; 1945 return;
1888 1946
1889 // See InitializeHistograms() for details. 1947 // See InitializeHistograms() for details.
1890 histogram_between_access_interval_minutes_->Add( 1948 histogram_between_access_interval_minutes_->Add(
1891 (current - cc->LastAccessDate()).InMinutes()); 1949 (current - cc->LastAccessDate()).InMinutes());
1892 1950
1893 cc->SetLastAccessDate(current); 1951 cc->SetLastAccessDate(current);
1894 if (cc->IsPersistent() && store_) 1952 if ((cc->IsPersistent() || sync_session_cookies_) && store_)
1895 store_->UpdateCookieAccessTime(*cc); 1953 store_->UpdateCookieAccessTime(*cc);
1896 } 1954 }
1897 1955
1898 void CookieMonster::InternalDeleteCookie(CookieMap::iterator it, 1956 void CookieMonster::InternalDeleteCookie(CookieMap::iterator it,
1899 bool sync_to_store, 1957 bool sync_to_store,
1900 DeletionCause deletion_cause) { 1958 DeletionCause deletion_cause) {
1901 lock_.AssertAcquired(); 1959 lock_.AssertAcquired();
1902 1960
1903 // Ideally, this would be asserted up where we define ChangeCauseMapping, 1961 // Ideally, this would be asserted up where we define ChangeCauseMapping,
1904 // but DeletionCause's visibility (or lack thereof) forces us to make 1962 // but DeletionCause's visibility (or lack thereof) forces us to make
1905 // this check here. 1963 // this check here.
1906 COMPILE_ASSERT(arraysize(ChangeCauseMapping) == DELETE_COOKIE_LAST_ENTRY + 1, 1964 COMPILE_ASSERT(arraysize(ChangeCauseMapping) == DELETE_COOKIE_LAST_ENTRY + 1,
1907 ChangeCauseMapping_size_not_eq_DeletionCause_enum_size); 1965 ChangeCauseMapping_size_not_eq_DeletionCause_enum_size);
1908 1966
1909 // See InitializeHistograms() for details. 1967 // See InitializeHistograms() for details.
1910 if (deletion_cause != DELETE_COOKIE_DONT_RECORD) 1968 if (deletion_cause != DELETE_COOKIE_DONT_RECORD)
1911 histogram_cookie_deletion_cause_->Add(deletion_cause); 1969 histogram_cookie_deletion_cause_->Add(deletion_cause);
1912 1970
1913 CanonicalCookie* cc = it->second; 1971 CanonicalCookie* cc = it->second;
1914 VLOG(kVlogSetCookies) << "InternalDeleteCookie() cc: " << cc->DebugString(); 1972 VLOG(kVlogSetCookies) << "InternalDeleteCookie() cc: " << cc->DebugString();
1915 1973
1916 if (cc->IsPersistent() && store_ && sync_to_store) 1974 if ((cc->IsPersistent() || sync_session_cookies_) && store_ && sync_to_store)
1917 store_->DeleteCookie(*cc); 1975 store_->DeleteCookie(*cc);
1918 if (delegate_.get()) { 1976 if (delegate_.get()) {
1919 ChangeCausePair mapping = ChangeCauseMapping[deletion_cause]; 1977 ChangeCausePair mapping = ChangeCauseMapping[deletion_cause];
1920 1978
1921 if (mapping.notify) 1979 if (mapping.notify)
1922 delegate_->OnCookieChanged(*cc, true, mapping.cause); 1980 delegate_->OnCookieChanged(*cc, true, mapping.cause);
1923 } 1981 }
1924 cookies_.erase(it); 1982 cookies_.erase(it);
1925 delete cc; 1983 delete cc;
1926 } 1984 }
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after
2512 } else { 2570 } else {
2513 /* some attribute we don't know or don't care about. */ 2571 /* some attribute we don't know or don't care about. */
2514 } 2572 }
2515 } 2573 }
2516 } 2574 }
2517 2575
2518 CookieMonster::CanonicalCookie::CanonicalCookie() 2576 CookieMonster::CanonicalCookie::CanonicalCookie()
2519 : secure_(false), 2577 : secure_(false),
2520 httponly_(false), 2578 httponly_(false),
2521 has_expires_(false), 2579 has_expires_(false),
2522 is_persistent_(false) { 2580 is_persistent_(false),
2581 is_old_session_cookie_(false) {
2523 SetSessionCookieExpiryTime(); 2582 SetSessionCookieExpiryTime();
2524 } 2583 }
2525 2584
2526 CookieMonster::CanonicalCookie::CanonicalCookie( 2585 CookieMonster::CanonicalCookie::CanonicalCookie(
2527 const GURL& url, const std::string& name, const std::string& value, 2586 const GURL& url, const std::string& name, const std::string& value,
2528 const std::string& domain, const std::string& path, 2587 const std::string& domain, const std::string& path,
2529 const std::string& mac_key, const std::string& mac_algorithm, 2588 const std::string& mac_key, const std::string& mac_algorithm,
2530 const base::Time& creation, const base::Time& expiration, 2589 const base::Time& creation, const base::Time& expiration,
2531 const base::Time& last_access, bool secure, bool httponly, bool has_expires, 2590 const base::Time& last_access, bool secure, bool httponly, bool has_expires,
2532 bool is_persistent) 2591 bool is_persistent)
2533 : source_(GetCookieSourceFromURL(url)), 2592 : source_(GetCookieSourceFromURL(url)),
2534 name_(name), 2593 name_(name),
2535 value_(value), 2594 value_(value),
2536 domain_(domain), 2595 domain_(domain),
2537 path_(path), 2596 path_(path),
2538 mac_key_(mac_key), 2597 mac_key_(mac_key),
2539 mac_algorithm_(mac_algorithm), 2598 mac_algorithm_(mac_algorithm),
2540 creation_date_(creation), 2599 creation_date_(creation),
2541 expiry_date_(expiration), 2600 expiry_date_(expiration),
2542 last_access_date_(last_access), 2601 last_access_date_(last_access),
2543 secure_(secure), 2602 secure_(secure),
2544 httponly_(httponly), 2603 httponly_(httponly),
2545 has_expires_(has_expires), 2604 has_expires_(has_expires),
2546 is_persistent_(is_persistent) { 2605 is_persistent_(is_persistent),
2606 is_old_session_cookie_(false) {
2547 if (!has_expires_) { 2607 if (!has_expires_) {
2548 DCHECK(!is_persistent_); 2608 DCHECK(!is_persistent_);
2549 SetSessionCookieExpiryTime(); 2609 SetSessionCookieExpiryTime();
2550 } 2610 }
2551 } 2611 }
2552 2612
2553 CookieMonster::CanonicalCookie::CanonicalCookie(const GURL& url, 2613 CookieMonster::CanonicalCookie::CanonicalCookie(const GURL& url,
2554 const ParsedCookie& pc) 2614 const ParsedCookie& pc)
2555 : source_(GetCookieSourceFromURL(url)), 2615 : source_(GetCookieSourceFromURL(url)),
2556 name_(pc.Name()), 2616 name_(pc.Name()),
2557 value_(pc.Value()), 2617 value_(pc.Value()),
2558 path_(CanonPath(url, pc)), 2618 path_(CanonPath(url, pc)),
2559 mac_key_(pc.MACKey()), 2619 mac_key_(pc.MACKey()),
2560 mac_algorithm_(pc.MACAlgorithm()), 2620 mac_algorithm_(pc.MACAlgorithm()),
2561 creation_date_(Time::Now()), 2621 creation_date_(Time::Now()),
2562 last_access_date_(Time()), 2622 last_access_date_(Time()),
2563 secure_(pc.IsSecure()), 2623 secure_(pc.IsSecure()),
2564 httponly_(pc.IsHttpOnly()), 2624 httponly_(pc.IsHttpOnly()),
2565 has_expires_(pc.HasExpires()), 2625 has_expires_(pc.HasExpires()),
2566 is_persistent_(pc.HasExpires()) { 2626 is_persistent_(pc.HasExpires()),
2627 is_old_session_cookie_(false) {
2567 if (has_expires_) 2628 if (has_expires_)
2568 expiry_date_ = CanonExpiration(pc, creation_date_); 2629 expiry_date_ = CanonExpiration(pc, creation_date_);
2569 else 2630 else
2570 SetSessionCookieExpiryTime(); 2631 SetSessionCookieExpiryTime();
2571 2632
2572 // Do the best we can with the domain. 2633 // Do the best we can with the domain.
2573 std::string cookie_domain; 2634 std::string cookie_domain;
2574 std::string domain_string; 2635 std::string domain_string;
2575 if (pc.HasDomain()) { 2636 if (pc.HasDomain()) {
2576 domain_string = pc.Domain(); 2637 domain_string = pc.Domain();
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
2762 std::string CookieMonster::CanonicalCookie::DebugString() const { 2823 std::string CookieMonster::CanonicalCookie::DebugString() const {
2763 return base::StringPrintf( 2824 return base::StringPrintf(
2764 "name: %s value: %s domain: %s path: %s creation: %" 2825 "name: %s value: %s domain: %s path: %s creation: %"
2765 PRId64, 2826 PRId64,
2766 name_.c_str(), value_.c_str(), 2827 name_.c_str(), value_.c_str(),
2767 domain_.c_str(), path_.c_str(), 2828 domain_.c_str(), path_.c_str(),
2768 static_cast<int64>(creation_date_.ToTimeT())); 2829 static_cast<int64>(creation_date_.ToTimeT()));
2769 } 2830 }
2770 2831
2771 } // namespace 2832 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698