Commit d926e778 authored by danakj's avatar danakj Committed by Commit Bot

Convert Callbacks to OnceCallbacks for //content/test/

Use OnceCallback where possible, and BindRepeating where it is meant to
be called more than once.

TBR=sky@chromium.org, dpranke

Bug: 953861
Change-Id: Ie70184db86a0fa19af7b3f2de67867d46e23a523
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1934775
Commit-Queue: danakj <danakj@chromium.org>
Reviewed-by: default avatarBo <boliu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#719182}
parent 90994f60
......@@ -405,7 +405,6 @@ _NOT_CONVERTED_TO_MODERN_BIND_AND_CALLBACK = '|'.join((
'^content/renderer/pepper/',
'^content/renderer/service_worker/',
'^content/renderer/worker/',
'^content/test/',
'^content/utility/',
'^dbus/',
'^device/base/',
......
......@@ -68,7 +68,7 @@ void AwSSLHostStateDelegate::AllowCert(const std::string& host,
}
void AwSSLHostStateDelegate::Clear(
const base::Callback<bool(const std::string&)>& host_filter) {
base::RepeatingCallback<bool(const std::string&)> host_filter) {
if (host_filter.is_null()) {
cert_policy_for_host_.clear();
return;
......
......@@ -53,7 +53,7 @@ class AwSSLHostStateDelegate : public content::SSLHostStateDelegate {
int error) override;
void Clear(
const base::Callback<bool(const std::string&)>& host_filter) override;
base::RepeatingCallback<bool(const std::string&)> host_filter) override;
// Queries whether |cert| is allowed or denied for |host| and |error|.
content::SSLHostStateDelegate::CertJudgment QueryPolicy(
......
......@@ -224,7 +224,7 @@ void MigrateOldSettings(HostContentSettingsMap* map) {
}
bool HostFilterToPatternFilter(
const base::Callback<bool(const std::string&)>& host_filter,
base::OnceCallback<bool(const std::string&)> host_filter,
const ContentSettingsPattern& primary_pattern,
const ContentSettingsPattern& secondary_pattern) {
// We only ever set origin-scoped exceptions which are of the form
......@@ -232,7 +232,7 @@ bool HostFilterToPatternFilter(
// against its host.
GURL url = GURL(primary_pattern.ToString());
DCHECK(url.is_valid());
return host_filter.Run(url.host());
return std::move(host_filter).Run(url.host());
}
} // namespace
......@@ -289,14 +289,14 @@ void ChromeSSLHostStateDelegate::AllowCert(const std::string& host,
}
void ChromeSSLHostStateDelegate::Clear(
const base::Callback<bool(const std::string&)>& host_filter) {
base::RepeatingCallback<bool(const std::string&)> host_filter) {
// Convert host matching to content settings pattern matching. Content
// settings deletion is done synchronously on the UI thread, so we can use
// |host_filter| by reference.
HostContentSettingsMap::PatternSourcePredicate pattern_filter;
if (!host_filter.is_null()) {
pattern_filter =
base::Bind(&HostFilterToPatternFilter, std::cref(host_filter));
base::BindRepeating(&HostFilterToPatternFilter, host_filter);
}
HostContentSettingsMapFactory::GetForProfile(profile_)
......
......@@ -44,7 +44,7 @@ class ChromeSSLHostStateDelegate : public content::SSLHostStateDelegate {
const net::X509Certificate& cert,
int error) override;
void Clear(
const base::Callback<bool(const std::string&)>& host_filter) override;
base::RepeatingCallback<bool(const std::string&)> host_filter) override;
CertJudgment QueryPolicy(const std::string& host,
const net::X509Certificate& cert,
int error) override;
......
......@@ -752,7 +752,7 @@ void HostContentSettingsMap::ClearSettingsForOneTypeWithPredicate(
ContentSettingsType content_type,
base::Time begin_time,
base::Time end_time,
const PatternSourcePredicate& pattern_predicate) {
PatternSourcePredicate pattern_predicate) {
if (pattern_predicate.is_null() && begin_time.is_null() &&
(end_time.is_null() || end_time.is_max())) {
ClearSettingsForOneType(content_type);
......
......@@ -260,9 +260,9 @@ class HostContentSettingsMap : public content_settings::Observer,
const ContentSettingsPattern& secondary_pattern,
ContentSettingsType content_type) const;
using PatternSourcePredicate =
base::Callback<bool(const ContentSettingsPattern& primary_pattern,
const ContentSettingsPattern& secondary_pattern)>;
using PatternSourcePredicate = base::RepeatingCallback<bool(
const ContentSettingsPattern& primary_pattern,
const ContentSettingsPattern& secondary_pattern)>;
// If |pattern_predicate| is null, this method is equivalent to the above.
// Otherwise, it only deletes exceptions matched by |pattern_predicate| that
......@@ -271,7 +271,7 @@ class HostContentSettingsMap : public content_settings::Observer,
ContentSettingsType content_type,
base::Time begin_time,
base::Time end_time,
const PatternSourcePredicate& pattern_predicate);
PatternSourcePredicate pattern_predicate);
// RefcountedKeyedService implementation.
void ShutdownOnUIThread() override;
......
......@@ -49,7 +49,7 @@ class SSLHostStateDelegate {
// Clear allow preferences matched by |host_filter|. If the filter is null,
// clear all preferences.
virtual void Clear(
const base::Callback<bool(const std::string&)>& host_filter) = 0;
base::RepeatingCallback<bool(const std::string&)> host_filter) = 0;
// Queries whether |cert| is allowed for |host| and |error|. Returns true in
virtual CertJudgment QueryPolicy(const std::string& host,
......
......@@ -18,7 +18,7 @@ void MockSSLHostStateDelegate::AllowCert(const std::string& host,
}
void MockSSLHostStateDelegate::Clear(
const base::Callback<bool(const std::string&)>& host_filter) {
base::RepeatingCallback<bool(const std::string&)> host_filter) {
if (host_filter.is_null()) {
exceptions_.clear();
} else {
......
......@@ -19,7 +19,7 @@ class MockSSLHostStateDelegate : public SSLHostStateDelegate {
int error) override;
void Clear(
const base::Callback<bool(const std::string&)>& host_filter) override;
base::RepeatingCallback<bool(const std::string&)> host_filter) override;
CertJudgment QueryPolicy(const std::string& host,
const net::X509Certificate& cert,
......
......@@ -60,7 +60,7 @@ void SSLHostStateDelegateImpl::AllowCert(const std::string& host,
}
void SSLHostStateDelegateImpl::Clear(
const base::Callback<bool(const std::string&)>& host_filter) {
base::RepeatingCallback<bool(const std::string&)> host_filter) {
if (host_filter.is_null()) {
cert_policy_for_host_.clear();
return;
......
......@@ -56,7 +56,7 @@ class SSLHostStateDelegateImpl : public content::SSLHostStateDelegate {
int error) override;
void Clear(
const base::Callback<bool(const std::string&)>& host_filter) override;
base::RepeatingCallback<bool(const std::string&)> host_filter) override;
// content::SSLHostStateDelegate:
content::SSLHostStateDelegate::CertJudgment QueryPolicy(
......
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