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

Unified Diff: content/browser/storage_partition_impl.cc

Issue 1844243002: [CookieStore] Upgrading host-based deleting to predicate-based deleting. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 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
« no previous file with comments | « content/browser/storage_partition_impl.h ('k') | content/browser/storage_partition_impl_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/storage_partition_impl.cc
diff --git a/content/browser/storage_partition_impl.cc b/content/browser/storage_partition_impl.cc
index 28b0eb13450342a737477b57648e1f57fde54821..f78f9a456f7a2c8437004a3e7fbc316b45b2ae89 100644
--- a/content/browser/storage_partition_impl.cc
+++ b/content/browser/storage_partition_impl.cc
@@ -9,6 +9,7 @@
#include <set>
#include <vector>
+#include "base/bind.h"
#include "base/location.h"
#include "base/sequenced_task_runner.h"
#include "base/single_thread_task_runner.h"
@@ -28,6 +29,7 @@
#include "content/public/browser/session_storage_usage_info.h"
#include "net/base/completion_callback.h"
#include "net/base/net_errors.h"
+#include "net/cookies/canonical_cookie.h"
#include "net/cookies/cookie_monster.h"
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_getter.h"
@@ -38,6 +40,11 @@ namespace content {
namespace {
+bool DoesCookieMatchHost(const std::string& host,
+ const net::CanonicalCookie& cookie) {
+ return cookie.IsHostCookie() && cookie.IsDomainMatch(host);
+}
+
void OnClearedCookies(const base::Closure& callback, int num_deleted) {
// The final callback needs to happen from UI thread.
if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
@@ -65,10 +72,13 @@ void ClearCookiesOnIOThread(
end,
base::Bind(&OnClearedCookies, callback));
} else {
- cookie_store->DeleteAllCreatedBetweenForHostAsync(
- begin,
- end,
- storage_origin, base::Bind(&OnClearedCookies, callback));
+ // TODO(mkwst): It's not clear whether removing host cookies is the correct
+ // behavior. We might want to remove all domain-matching cookies instead.
+ // Also, this code path may be dead anyways.
+ cookie_store->DeleteAllCreatedBetweenWithPredicateAsync(
+ begin, end,
+ StoragePartitionImpl::CreatePredicateForHostCookies(storage_origin),
+ base::Bind(&OnClearedCookies, callback));
}
}
@@ -221,6 +231,12 @@ int StoragePartitionImpl::GenerateQuotaClientMask(uint32_t remove_mask) {
return quota_client_mask;
}
+// static
+net::CookieStore::CookiePredicate
+StoragePartitionImpl::CreatePredicateForHostCookies(const GURL& url) {
+ return base::Bind(&DoesCookieMatchHost, url.host());
+}
+
// Helper for deleting quota managed data from a partition.
//
// Most of the operations in this class are done on IO thread.
« no previous file with comments | « content/browser/storage_partition_impl.h ('k') | content/browser/storage_partition_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698