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

Unified Diff: Source/core/fetch/ResourceOwner.h

Issue 288673002: Make ScriptLoader into a ResourceOwner (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 7 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
« no previous file with comments | « Source/core/dom/ScriptLoader.cpp ('k') | Source/core/html/parser/HTMLScriptRunner.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/fetch/ResourceOwner.h
diff --git a/Source/core/fetch/ResourceOwner.h b/Source/core/fetch/ResourceOwner.h
index ebadbe916cc7867c14ea6f13a086f7aceb0c1478..03324208b35aa3bf00c36c1ebeba3f1893f3926a 100644
--- a/Source/core/fetch/ResourceOwner.h
+++ b/Source/core/fetch/ResourceOwner.h
@@ -46,20 +46,22 @@ public:
protected:
ResourceOwner();
- ResourceOwner(const ResourceOwner& other) { setResource(other.resource()); }
+ ResourceOwner(const ResourceOwner& other) { setResource(other.resource(), other.m_subscribing); }
explicit ResourceOwner(const ResourcePtr<ResourceType>&);
- void setResource(const ResourcePtr<ResourceType>&);
+ void setResource(const ResourcePtr<ResourceType>&, bool subscribing = true);
void clearResource();
ResourceOwner& operator=(const ResourceOwner& other);
private:
ResourcePtr<ResourceType> m_resource;
+ bool m_subscribing;
};
template<class R, class C>
inline ResourceOwner<R, C>::ResourceOwner()
+ : m_subscribing(false)
{
}
@@ -78,7 +80,7 @@ inline ResourceOwner<R, C>::ResourceOwner(const ResourcePtr<R>& resource)
}
template<class R, class C>
-inline void ResourceOwner<R, C>::setResource(const ResourcePtr<R>& newResource)
+inline void ResourceOwner<R, C>::setResource(const ResourcePtr<R>& newResource, bool subscribe)
{
if (newResource == m_resource)
return;
@@ -87,12 +89,15 @@ inline void ResourceOwner<R, C>::setResource(const ResourcePtr<R>& newResource)
// we need to prevent double removal.
if (ResourcePtr<ResourceType> oldResource = m_resource) {
m_resource.clear();
- oldResource->removeClient(this);
+ if (m_subscribing)
+ oldResource->removeClient(this);
}
if (newResource) {
+ m_subscribing = subscribe;
m_resource = newResource;
- m_resource->addClient(this);
+ if (m_subscribing)
+ m_resource->addClient(this);
}
}
@@ -107,7 +112,7 @@ inline ResourceOwner<R, C>& ResourceOwner<R, C>::operator=(const ResourceOwner<R
{
if (this == &other)
return *this;
- setResource(other.resource());
+ setResource(other.resource(), other.m_subscribing);
return *this;
}
« no previous file with comments | « Source/core/dom/ScriptLoader.cpp ('k') | Source/core/html/parser/HTMLScriptRunner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698