Commit ec9caca7 authored by Eric Orth's avatar Eric Orth Committed by Commit Bot

Servicify http auth cache removal in ChromeBrowsingDataRemoverDelegate.

Bug: 824967
Change-Id: I4eb57d85bb057061bf12848f39127a6542ebe886
Reviewed-on: https://chromium-review.googlesource.com/1037523
Commit-Queue: Eric Orth <ericorth@chromium.org>
Reviewed-by: default avatarMartin Šrámek <msramek@chromium.org>
Reviewed-by: default avatarHelen Li <xunjieli@chromium.org>
Cr-Commit-Position: refs/heads/master@{#555881}
parent 4d96f549
...@@ -88,6 +88,7 @@ ...@@ -88,6 +88,7 @@
#include "content/public/browser/ssl_host_state_delegate.h" #include "content/public/browser/ssl_host_state_delegate.h"
#include "content/public/browser/storage_partition.h" #include "content/public/browser/storage_partition.h"
#include "media/mojo/services/video_decode_perf_history.h" #include "media/mojo/services/video_decode_perf_history.h"
#include "mojo/public/cpp/bindings/callback_helpers.h"
#include "net/cookies/cookie_store.h" #include "net/cookies/cookie_store.h"
#include "net/http/http_transaction_factory.h" #include "net/http/http_transaction_factory.h"
#include "net/net_buildflags.h" #include "net/net_buildflags.h"
...@@ -249,20 +250,6 @@ void ClearHostnameResolutionCacheOnIOThread( ...@@ -249,20 +250,6 @@ void ClearHostnameResolutionCacheOnIOThread(
io_thread->ClearHostCache(host_filter); io_thread->ClearHostCache(host_filter);
} }
void ClearHttpAuthCacheOnIOThread(
scoped_refptr<net::URLRequestContextGetter> context_getter,
base::Time delete_begin) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
net::HttpNetworkSession* http_session = context_getter->GetURLRequestContext()
->http_transaction_factory()
->GetSession();
DCHECK(http_session);
http_session->http_auth_cache()->ClearEntriesAddedWithin(base::Time::Now() -
delete_begin);
http_session->CloseAllConnections();
}
#if BUILDFLAG(ENABLE_REPORTING) #if BUILDFLAG(ENABLE_REPORTING)
void ClearReportingCacheOnIOThread( void ClearReportingCacheOnIOThread(
net::URLRequestContextGetter* context, net::URLRequestContextGetter* context,
...@@ -848,14 +835,10 @@ void ChromeBrowsingDataRemoverDelegate::RemoveEmbedderData( ...@@ -848,14 +835,10 @@ void ChromeBrowsingDataRemoverDelegate::RemoveEmbedderData(
CreatePendingTaskCompletionClosure())); CreatePendingTaskCompletionClosure()));
} }
scoped_refptr<net::URLRequestContextGetter> request_context = BrowserContext::GetDefaultStoragePartition(profile_)
BrowserContext::GetDefaultStoragePartition(profile_) ->GetNetworkContext()
->GetURLRequestContext(); ->ClearHttpAuthCache(delete_begin_,
BrowserThread::PostTaskAndReply( CreatePendingTaskCompletionClosureForMojo());
BrowserThread::IO, FROM_HERE,
base::BindOnce(&ClearHttpAuthCacheOnIOThread,
std::move(request_context), delete_begin_),
CreatePendingTaskCompletionClosure());
} }
if (remove_mask & content::BrowsingDataRemover::DATA_TYPE_COOKIES) { if (remove_mask & content::BrowsingDataRemover::DATA_TYPE_COOKIES) {
...@@ -1191,6 +1174,17 @@ ChromeBrowsingDataRemoverDelegate::CreatePendingTaskCompletionClosure() { ...@@ -1191,6 +1174,17 @@ ChromeBrowsingDataRemoverDelegate::CreatePendingTaskCompletionClosure() {
weak_ptr_factory_.GetWeakPtr()); weak_ptr_factory_.GetWeakPtr());
} }
base::OnceClosure
ChromeBrowsingDataRemoverDelegate::CreatePendingTaskCompletionClosureForMojo() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
// Note num_pending_tasks++ unnecessary here because it's done by the call to
// CreatePendingTaskCompletionClosure().
return mojo::WrapCallbackWithDropHandler(
CreatePendingTaskCompletionClosure(),
base::BindOnce(&ChromeBrowsingDataRemoverDelegate::OnTaskComplete,
weak_ptr_factory_.GetWeakPtr()));
}
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
void ChromeBrowsingDataRemoverDelegate::OverrideWebappRegistryForTesting( void ChromeBrowsingDataRemoverDelegate::OverrideWebappRegistryForTesting(
std::unique_ptr<WebappRegistry> webapp_registry) { std::unique_ptr<WebappRegistry> webapp_registry) {
......
...@@ -187,6 +187,11 @@ class ChromeBrowsingDataRemoverDelegate ...@@ -187,6 +187,11 @@ class ChromeBrowsingDataRemoverDelegate
// created by this method have been invoked. // created by this method have been invoked.
base::OnceClosure CreatePendingTaskCompletionClosure(); base::OnceClosure CreatePendingTaskCompletionClosure();
// Same as CreatePendingTaskCompletionClosure() but guarantees that
// OnTaskComplete() is called if the task is dropped. That can typically
// happen when the connection is closed while an interface call is made.
base::OnceClosure CreatePendingTaskCompletionClosureForMojo();
// Callback for when TemplateURLService has finished loading. Clears the data, // Callback for when TemplateURLService has finished loading. Clears the data,
// clears the respective waiting flag, and invokes NotifyIfDone. // clears the respective waiting flag, and invokes NotifyIfDone.
void OnKeywordsLoaded(base::RepeatingCallback<bool(const GURL&)> url_filter, void OnKeywordsLoaded(base::RepeatingCallback<bool(const GURL&)> url_filter,
......
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