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

Unified Diff: net/cookies/cookie_store.h

Issue 2937963003: Shift cookie system callbacks to OnceCallback to impedance match mojo. (Closed)
Patch Set: Finish Merge Created 3 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: net/cookies/cookie_store.h
diff --git a/net/cookies/cookie_store.h b/net/cookies/cookie_store.h
index 931b2ea1e4f0ac63296932f1c63e7c7ff6303fe5..9ef7535707e26227c7177e072295d2dd081981d9 100644
--- a/net/cookies/cookie_store.h
+++ b/net/cookies/cookie_store.h
@@ -64,10 +64,13 @@ class NET_EXPORT CookieStore {
static bool ChangeCauseIsDeletion(ChangeCause cause);
// Callback definitions.
- typedef base::Callback<void(const CookieList& cookies)> GetCookieListCallback;
- typedef base::Callback<void(const std::string& cookie)> GetCookiesCallback;
- typedef base::Callback<void(bool success)> SetCookiesCallback;
- typedef base::Callback<void(int num_deleted)> DeleteCallback;
+ typedef base::OnceCallback<void(const CookieList& cookies)>
+ GetCookieListCallback;
+ typedef base::OnceCallback<void(const std::string& cookie)>
+ GetCookiesCallback;
+ typedef base::OnceCallback<void(bool success)> SetCookiesCallback;
+ typedef base::OnceCallback<void(int num_deleted)> DeleteCallback;
+
typedef base::Callback<void(const CanonicalCookie& cookie, ChangeCause cause)>
CookieChangedCallback;
typedef base::CallbackList<void(const CanonicalCookie& cookie,
@@ -95,11 +98,10 @@ class NET_EXPORT CookieStore {
// Fails either if the cookie is invalid or if this is a non-HTTPONLY cookie
// and it would overwrite an existing HTTPONLY cookie.
// Returns true if the cookie is successfully set.
- virtual void SetCookieWithOptionsAsync(
- const GURL& url,
- const std::string& cookie_line,
- const CookieOptions& options,
- const SetCookiesCallback& callback) = 0;
+ virtual void SetCookieWithOptionsAsync(const GURL& url,
+ const std::string& cookie_line,
+ const CookieOptions& options,
+ SetCookiesCallback callback) = 0;
// Sets a cookie given explicit user-provided cookie attributes. The cookie
// name, value, domain, etc. are each provided as separate strings. This
@@ -112,20 +114,19 @@ class NET_EXPORT CookieStore {
// If |last_access_time| is null, it be set to |creation_time|.
//
// If unable to set a cookie, will invoke |callback| with false.
- virtual void SetCookieWithDetailsAsync(
- const GURL& url,
- const std::string& name,
- const std::string& value,
- const std::string& domain,
- const std::string& path,
- base::Time creation_time,
- base::Time expiration_time,
- base::Time last_access_time,
- bool secure,
- bool http_only,
- CookieSameSite same_site,
- CookiePriority priority,
- const SetCookiesCallback& callback) = 0;
+ virtual void SetCookieWithDetailsAsync(const GURL& url,
+ const std::string& name,
+ const std::string& value,
+ const std::string& domain,
+ const std::string& path,
+ base::Time creation_time,
+ base::Time expiration_time,
+ base::Time last_access_time,
+ bool secure,
+ bool http_only,
+ CookieSameSite same_site,
+ CookiePriority priority,
+ SetCookiesCallback callback) = 0;
// TODO(rdsmith): Remove SetCookieWithDetailsAsync in favor of this.
// Set the cookie on the cookie store. |cookie.IsCanonical()| must
@@ -137,7 +138,7 @@ class NET_EXPORT CookieStore {
virtual void SetCanonicalCookieAsync(std::unique_ptr<CanonicalCookie> cookie,
bool secure_source,
bool modify_http_only,
- const SetCookiesCallback& callback) = 0;
+ SetCookiesCallback callback) = 0;
// TODO(???): what if the total size of all the cookies >4k, can we have a
// header that big or do we need multiple Cookie: headers?
@@ -152,10 +153,9 @@ class NET_EXPORT CookieStore {
//
// TODO(mkwst): This method is deprecated; callsites should be updated to
// use 'GetCookieListWithOptionsAsync'.
- virtual void GetCookiesWithOptionsAsync(
- const GURL& url,
- const CookieOptions& options,
- const GetCookiesCallback& callback) = 0;
+ virtual void GetCookiesWithOptionsAsync(const GURL& url,
+ const CookieOptions& options,
+ GetCookiesCallback callback) = 0;
// Obtains a CookieList for the given |url| and |options|. The returned
// cookies are passed into |callback|, ordered by longest path, then earliest
@@ -163,7 +163,7 @@ class NET_EXPORT CookieStore {
virtual void GetCookieListWithOptionsAsync(
const GURL& url,
const CookieOptions& options,
- const GetCookieListCallback& callback) = 0;
+ GetCookieListCallback callback) = 0;
// Returns all cookies associated with |url|, including http-only, and
// same-site cookies. The returned cookies are ordered by longest path, then
@@ -173,30 +173,30 @@ class NET_EXPORT CookieStore {
// updating callsites to use 'GetCookieListWithOptionsAsync' with an explicit
// CookieOptions, or by changing CookieOptions' defaults.
void GetAllCookiesForURLAsync(const GURL& url,
- const GetCookieListCallback& callback);
+ GetCookieListCallback callback);
// Returns all the cookies, for use in management UI, etc. This does not mark
// the cookies as having been accessed. The returned cookies are ordered by
// longest path, then by earliest creation date.
- virtual void GetAllCookiesAsync(const GetCookieListCallback& callback) = 0;
+ virtual void GetAllCookiesAsync(GetCookieListCallback callback) = 0;
// Deletes all cookies that might apply to |url| that have |cookie_name|.
virtual void DeleteCookieAsync(const GURL& url,
const std::string& cookie_name,
- const base::Closure& callback) = 0;
+ base::OnceClosure callback) = 0;
// Deletes one specific cookie. |cookie| must have been returned by a previous
// query on this CookieStore. Invokes |callback| with 1 if a cookie was
// deleted, 0 otherwise.
virtual void DeleteCanonicalCookieAsync(const CanonicalCookie& cookie,
- const DeleteCallback& callback) = 0;
+ DeleteCallback callback) = 0;
// Deletes all of the cookies that have a creation_date greater than or equal
// to |delete_begin| and less than |delete_end|
// Calls |callback| with the number of cookies deleted.
virtual void DeleteAllCreatedBetweenAsync(const base::Time& delete_begin,
const base::Time& delete_end,
- const DeleteCallback& callback) = 0;
+ DeleteCallback callback) = 0;
// Deletes all of the cookies that match the given predicate and that have a
// creation_date greater than or equal to |delete_begin| and smaller than
@@ -208,16 +208,16 @@ class NET_EXPORT CookieStore {
const base::Time& delete_begin,
const base::Time& delete_end,
const CookiePredicate& predicate,
- const DeleteCallback& callback) = 0;
+ DeleteCallback callback) = 0;
- virtual void DeleteSessionCookiesAsync(const DeleteCallback&) = 0;
+ virtual void DeleteSessionCookiesAsync(DeleteCallback) = 0;
// Deletes all cookies in the store.
- void DeleteAllAsync(const DeleteCallback& callback);
+ void DeleteAllAsync(DeleteCallback callback);
// Flush the backing store (if any) to disk and post the given callback when
// done.
- virtual void FlushStore(const base::Closure& callback) = 0;
+ virtual void FlushStore(base::OnceClosure callback) = 0;
// Protects session cookies from deletion on shutdown, if the underlying
// CookieStore implemention is currently configured to store them to disk.

Powered by Google App Engine
This is Rietveld 408576698