| Index: net/cookies/canonical_cookie.cc
|
| diff --git a/net/cookies/canonical_cookie.cc b/net/cookies/canonical_cookie.cc
|
| index 5d67ebc21828614c10a7d518d2a0f07e6a76c372..9db663cf938faafa775c8d7652fe554d2d4d626f 100644
|
| --- a/net/cookies/canonical_cookie.cc
|
| +++ b/net/cookies/canonical_cookie.cc
|
| @@ -104,17 +104,20 @@ std::string CanonPathWithString(const GURL& url,
|
|
|
| } // namespace
|
|
|
| -CanonicalCookie::CanonicalCookie()
|
| - : secure_(false),
|
| - httponly_(false) {
|
| +CanonicalCookie::CanonicalCookie() : secure_(false), httponly_(false) {
|
| }
|
|
|
| -CanonicalCookie::CanonicalCookie(
|
| - const GURL& url, const std::string& name, const std::string& value,
|
| - const std::string& domain, const std::string& path,
|
| - const base::Time& creation, const base::Time& expiration,
|
| - const base::Time& last_access, bool secure, bool httponly,
|
| - CookiePriority priority)
|
| +CanonicalCookie::CanonicalCookie(const GURL& url,
|
| + const std::string& name,
|
| + const std::string& value,
|
| + const std::string& domain,
|
| + const std::string& path,
|
| + const base::Time& creation,
|
| + const base::Time& expiration,
|
| + const base::Time& last_access,
|
| + bool secure,
|
| + bool httponly,
|
| + CookiePriority priority)
|
| : source_(GetCookieSourceFromURL(url)),
|
| name_(name),
|
| value_(value),
|
| @@ -147,9 +150,8 @@ CanonicalCookie::CanonicalCookie(const GURL& url, const ParsedCookie& pc)
|
| if (pc.HasDomain()) {
|
| domain_string = pc.Domain();
|
| }
|
| - bool result
|
| - = cookie_util::GetCookieDomainWithString(url, domain_string,
|
| - &cookie_domain);
|
| + bool result = cookie_util::GetCookieDomainWithString(
|
| + url, domain_string, &cookie_domain);
|
| // Caller is responsible for passing in good arguments.
|
| DCHECK(result);
|
| domain_ = cookie_domain;
|
| @@ -191,7 +193,7 @@ Time CanonicalCookie::CanonExpiration(const ParsedCookie& pc,
|
| #else
|
| sscanf(
|
| #endif
|
| - pc.MaxAge().c_str(), " %" PRIu64, &max_age) == 1) {
|
| + pc.MaxAge().c_str(), " %" PRIu64, &max_age) == 1) {
|
| return current + TimeDelta::FromSeconds(max_age);
|
| }
|
|
|
| @@ -234,13 +236,17 @@ CanonicalCookie* CanonicalCookie::Create(const GURL& url,
|
| if (options.has_server_time())
|
| server_time = options.server_time();
|
|
|
| - Time cookie_expires = CanonicalCookie::CanonExpiration(parsed_cookie,
|
| - creation_time,
|
| - server_time);
|
| -
|
| - return new CanonicalCookie(url, parsed_cookie.Name(), parsed_cookie.Value(),
|
| - cookie_domain, cookie_path, creation_time,
|
| - cookie_expires, creation_time,
|
| + Time cookie_expires = CanonicalCookie::CanonExpiration(
|
| + parsed_cookie, creation_time, server_time);
|
| +
|
| + return new CanonicalCookie(url,
|
| + parsed_cookie.Name(),
|
| + parsed_cookie.Value(),
|
| + cookie_domain,
|
| + cookie_path,
|
| + creation_time,
|
| + cookie_expires,
|
| + creation_time,
|
| parsed_cookie.IsSecure(),
|
| parsed_cookie.IsHttpOnly(),
|
| parsed_cookie.Priority());
|
| @@ -269,8 +275,8 @@ CanonicalCookie* CanonicalCookie::Create(const GURL& url,
|
| if (parsed_domain != domain)
|
| return NULL;
|
| std::string cookie_domain;
|
| - if (!cookie_util::GetCookieDomainWithString(url, parsed_domain,
|
| - &cookie_domain)) {
|
| + if (!cookie_util::GetCookieDomainWithString(
|
| + url, parsed_domain, &cookie_domain)) {
|
| return NULL;
|
| }
|
|
|
| @@ -286,18 +292,25 @@ CanonicalCookie* CanonicalCookie::Create(const GURL& url,
|
| url::Component path_component(0, cookie_path.length());
|
| url::RawCanonOutputT<char> canon_path;
|
| url::Component canon_path_component;
|
| - url::CanonicalizePath(cookie_path.data(), path_component, &canon_path,
|
| - &canon_path_component);
|
| + url::CanonicalizePath(
|
| + cookie_path.data(), path_component, &canon_path, &canon_path_component);
|
| cookie_path = std::string(canon_path.data() + canon_path_component.begin,
|
| canon_path_component.len);
|
|
|
| - return new CanonicalCookie(url, parsed_name, parsed_value, cookie_domain,
|
| - cookie_path, creation, expiration, creation,
|
| - secure, http_only, priority);
|
| + return new CanonicalCookie(url,
|
| + parsed_name,
|
| + parsed_value,
|
| + cookie_domain,
|
| + cookie_path,
|
| + creation,
|
| + expiration,
|
| + creation,
|
| + secure,
|
| + http_only,
|
| + priority);
|
| }
|
|
|
| bool CanonicalCookie::IsOnPath(const std::string& url_path) const {
|
| -
|
| // A zero length would be unsafe for our trailing '/' checks, and
|
| // would also make no sense for our prefix match. The code that
|
| // creates a CanonicalCookie should make sure the path is never zero length,
|
| @@ -324,8 +337,7 @@ bool CanonicalCookie::IsOnPath(const std::string& url_path) const {
|
| // the cookie path ends in a trailing '/', or that we prefix up to a '/'
|
| // in the url path. Since we know that the url path length is greater
|
| // than the cookie path length, it's safe to index one byte past.
|
| - if (path_.length() != url_path.length() &&
|
| - path_[path_.length() - 1] != '/' &&
|
| + if (path_.length() != url_path.length() && path_[path_.length() - 1] != '/' &&
|
| url_path[path_.length()] != '/')
|
| return false;
|
|
|
| @@ -362,7 +374,8 @@ bool CanonicalCookie::IsDomainMatch(const std::string& host) const {
|
| // starts with a ".")
|
| return (host.length() > domain_.length() &&
|
| host.compare(host.length() - domain_.length(),
|
| - domain_.length(), domain_) == 0);
|
| + domain_.length(),
|
| + domain_) == 0);
|
| }
|
|
|
| bool CanonicalCookie::IncludeForRequestURL(const GURL& url,
|
| @@ -387,10 +400,11 @@ bool CanonicalCookie::IncludeForRequestURL(const GURL& url,
|
|
|
| std::string CanonicalCookie::DebugString() const {
|
| return base::StringPrintf(
|
| - "name: %s value: %s domain: %s path: %s creation: %"
|
| - PRId64,
|
| - name_.c_str(), value_.c_str(),
|
| - domain_.c_str(), path_.c_str(),
|
| + "name: %s value: %s domain: %s path: %s creation: %" PRId64,
|
| + name_.c_str(),
|
| + value_.c_str(),
|
| + domain_.c_str(),
|
| + path_.c_str(),
|
| static_cast<int64>(creation_date_.ToTimeT()));
|
| }
|
|
|
|
|