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

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

Issue 3412016: FBTF: Move a bunch of code to the headers and remove includes. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Rebase + fixed windows issues locally Created 10 years, 3 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
« no previous file with comments | « net/base/cookie_monster.h ('k') | net/base/dnssec_chain_verifier.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 30 matching lines...) Expand all
41 * the terms of any one of the MPL, the GPL or the LGPL. 41 * the terms of any one of the MPL, the GPL or the LGPL.
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 48
49 #include "base/basictypes.h" 49 #include "base/basictypes.h"
50 #include "base/format_macros.h" 50 #include "base/format_macros.h"
51 #include "base/histogram.h"
51 #include "base/logging.h" 52 #include "base/logging.h"
52 #include "base/scoped_ptr.h" 53 #include "base/scoped_ptr.h"
53 #include "base/string_tokenizer.h" 54 #include "base/string_tokenizer.h"
54 #include "base/string_util.h" 55 #include "base/string_util.h"
55 #include "googleurl/src/gurl.h" 56 #include "googleurl/src/gurl.h"
56 #include "googleurl/src/url_canon.h" 57 #include "googleurl/src/url_canon.h"
57 #include "net/base/net_util.h" 58 #include "net/base/net_util.h"
58 #include "net/base/registry_controlled_domain.h" 59 #include "net/base/registry_controlled_domain.h"
59 60
60 // #define COOKIE_LOGGING_ENABLED 61 // #define COOKIE_LOGGING_ENABLED
(...skipping 1629 matching lines...) Expand 10 before | Expand all | Expand 10 after
1690 for (PairList::const_iterator it = pairs_.begin(); 1691 for (PairList::const_iterator it = pairs_.begin();
1691 it != pairs_.end(); ++it) { 1692 it != pairs_.end(); ++it) {
1692 out.append(it->first); 1693 out.append(it->first);
1693 out.append("="); 1694 out.append("=");
1694 out.append(it->second); 1695 out.append(it->second);
1695 out.append("; "); 1696 out.append("; ");
1696 } 1697 }
1697 return out; 1698 return out;
1698 } 1699 }
1699 1700
1701 CookieMonster::CanonicalCookie::CanonicalCookie() {
1702 }
1703
1704 CookieMonster::CanonicalCookie::CanonicalCookie(const std::string& name,
1705 const std::string& value,
1706 const std::string& domain,
1707 const std::string& path,
1708 bool secure,
1709 bool httponly,
1710 const base::Time& creation,
1711 const base::Time& last_access,
1712 bool has_expires,
1713 const base::Time& expires)
1714 : name_(name),
1715 value_(value),
1716 domain_(domain),
1717 path_(path),
1718 creation_date_(creation),
1719 last_access_date_(last_access),
1720 expiry_date_(expires),
1721 has_expires_(has_expires),
1722 secure_(secure),
1723 httponly_(httponly) {
1724 }
1725
1700 CookieMonster::CanonicalCookie::CanonicalCookie(const GURL& url, 1726 CookieMonster::CanonicalCookie::CanonicalCookie(const GURL& url,
1701 const ParsedCookie& pc) 1727 const ParsedCookie& pc)
1702 : name_(pc.Name()), 1728 : name_(pc.Name()),
1703 value_(pc.Value()), 1729 value_(pc.Value()),
1704 path_(CanonPath(url, pc)), 1730 path_(CanonPath(url, pc)),
1705 creation_date_(Time::Now()), 1731 creation_date_(Time::Now()),
1706 last_access_date_(Time()), 1732 last_access_date_(Time()),
1707 has_expires_(pc.HasExpires()), 1733 has_expires_(pc.HasExpires()),
1708 secure_(pc.IsSecure()), 1734 secure_(pc.IsSecure()),
1709 httponly_(pc.IsHttpOnly()) { 1735 httponly_(pc.IsHttpOnly()) {
1710 if (has_expires_) 1736 if (has_expires_)
1711 expiry_date_ = CanonExpiration(pc, creation_date_, CookieOptions()); 1737 expiry_date_ = CanonExpiration(pc, creation_date_, CookieOptions());
1712 1738
1713 // Do the best we can with the domain. 1739 // Do the best we can with the domain.
1714 std::string cookie_domain; 1740 std::string cookie_domain;
1715 std::string domain_string; 1741 std::string domain_string;
1716 if (pc.HasDomain()) { 1742 if (pc.HasDomain()) {
1717 domain_string = pc.Domain(); 1743 domain_string = pc.Domain();
1718 } 1744 }
1719 bool result 1745 bool result
1720 = GetCookieDomainWithString(url, domain_string, 1746 = GetCookieDomainWithString(url, domain_string,
1721 &cookie_domain); 1747 &cookie_domain);
1722 // Caller is responsible for passing in good arguments. 1748 // Caller is responsible for passing in good arguments.
1723 DCHECK(result); 1749 DCHECK(result);
1724 domain_ = cookie_domain; 1750 domain_ = cookie_domain;
1725 } 1751 }
1726 1752
1753 CookieMonster::CookieMonster(PersistentCookieStore* store,
1754 Delegate* delegate,
1755 int last_access_threshold_milliseconds)
1756 : initialized_(false),
1757 use_effective_domain_key_scheme_(use_effective_domain_key_default_),
1758 store_(store),
1759 last_access_threshold_(base::TimeDelta::FromMilliseconds(
1760 last_access_threshold_milliseconds)),
1761 delegate_(delegate),
1762 last_statistic_record_time_(base::Time::Now()) {
1763 InitializeHistograms();
1764 SetDefaultCookieableSchemes();
1765 }
1766
1767 CookieMonster::CanonicalCookie::~CanonicalCookie() {
1768 }
1769
1727 CookieMonster::CanonicalCookie* CookieMonster::CanonicalCookie::Create( 1770 CookieMonster::CanonicalCookie* CookieMonster::CanonicalCookie::Create(
1728 const GURL& url, const std::string& name, const std::string& value, 1771 const GURL& url, const std::string& name, const std::string& value,
1729 const std::string& domain, const std::string& path, 1772 const std::string& domain, const std::string& path,
1730 const base::Time& creation_time, const base::Time& expiration_time, 1773 const base::Time& creation_time, const base::Time& expiration_time,
1731 bool secure, bool http_only) { 1774 bool secure, bool http_only) {
1732 // Expect valid attribute tokens and values, as defined by the ParsedCookie 1775 // Expect valid attribute tokens and values, as defined by the ParsedCookie
1733 // logic, otherwise don't create the cookie. 1776 // logic, otherwise don't create the cookie.
1734 std::string parsed_name = ParsedCookie::ParseTokenString(name); 1777 std::string parsed_name = ParsedCookie::ParseTokenString(name);
1735 if (parsed_name != name) 1778 if (parsed_name != name)
1736 return NULL; 1779 return NULL;
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
1842 std::string CookieMonster::CanonicalCookie::DebugString() const { 1885 std::string CookieMonster::CanonicalCookie::DebugString() const {
1843 return StringPrintf("name: %s value: %s domain: %s path: %s creation: %" 1886 return StringPrintf("name: %s value: %s domain: %s path: %s creation: %"
1844 PRId64, 1887 PRId64,
1845 name_.c_str(), value_.c_str(), 1888 name_.c_str(), value_.c_str(),
1846 domain_.c_str(), path_.c_str(), 1889 domain_.c_str(), path_.c_str(),
1847 static_cast<int64>(creation_date_.ToTimeT())); 1890 static_cast<int64>(creation_date_.ToTimeT()));
1848 } 1891 }
1849 1892
1850 } // namespace 1893 } // namespace
1851 1894
OLDNEW
« no previous file with comments | « net/base/cookie_monster.h ('k') | net/base/dnssec_chain_verifier.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698