Commit de2c3629 authored by David Bokan's avatar David Bokan Committed by Chromium LUCI CQ

Convert web_view_internal_api to BindOnce

The callback in ClearData is either called immediately or passed to
other async code that does the same so this callback is only ever called
once.

Bug: 1152268
Change-Id: I11a0d565a11503955e1224c4e370437c6dba9a35
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2593877Reviewed-by: default avatarLucas Gadani <lfg@chromium.org>
Commit-Queue: David Bokan <bokan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#837595}
parent 7d21a52d
......@@ -1051,7 +1051,7 @@ ExtensionFunction::ResponseAction WebViewInternalClearDataFunction::Run() {
if (remove_mask_) {
scheduled = guest_->ClearData(
remove_since_, remove_mask_,
base::Bind(&WebViewInternalClearDataFunction::ClearDataDone, this));
base::BindOnce(&WebViewInternalClearDataFunction::ClearDataDone, this));
}
if (!remove_mask_ || !scheduled) {
Release(); // Balanced above.
......
......@@ -486,7 +486,7 @@ void WebViewGuest::DidInitialize(const base::DictionaryValue& create_params) {
void WebViewGuest::ClearCodeCache(base::Time remove_since,
uint32_t removal_mask,
const base::Closure& callback) {
base::OnceClosure callback) {
content::StoragePartition* partition =
content::BrowserContext::GetStoragePartition(
web_contents()->GetBrowserContext(),
......@@ -494,7 +494,7 @@ void WebViewGuest::ClearCodeCache(base::Time remove_since,
DCHECK(partition);
base::OnceClosure code_cache_removal_done_callback = base::BindOnce(
&WebViewGuest::ClearDataInternal, weak_ptr_factory_.GetWeakPtr(),
remove_since, removal_mask, callback);
remove_since, removal_mask, std::move(callback));
partition->ClearCodeCaches(remove_since, base::Time::Now(),
base::RepeatingCallback<bool(const GURL&)>(),
std::move(code_cache_removal_done_callback));
......@@ -502,11 +502,11 @@ void WebViewGuest::ClearCodeCache(base::Time remove_since,
void WebViewGuest::ClearDataInternal(base::Time remove_since,
uint32_t removal_mask,
const base::Closure& callback) {
base::OnceClosure callback) {
uint32_t storage_partition_removal_mask =
GetStoragePartitionRemovalMask(removal_mask);
if (!storage_partition_removal_mask) {
callback.Run();
std::move(callback).Run();
return;
}
......@@ -543,7 +543,7 @@ void WebViewGuest::ClearDataInternal(base::Time remove_since,
content::StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL,
content::StoragePartition::OriginMatcherFunction(),
std::move(cookie_delete_filter), perform_cleanup, remove_since,
base::Time::Max(), callback);
base::Time::Max(), std::move(callback));
}
void WebViewGuest::GuestViewDidStopLoading() {
......@@ -803,7 +803,7 @@ void WebViewGuest::Terminate() {
bool WebViewGuest::ClearData(base::Time remove_since,
uint32_t removal_mask,
const base::Closure& callback) {
base::OnceClosure callback) {
base::RecordAction(UserMetricsAction("WebView.Guest.ClearData"));
content::StoragePartition* partition =
content::BrowserContext::GetStoragePartition(
......@@ -825,7 +825,7 @@ bool WebViewGuest::ClearData(base::Time remove_since,
base::OnceClosure cache_removal_done_callback = base::BindOnce(
&WebViewGuest::ClearCodeCache, weak_ptr_factory_.GetWeakPtr(),
remove_since, removal_mask, callback);
remove_since, removal_mask, std::move(callback));
// We cannot use |BrowsingDataRemover| here since it doesn't support
// non-default StoragePartition.
......@@ -835,7 +835,7 @@ bool WebViewGuest::ClearData(base::Time remove_since,
return true;
}
ClearDataInternal(remove_since, removal_mask, callback);
ClearDataInternal(remove_since, removal_mask, std::move(callback));
return true;
}
......
......@@ -146,7 +146,7 @@ class WebViewGuest : public guest_view::GuestView<WebViewGuest> {
// |removal_mask| corresponds to bitmask in StoragePartition::RemoveDataMask.
bool ClearData(const base::Time remove_since,
uint32_t removal_mask,
const base::Closure& callback);
base::OnceClosure callback);
ScriptExecutor* script_executor() { return script_executor_.get(); }
......@@ -165,10 +165,10 @@ class WebViewGuest : public guest_view::GuestView<WebViewGuest> {
void ClearCodeCache(base::Time remove_since,
uint32_t removal_mask,
const base::Closure& callback);
base::OnceClosure callback);
void ClearDataInternal(const base::Time remove_since,
uint32_t removal_mask,
const base::Closure& callback);
base::OnceClosure callback);
void OnWebViewNewWindowResponse(int new_window_instance_id,
bool allow,
......
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