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