Index: third_party/WebKit/Source/core/html/parser/CSSPreloadScanner.cpp |
diff --git a/third_party/WebKit/Source/core/html/parser/CSSPreloadScanner.cpp b/third_party/WebKit/Source/core/html/parser/CSSPreloadScanner.cpp |
index 19e8b68357cf27bd712ecd7bb63d734d2f68796a..6be45f8e9fd1e327855f9edae52571d88d84fa12 100644 |
--- a/third_party/WebKit/Source/core/html/parser/CSSPreloadScanner.cpp |
+++ b/third_party/WebKit/Source/core/html/parser/CSSPreloadScanner.cpp |
@@ -242,10 +242,22 @@ CSSPreloaderResourceClient::CSSPreloaderResourceClient(Resource* resource, HTMLR |
{ |
} |
+void CSSPreloaderResourceClient::stopObserving() |
+{ |
+ if (m_resource) { |
+ m_resource->removeClient(this); |
+ m_resource.clear(); |
+ } |
+} |
+ |
+CSSPreloaderResourceClient::~CSSPreloaderResourceClient() |
+{ |
+ stopObserving(); |
Nate Chapin
2016/05/03 18:25:30
Alternately, you can have CSSPreloaderResourceClie
Charlie Harrison
2016/05/03 20:32:11
Very good point. Thanks for the suggestion.
|
+} |
+ |
void CSSPreloaderResourceClient::notifyFinished(Resource* resource) |
{ |
- resource->removeClient(this); |
- m_resource.clear(); |
+ stopObserving(); |
} |
// Only attach for one appendData call, as that's where most imports will likely |
@@ -267,8 +279,7 @@ void CSSPreloaderResourceClient::didAppendFirstData(const CSSStyleSheetResource* |
DEFINE_STATIC_LOCAL(CustomCountHistogram, cssImportHistogram, ("PreloadScanner.ExternalCSS.PreloadCount", 1, 100, 50)); |
cssImportHistogram.count(m_preloader->countPreloads() - currentPreloadCount); |
} |
- m_resource->removeClient(this); |
- m_resource.clear(); |
+ stopObserving(); |
} |
} // namespace blink |