Commit 25087abf authored by Dylan Cutler's avatar Dylan Cutler Committed by Commit Bot

Make CreateUnsafeCookieForTesting return a unique_ptr.

This will make it easier to use this factory when testing code that uses
SetCanonicalCookie() and other methods that take unique_ptrs to
CanonicalCookies.

The factory method uses base::WrapUnique to create the unique_ptr so
that the constructor can be made private. I plan on updating the other
factory methods to use base::WrapUnique instead of make_unique in a
follow-up CL.

Bug: 1102874
Change-Id: I3e84fbc68ce95438a5adfdac46573df9efe4e38d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2559311Reviewed-by: default avatarMaksim Orlovich <morlovich@chromium.org>
Commit-Queue: Dylan Cutler <dylancutler@google.com>
Cr-Commit-Position: refs/heads/master@{#831072}
parent 3bad00bf
...@@ -50,6 +50,7 @@ ...@@ -50,6 +50,7 @@
#include "base/feature_list.h" #include "base/feature_list.h"
#include "base/format_macros.h" #include "base/format_macros.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/metrics/histogram_functions.h" #include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_macros.h"
#include "base/strings/strcat.h" #include "base/strings/strcat.h"
...@@ -553,7 +554,7 @@ std::unique_ptr<CanonicalCookie> CanonicalCookie::FromStorage( ...@@ -553,7 +554,7 @@ std::unique_ptr<CanonicalCookie> CanonicalCookie::FromStorage(
} }
// static // static
CanonicalCookie CanonicalCookie::CreateUnsafeCookieForTesting( std::unique_ptr<CanonicalCookie> CanonicalCookie::CreateUnsafeCookieForTesting(
const std::string& name, const std::string& name,
const std::string& value, const std::string& value,
const std::string& domain, const std::string& domain,
...@@ -568,9 +569,9 @@ CanonicalCookie CanonicalCookie::CreateUnsafeCookieForTesting( ...@@ -568,9 +569,9 @@ CanonicalCookie CanonicalCookie::CreateUnsafeCookieForTesting(
bool same_party, bool same_party,
CookieSourceScheme source_scheme, CookieSourceScheme source_scheme,
int source_port) { int source_port) {
return CanonicalCookie(name, value, domain, path, creation, expiration, return base::WrapUnique(new CanonicalCookie(
last_access, secure, httponly, same_site, priority, name, value, domain, path, creation, expiration, last_access, secure,
same_party, source_scheme, source_port); httponly, same_site, priority, same_party, source_scheme, source_port));
} }
std::string CanonicalCookie::DomainWithoutDot() const { std::string CanonicalCookie::DomainWithoutDot() const {
......
...@@ -147,7 +147,7 @@ class NET_EXPORT CanonicalCookie { ...@@ -147,7 +147,7 @@ class NET_EXPORT CanonicalCookie {
// Create a CanonicalCookie that is not guaranteed to actually be Canonical // Create a CanonicalCookie that is not guaranteed to actually be Canonical
// for tests. This factory should NOT be used in production. // for tests. This factory should NOT be used in production.
static CanonicalCookie CreateUnsafeCookieForTesting( static std::unique_ptr<CanonicalCookie> CreateUnsafeCookieForTesting(
const std::string& name, const std::string& name,
const std::string& value, const std::string& value,
const std::string& domain, const std::string& domain,
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment