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

Unified Diff: components/content_settings/core/browser/content_settings_binary_value_map.cc

Issue 2318223002: Remove EmptyRuleIterators with nullptrs. (Closed)
Patch Set: Fix failing unit test Created 4 years, 3 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
Index: components/content_settings/core/browser/content_settings_binary_value_map.cc
diff --git a/components/content_settings/core/browser/content_settings_binary_value_map.cc b/components/content_settings/core/browser/content_settings_binary_value_map.cc
index cd030bd65dd659e4d62b67b48cd4aa07104611e7..ddfb7326c125a2964700eac88e287fdc7efb642a 100644
--- a/components/content_settings/core/browser/content_settings_binary_value_map.cc
+++ b/components/content_settings/core/browser/content_settings_binary_value_map.cc
@@ -16,14 +16,13 @@ namespace {
class RuleIteratorBinary : public RuleIterator {
public:
- explicit RuleIteratorBinary(bool is_enabled,
- std::unique_ptr<base::AutoLock> auto_lock)
+ RuleIteratorBinary(bool is_enabled, std::unique_ptr<base::AutoLock> auto_lock)
: is_done_(is_enabled), auto_lock_(std::move(auto_lock)) {}
bool HasNext() const override { return !is_done_; }
Rule Next() override {
- DCHECK(!is_done_);
+ DCHECK(HasNext());
is_done_ = true;
return Rule(ContentSettingsPattern::Wildcard(),
ContentSettingsPattern::Wildcard(),
@@ -45,11 +44,10 @@ std::unique_ptr<RuleIterator> BinaryValueMap::GetRuleIterator(
ContentSettingsType content_type,
const ResourceIdentifier& resource_identifier,
std::unique_ptr<base::AutoLock> auto_lock) const {
- if (resource_identifier.empty()) {
- return std::unique_ptr<RuleIterator>(new RuleIteratorBinary(
- IsContentSettingEnabled(content_type), std::move(auto_lock)));
- }
- return std::unique_ptr<RuleIterator>(new EmptyRuleIterator());
+ if (!resource_identifier.empty())
+ return nullptr;
+ return std::unique_ptr<RuleIterator>(new RuleIteratorBinary(
+ IsContentSettingEnabled(content_type), std::move(auto_lock)));
}
void BinaryValueMap::SetContentSettingDisabled(ContentSettingsType content_type,
@@ -60,9 +58,7 @@ void BinaryValueMap::SetContentSettingDisabled(ContentSettingsType content_type,
bool BinaryValueMap::IsContentSettingEnabled(
ContentSettingsType content_type) const {
auto it = is_enabled_.find(content_type);
- if (it == is_enabled_.end())
- return true;
- return it->second;
+ return it == is_enabled_.end() || it->second;
}
} // namespace content_settings

Powered by Google App Engine
This is Rietveld 408576698