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

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

Issue 2812113004: Write last_modified date to Content Settings in the PrefProvider (Closed)
Patch Set: rebase Created 3 years, 8 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_origin_identifier_value_map.cc
diff --git a/components/content_settings/core/browser/content_settings_origin_identifier_value_map.cc b/components/content_settings/core/browser/content_settings_origin_identifier_value_map.cc
index 3f6133b67a8cb760ad7fb12b8d5c3c8ec5633a74..8bb2f98613ce3e7134a1ce539cd359290b5e4c8c 100644
--- a/components/content_settings/core/browser/content_settings_origin_identifier_value_map.cc
+++ b/components/content_settings/core/browser/content_settings_origin_identifier_value_map.cc
@@ -38,10 +38,10 @@ class RuleIteratorImpl : public RuleIterator {
Rule Next() override {
DCHECK(HasNext());
- DCHECK(current_rule_->second.get());
+ DCHECK(current_rule_->second.value.get());
Rule to_return(current_rule_->first.primary_pattern,
current_rule_->first.secondary_pattern,
- current_rule_->second.get()->DeepCopy());
+ current_rule_->second.value.get()->DeepCopy());
++current_rule_;
return to_return;
}
@@ -83,6 +83,10 @@ bool OriginIdentifierValueMap::PatternPair::operator<(
std::tie(other.primary_pattern, other.secondary_pattern);
}
+OriginIdentifierValueMap::ValueEntry::ValueEntry() : last_modified(), value(){};
+
+OriginIdentifierValueMap::ValueEntry::~ValueEntry(){};
+
std::unique_ptr<RuleIterator> OriginIdentifierValueMap::GetRuleIterator(
ContentSettingsType content_type,
const ResourceIdentifier& resource_identifier,
@@ -129,17 +133,37 @@ base::Value* OriginIdentifierValueMap::GetValue(
for (const auto& entry : it->second) {
if (entry.first.primary_pattern.Matches(primary_url) &&
entry.first.secondary_pattern.Matches(secondary_url)) {
- return entry.second.get();
+ return entry.second.value.get();
}
}
return nullptr;
}
+base::Time OriginIdentifierValueMap::GetLastModified(
+ const ContentSettingsPattern& primary_pattern,
+ const ContentSettingsPattern& secondary_pattern,
+ ContentSettingsType content_type,
+ const ResourceIdentifier& resource_identifier) const {
+ DCHECK(primary_pattern.IsValid());
+ DCHECK(secondary_pattern.IsValid());
+
+ EntryMapKey key(content_type, resource_identifier);
+ PatternPair patterns(primary_pattern, secondary_pattern);
+ EntryMap::const_iterator it = entries_.find(key);
+ if (it == entries_.end())
+ return base::Time();
+ Rules::const_iterator r = it->second.find(patterns);
+ if (r == it->second.end())
+ return base::Time();
+ return r->second.last_modified;
+}
+
void OriginIdentifierValueMap::SetValue(
const ContentSettingsPattern& primary_pattern,
const ContentSettingsPattern& secondary_pattern,
ContentSettingsType content_type,
const ResourceIdentifier& resource_identifier,
+ base::Time last_modified,
base::Value* value) {
DCHECK(primary_pattern.IsValid());
DCHECK(secondary_pattern.IsValid());
@@ -150,7 +174,9 @@ void OriginIdentifierValueMap::SetValue(
EntryMapKey key(content_type, resource_identifier);
PatternPair patterns(primary_pattern, secondary_pattern);
// This will create the entry and the linked_ptr if needed.
- entries_[key][patterns].reset(value);
+ ValueEntry* entry = &entries_[key][patterns];
+ entry->value.reset(value);
+ entry->last_modified = last_modified;
}
void OriginIdentifierValueMap::DeleteValue(

Powered by Google App Engine
This is Rietveld 408576698