Index: net/cookies/canonical_cookie.cc |
diff --git a/net/cookies/canonical_cookie.cc b/net/cookies/canonical_cookie.cc |
index 15287e0b8b554a4e362248738c6a35866c5202b1..4491873003b59aa22bdcd4d5e18f7ab270a03bed 100644 |
--- a/net/cookies/canonical_cookie.cc |
+++ b/net/cookies/canonical_cookie.cc |
@@ -217,26 +217,27 @@ Time CanonicalCookie::CanonExpiration(const ParsedCookie& pc, |
} |
// static |
-CanonicalCookie* CanonicalCookie::Create(const GURL& url, |
- const std::string& cookie_line, |
- const base::Time& creation_time, |
- const CookieOptions& options) { |
+scoped_ptr<CanonicalCookie> CanonicalCookie::Create( |
+ const GURL& url, |
+ const std::string& cookie_line, |
+ const base::Time& creation_time, |
+ const CookieOptions& options) { |
ParsedCookie parsed_cookie(cookie_line); |
if (!parsed_cookie.IsValid()) { |
VLOG(kVlogSetCookies) << "WARNING: Couldn't parse cookie"; |
- return NULL; |
+ return nullptr; |
} |
if (options.exclude_httponly() && parsed_cookie.IsHttpOnly()) { |
VLOG(kVlogSetCookies) << "Create() is not creating a httponly cookie"; |
- return NULL; |
+ return nullptr; |
} |
std::string cookie_domain; |
if (!GetCookieDomain(url, parsed_cookie, &cookie_domain)) { |
VLOG(kVlogSetCookies) << "Create() failed to get a cookie domain"; |
- return NULL; |
+ return nullptr; |
} |
// Per 3.2.1 of "Deprecate modification of 'secure' cookies from non-secure |
@@ -247,7 +248,7 @@ CanonicalCookie* CanonicalCookie::Create(const GURL& url, |
!url.SchemeIsCryptographic()) { |
VLOG(kVlogSetCookies) |
<< "Create() is trying to create a secure cookie from an insecure URL"; |
- return NULL; |
+ return nullptr; |
} |
std::string cookie_path = CanonicalCookie::CanonPath(url, parsed_cookie); |
@@ -269,54 +270,56 @@ CanonicalCookie* CanonicalCookie::Create(const GURL& url, |
return nullptr; |
} |
- return new CanonicalCookie( |
+ return make_scoped_ptr(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.IsFirstPartyOnly(), parsed_cookie.Priority()); |
+ parsed_cookie.IsFirstPartyOnly(), parsed_cookie.Priority())); |
} |
-CanonicalCookie* CanonicalCookie::Create(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, |
- bool secure, |
- bool http_only, |
- bool first_party_only, |
- bool enforce_strict_secure, |
- CookiePriority priority) { |
+// static |
+scoped_ptr<CanonicalCookie> CanonicalCookie::Create( |
+ 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, |
+ bool secure, |
+ bool http_only, |
+ bool first_party_only, |
+ bool enforce_strict_secure, |
+ CookiePriority priority) { |
// Expect valid attribute tokens and values, as defined by the ParsedCookie |
// logic, otherwise don't create the cookie. |
std::string parsed_name = ParsedCookie::ParseTokenString(name); |
if (parsed_name != name) |
- return NULL; |
+ return nullptr; |
std::string parsed_value = ParsedCookie::ParseValueString(value); |
if (parsed_value != value) |
- return NULL; |
+ return nullptr; |
std::string parsed_domain = ParsedCookie::ParseValueString(domain); |
if (parsed_domain != domain) |
- return NULL; |
+ return nullptr; |
std::string cookie_domain; |
if (!cookie_util::GetCookieDomainWithString(url, parsed_domain, |
&cookie_domain)) { |
- return NULL; |
+ return nullptr; |
} |
if (enforce_strict_secure && secure && !url.SchemeIsCryptographic()) |
- return NULL; |
+ return nullptr; |
std::string parsed_path = ParsedCookie::ParseValueString(path); |
if (parsed_path != path) |
- return NULL; |
+ return nullptr; |
std::string cookie_path = CanonPathWithString(url, parsed_path); |
// Expect that the path was either not specified (empty), or is valid. |
if (!parsed_path.empty() && cookie_path != parsed_path) |
- return NULL; |
+ return nullptr; |
// Canonicalize path again to make sure it escapes characters as needed. |
url::Component path_component(0, cookie_path.length()); |
url::RawCanonOutputT<char> canon_path; |
@@ -326,9 +329,9 @@ CanonicalCookie* CanonicalCookie::Create(const GURL& url, |
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, first_party_only, priority); |
+ return make_scoped_ptr(new CanonicalCookie( |
+ url, parsed_name, parsed_value, cookie_domain, cookie_path, creation, |
+ expiration, creation, secure, http_only, first_party_only, priority)); |
} |
bool CanonicalCookie::IsOnPath(const std::string& url_path) const { |