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

Unified Diff: Source/web/ContextFeaturesClientImpl.cpp

Issue 171333003: Pass implementation object to supplemental classes by reference (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 6 years, 10 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: Source/web/ContextFeaturesClientImpl.cpp
diff --git a/Source/web/ContextFeaturesClientImpl.cpp b/Source/web/ContextFeaturesClientImpl.cpp
index 6ccbb4804e25948f0a1fca73ed66678a1720e452..6b2729bc17c20aea6aba8af4daba1347aa93d8ab 100644
--- a/Source/web/ContextFeaturesClientImpl.cpp
+++ b/Source/web/ContextFeaturesClientImpl.cpp
@@ -79,7 +79,7 @@ public:
};
static const char* supplementName();
- static ContextFeaturesCache* from(Document*);
+ static ContextFeaturesCache& from(Document&);
Entry& entryFor(ContextFeatures::FeatureType type)
{
@@ -100,7 +100,7 @@ const char* ContextFeaturesCache::supplementName()
return "ContextFeaturesCache";
}
-ContextFeaturesCache* ContextFeaturesCache::from(Document* document)
+ContextFeaturesCache& ContextFeaturesCache::from(Document& document)
{
ContextFeaturesCache* cache = static_cast<ContextFeaturesCache*>(DocumentSupplement::from(document, supplementName()));
if (!cache) {
@@ -108,7 +108,7 @@ ContextFeaturesCache* ContextFeaturesCache::from(Document* document)
DocumentSupplement::provideTo(document, supplementName(), adoptPtr(cache));
}
- return cache;
+ return *cache;
}
void ContextFeaturesCache::validateAgainst(Document* document)
@@ -123,7 +123,8 @@ void ContextFeaturesCache::validateAgainst(Document* document)
bool ContextFeaturesClientImpl::isEnabled(Document* document, ContextFeatures::FeatureType type, bool defaultValue)
{
- ContextFeaturesCache::Entry& cache = ContextFeaturesCache::from(document)->entryFor(type);
+ ASSERT(document);
+ ContextFeaturesCache::Entry& cache = ContextFeaturesCache::from(*document).entryFor(type);
if (cache.needsRefresh(defaultValue))
cache.set(askIfIsEnabled(document, type, defaultValue), defaultValue);
return cache.isEnabled();
@@ -131,7 +132,8 @@ bool ContextFeaturesClientImpl::isEnabled(Document* document, ContextFeatures::F
void ContextFeaturesClientImpl::urlDidChange(Document* document)
{
- ContextFeaturesCache::from(document)->validateAgainst(document);
+ ASSERT(document);
+ ContextFeaturesCache::from(*document).validateAgainst(document);
}
bool ContextFeaturesClientImpl::askIfIsEnabled(Document* document, ContextFeatures::FeatureType type, bool defaultValue)

Powered by Google App Engine
This is Rietveld 408576698