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

Unified Diff: third_party/WebKit/Source/core/fetch/ImageResource.cpp

Issue 2469873002: [ImageResource 4] Split ImageResource into Resource and Image parts (Closed)
Patch Set: fix Created 4 years 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: third_party/WebKit/Source/core/fetch/ImageResource.cpp
diff --git a/third_party/WebKit/Source/core/fetch/ImageResource.cpp b/third_party/WebKit/Source/core/fetch/ImageResource.cpp
index 0a454391815e5909ea81d4e931931a92341c7884..7e04c4e4b68bf074b032cf960663411322bf8ba8 100644
--- a/third_party/WebKit/Source/core/fetch/ImageResource.cpp
+++ b/third_party/WebKit/Source/core/fetch/ImageResource.cpp
@@ -23,22 +23,19 @@
#include "core/fetch/ImageResource.h"
+#include "core/fetch/ImageResourceContent.h"
+#include "core/fetch/ImageResourceInfo.h"
#include "core/fetch/ImageResourceObserver.h"
yhirano 2016/12/05 09:02:03 Is this needed?
hiroshige 2016/12/06 09:32:50 Done.
#include "core/fetch/MemoryCache.h"
#include "core/fetch/ResourceClient.h"
#include "core/fetch/ResourceFetcher.h"
#include "core/fetch/ResourceLoader.h"
#include "core/fetch/ResourceLoadingLog.h"
-#include "core/svg/graphics/SVGImage.h"
#include "platform/Histogram.h"
#include "platform/RuntimeEnabledFeatures.h"
#include "platform/SharedBuffer.h"
-#include "platform/geometry/IntSize.h"
-#include "platform/graphics/BitmapImage.h"
-#include "platform/graphics/PlaceholderImage.h"
#include "platform/tracing/TraceEvent.h"
#include "public/platform/Platform.h"
-#include "public/platform/WebCachePolicy.h"
#include "wtf/CurrentTime.h"
#include "wtf/HashCountedSet.h"
yhirano 2016/12/05 09:02:03 Not needed?
hiroshige 2016/12/06 09:32:50 Done.
#include "wtf/StdLibExtras.h"
@@ -54,6 +51,82 @@ namespace {
constexpr double kFlushDelaySeconds = 1.;
} // namespace
+class ImageResource::ImageResourceInfoImpl final
+ : public GarbageCollectedFinalized<ImageResourceInfoImpl>,
+ public ImageResourceInfo {
+ USING_GARBAGE_COLLECTED_MIXIN(ImageResourceInfoImpl);
+
+ public:
+ ImageResourceInfoImpl(ImageResource* resource) : m_resource(resource) {
+ DCHECK(m_resource);
+ }
+ DEFINE_INLINE_VIRTUAL_TRACE() {
+ visitor->trace(m_resource);
+ ImageResourceInfo::trace(visitor);
+ }
+
+ private:
+ const KURL& url() const override { return m_resource->url(); }
+ bool isSchedulingReload() const override {
+ return m_resource->m_isSchedulingReload;
+ }
+ bool hasDevicePixelRatioHeaderValue() const override {
+ return m_resource->m_hasDevicePixelRatioHeaderValue;
+ }
+ float devicePixelRatioHeaderValue() const override {
+ return m_resource->m_devicePixelRatioHeaderValue;
+ }
+ const ResourceResponse& response() const override {
+ return m_resource->response();
+ }
+ Resource::Status getStatus() const override {
+ return m_resource->getStatus();
+ }
+ bool isPlaceholder() const override { return m_resource->isPlaceholder(); }
+ bool isCacheValidator() const override {
+ return m_resource->isCacheValidator();
+ }
+ bool schedulingReloadOrShouldReloadBrokenPlaceholder() const override {
+ return m_resource->m_isSchedulingReload ||
+ m_resource->shouldReloadBrokenPlaceholder();
+ }
+ bool isAccessAllowed(
+ SecurityOrigin* securityOrigin,
+ bool doesCurrentFrameHasSingleSecurityOrigin) const override {
+ return m_resource->isAccessAllowed(securityOrigin,
+ doesCurrentFrameHasSingleSecurityOrigin);
+ }
+ bool hasCacheControlNoStoreHeader() const override {
+ return m_resource->hasCacheControlNoStoreHeader();
+ }
+ const ResourceError& resourceError() const override {
+ return m_resource->resourceError();
+ }
+
+ void decodeError(bool allDataReceived) override {
+ m_resource->decodeError(allDataReceived);
+ }
+ void setDecodedSize(size_t size) override {
+ m_resource->setDecodedSize(size);
+ }
+ void willAddClientOrObserver() override {
+ m_resource->willAddClientOrObserver(Resource::MarkAsReferenced);
+ }
+ void didRemoveClientOrObserver() override {
+ m_resource->didRemoveClientOrObserver();
+ }
+ void emulateLoadStartedForInspector(
+ ResourceFetcher* fetcher,
+ const KURL& url,
+ const AtomicString& initiatorName) override {
+ fetcher->emulateLoadStartedForInspector(m_resource.get(), url,
+ WebURLRequest::RequestContextImage,
+ initiatorName);
+ }
+
+ Member<ImageResource> m_resource;
yhirano 2016/12/05 09:02:03 [optional] const Member<ImageResource> m_resource;
hiroshige 2016/12/06 09:32:50 Done.
+};
+
class ImageResource::ImageResourceFactory : public ResourceFactory {
STACK_ALLOCATED();
@@ -64,7 +137,7 @@ class ImageResource::ImageResourceFactory : public ResourceFactory {
Resource* create(const ResourceRequest& request,
const ResourceLoaderOptions& options,
const String&) const override {
- return new ImageResource(request, options,
+ return new ImageResource(request, options, ImageResourceContent::create(),
m_fetchRequest->placeholderImageRequestType() ==
FetchRequest::AllowPlaceholder);
}
@@ -106,43 +179,35 @@ ImageResource* ImageResource::fetch(FetchRequest& request,
return resource;
}
+ImageResource* ImageResource::create(const ResourceRequest& request) {
+ return new ImageResource(request, ResourceLoaderOptions(),
+ ImageResourceContent::create(), false);
+}
+
ImageResource::ImageResource(const ResourceRequest& resourceRequest,
const ResourceLoaderOptions& options,
+ ImageResourceContent* content,
bool isPlaceholder)
: Resource(resourceRequest, Image, options),
+ m_content(content),
m_devicePixelRatioHeaderValue(1.0),
- m_image(nullptr),
m_hasDevicePixelRatioHeaderValue(false),
m_isSchedulingReload(false),
m_isPlaceholder(isPlaceholder),
- m_flushTimer(this, &ImageResource::flushImageIfNeeded),
- m_isRefetchableDataFromDiskCache(true) {
+ m_flushTimer(this, &ImageResource::flushImageIfNeeded) {
+ DCHECK(getContent());
RESOURCE_LOADING_DVLOG(1) << "new ImageResource(ResourceRequest) " << this;
-}
-
-ImageResource::ImageResource(blink::Image* image,
- const ResourceLoaderOptions& options)
- : Resource(ResourceRequest(""), Image, options),
- m_devicePixelRatioHeaderValue(1.0),
- m_image(image),
- m_hasDevicePixelRatioHeaderValue(false),
- m_isSchedulingReload(false),
- m_isPlaceholder(false),
- m_flushTimer(this, &ImageResource::flushImageIfNeeded),
- m_isRefetchableDataFromDiskCache(true) {
- RESOURCE_LOADING_DVLOG(1) << "new ImageResource(Image) " << this;
- setStatus(Cached);
+ getContent()->setImageResourceInfo(new ImageResourceInfoImpl(this));
}
ImageResource::~ImageResource() {
RESOURCE_LOADING_DVLOG(1) << "~ImageResource " << this;
- clearImage();
}
DEFINE_TRACE(ImageResource) {
visitor->trace(m_multipartParser);
+ visitor->trace(m_content);
Resource::trace(visitor);
- ImageObserver::trace(visitor);
MultipartImageResourceParser::Client::trace(visitor);
}
@@ -155,15 +220,13 @@ void ImageResource::checkNotify() {
Resource::checkNotify();
}
-void ImageResource::markObserverFinished(ImageResourceObserver* observer) {
- if (m_observers.contains(observer)) {
- m_finishedObservers.add(observer);
- m_observers.remove(observer);
- }
+bool ImageResource::hasClientsOrObservers() const {
+ return Resource::hasClientsOrObservers() || getContent()->hasObservers();
}
void ImageResource::didAddClient(ResourceClient* client) {
- DCHECK((m_multipartParser && isLoading()) || !data() || m_image);
+ DCHECK((m_multipartParser && isLoading()) || !data() ||
+ getContent()->hasImage());
// Don't notify observers and clients of completion if this ImageResource is
// about to be reloaded.
@@ -173,106 +236,32 @@ void ImageResource::didAddClient(ResourceClient* client) {
Resource::didAddClient(client);
}
-void ImageResource::addObserver(ImageResourceObserver* observer) {
- willAddClientOrObserver(MarkAsReferenced);
-
- m_observers.add(observer);
-
- if (isCacheValidator())
- return;
-
- // When the response is not multipart, if |data()| exists, |m_image| must be
- // created. This is assured that |updateImage()| is called when |appendData()|
- // is called.
- //
- // On the other hand, when the response is multipart, |updateImage()| is not
- // called in |appendData()|, which means |m_image| might not be created even
- // when |data()| exists. This is intentional since creating a |m_image| on
- // receiving data might destroy an existing image in a previous part.
- DCHECK((m_multipartParser && isLoading()) || !data() || m_image);
-
- if (m_image && !m_image->isNull()) {
- observer->imageChanged(this);
- }
-
- if (isLoaded() && m_observers.contains(observer) && !m_isSchedulingReload &&
- !shouldReloadBrokenPlaceholder()) {
- markObserverFinished(observer);
- observer->imageNotifyFinished(this);
- }
-}
-
-void ImageResource::removeObserver(ImageResourceObserver* observer) {
- DCHECK(observer);
-
- if (m_observers.contains(observer))
- m_observers.remove(observer);
- else if (m_finishedObservers.contains(observer))
- m_finishedObservers.remove(observer);
- else
- NOTREACHED();
-
- didRemoveClientOrObserver();
-}
-
-static void priorityFromObserver(const ImageResourceObserver* observer,
- ResourcePriority& priority) {
- ResourcePriority nextPriority = observer->computeResourcePriority();
- if (nextPriority.visibility == ResourcePriority::NotVisible)
- return;
- priority.visibility = ResourcePriority::Visible;
- priority.intraPriorityValue += nextPriority.intraPriorityValue;
-}
-
-ResourcePriority ImageResource::priorityFromObservers() {
- ResourcePriority priority;
-
- for (auto* observer : m_finishedObservers.asVector()) {
- if (m_finishedObservers.contains(observer))
- priorityFromObserver(observer, priority);
- }
- for (auto* observer : m_observers.asVector()) {
- if (m_observers.contains(observer))
- priorityFromObserver(observer, priority);
- }
-
- return priority;
-}
-
void ImageResource::destroyDecodedDataForFailedRevalidation() {
- clearImage();
+ getContent()->updateImage(nullptr, ImageResourceContent::ClearExistingImage,
+ false);
setDecodedSize(0);
}
void ImageResource::destroyDecodedDataIfPossible() {
- if (!m_image)
- return;
- CHECK(!errorOccurred());
- m_image->destroyDecodedData();
- if (!isPreloaded() && m_isRefetchableDataFromDiskCache) {
+ getContent()->destroyDecodedData();
+ if (getContent()->hasImage() && !isPreloaded() &&
+ getContent()->isRefetchableDataFromDiskCache()) {
UMA_HISTOGRAM_MEMORY_KB("Memory.Renderer.EstimatedDroppableEncodedSize",
encodedSize() / 1024);
}
}
-void ImageResource::doResetAnimation() {
- if (m_image)
- m_image->resetAnimation();
-}
-
void ImageResource::allClientsAndObserversRemoved() {
- if (m_image) {
- CHECK(!errorOccurred());
- // If possible, delay the resetting until back at the event loop. Doing so
- // after a conservative GC prevents resetAnimation() from upsetting ongoing
- // animation updates (crbug.com/613709)
- if (!ThreadHeap::willObjectBeLazilySwept(this)) {
- Platform::current()->currentThread()->getWebTaskRunner()->postTask(
- BLINK_FROM_HERE, WTF::bind(&ImageResource::doResetAnimation,
- wrapWeakPersistent(this)));
- } else {
- m_image->resetAnimation();
- }
+ CHECK(!getContent()->hasImage() || !errorOccurred());
+ // If possible, delay the resetting until back at the event loop. Doing so
+ // after a conservative GC prevents resetAnimation() from upsetting ongoing
+ // animation updates (crbug.com/613709)
+ if (!ThreadHeap::willObjectBeLazilySwept(this)) {
+ Platform::current()->currentThread()->getWebTaskRunner()->postTask(
+ BLINK_FROM_HERE, WTF::bind(&ImageResourceContent::doResetAnimation,
+ wrapWeakPersistent(getContent())));
+ } else {
+ getContent()->doResetAnimation();
}
if (m_multipartParser)
m_multipartParser->cancel();
@@ -282,8 +271,8 @@ void ImageResource::allClientsAndObserversRemoved() {
PassRefPtr<const SharedBuffer> ImageResource::resourceBuffer() const {
if (data())
return data();
- if (m_image)
- return m_image->data();
+ if (getContent()->hasImage())
+ return getContent()->getImage()->data();
return nullptr;
}
@@ -298,9 +287,11 @@ void ImageResource::appendData(const char* data, size_t length) {
// we need to know the image size as soon as possible. Likewise for
// animated images, update right away since we shouldn't throttle animated
// images.
- if (m_sizeAvailable == Image::SizeUnavailable ||
- (m_image && m_image->maybeAnimated())) {
- updateImage(false);
+ if (!getContent()->isSizeAvailable() ||
+ (getContent()->hasImage() &&
+ getContent()->getImage()->maybeAnimated())) {
+ getContent()->updateImage(this->data(),
+ ImageResourceContent::KeepExistingImage, false);
return;
}
@@ -328,193 +319,34 @@ void ImageResource::flushImageIfNeeded(TimerBase*) {
// to call |updateImage()|.
if (isLoading()) {
m_lastFlushTime = WTF::monotonicallyIncreasingTime();
- updateImage(false);
- }
-}
-
-std::pair<blink::Image*, float> ImageResource::brokenImage(
- float deviceScaleFactor) {
- if (deviceScaleFactor >= 2) {
- DEFINE_STATIC_REF(blink::Image, brokenImageHiRes,
- (blink::Image::loadPlatformResource("missingImage@2x")));
- return std::make_pair(brokenImageHiRes, 2);
+ getContent()->updateImage(this->data(),
+ ImageResourceContent::KeepExistingImage, false);
}
-
- DEFINE_STATIC_REF(blink::Image, brokenImageLoRes,
- (blink::Image::loadPlatformResource("missingImage")));
- return std::make_pair(brokenImageLoRes, 1);
}
bool ImageResource::willPaintBrokenImage() const {
return errorOccurred();
}
-blink::Image* ImageResource::getImage() {
- if (errorOccurred()) {
- // Returning the 1x broken image is non-ideal, but we cannot reliably access
- // the appropriate deviceScaleFactor from here. It is critical that callers
- // use ImageResource::brokenImage() when they need the real,
- // deviceScaleFactor-appropriate broken image icon.
- return brokenImage(1).first;
- }
-
- if (m_image)
- return m_image.get();
-
- return blink::Image::nullImage();
-}
-
-bool ImageResource::usesImageContainerSize() const {
- if (m_image)
- return m_image->usesContainerSize();
-
- return false;
-}
-
-bool ImageResource::imageHasRelativeSize() const {
- if (m_image)
- return m_image->hasRelativeSize();
-
- return false;
-}
-
-LayoutSize ImageResource::imageSize(
- RespectImageOrientationEnum shouldRespectImageOrientation,
- float multiplier,
- SizeType sizeType) {
- if (!m_image)
- return LayoutSize();
-
- LayoutSize size;
-
- if (m_image->isBitmapImage() &&
- shouldRespectImageOrientation == RespectImageOrientation) {
- size =
- LayoutSize(toBitmapImage(m_image.get())->sizeRespectingOrientation());
- } else {
- size = LayoutSize(m_image->size());
- }
-
- if (sizeType == IntrinsicCorrectedToDPR && m_hasDevicePixelRatioHeaderValue &&
- m_devicePixelRatioHeaderValue > 0)
- multiplier = 1 / m_devicePixelRatioHeaderValue;
-
- if (multiplier == 1 || m_image->hasRelativeSize())
- return size;
-
- // Don't let images that have a width/height >= 1 shrink below 1 when zoomed.
- LayoutSize minimumSize(
- size.width() > LayoutUnit() ? LayoutUnit(1) : LayoutUnit(),
- LayoutUnit(size.height() > LayoutUnit() ? LayoutUnit(1) : LayoutUnit()));
- size.scale(multiplier);
- size.clampToMinimumSize(minimumSize);
- return size;
-}
-
-void ImageResource::notifyObservers(NotifyFinishOption notifyingFinishOption,
- const IntRect* changeRect) {
- for (auto* observer : m_finishedObservers.asVector()) {
- if (m_finishedObservers.contains(observer))
- observer->imageChanged(this, changeRect);
- }
- for (auto* observer : m_observers.asVector()) {
- if (m_observers.contains(observer)) {
- observer->imageChanged(this, changeRect);
- if (notifyingFinishOption == ShouldNotifyFinish &&
- m_observers.contains(observer) && !m_isSchedulingReload &&
- !shouldReloadBrokenPlaceholder()) {
- markObserverFinished(observer);
- observer->imageNotifyFinished(this);
- }
- }
- }
-}
+void ImageResource::decodeError(bool allDataReceived) {
+ size_t size = encodedSize();
-void ImageResource::clear() {
- clearImage();
clearData();
setEncodedSize(0);
-}
-
-inline void ImageResource::createImage() {
- // Create the image if it doesn't yet exist.
- if (m_image)
- return;
-
- if (response().mimeType() == "image/svg+xml") {
- m_image = SVGImage::create(this);
- } else {
- m_image = BitmapImage::create(this);
- }
-}
-
-inline void ImageResource::clearImage() {
- if (!m_image)
- return;
- int64_t length = m_image->data() ? m_image->data()->size() : 0;
- v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(-length);
-
- // If our Image has an observer, it's always us so we need to clear the back
- // pointer before dropping our reference.
- m_image->clearImageObserver();
- m_image.clear();
- m_sizeAvailable = Image::SizeUnavailable;
-}
-
-void ImageResource::updateImage(bool allDataReceived) {
- TRACE_EVENT0("blink", "ImageResource::updateImage");
-
- if (data())
- createImage();
-
- // Have the image update its data from its internal buffer. It will not do
- // anything now, but will delay decoding until queried for info (like size or
- // specific image frames).
- if (data()) {
- DCHECK(m_image);
- m_sizeAvailable = m_image->setData(data(), allDataReceived);
- }
-
- // Go ahead and tell our observers to try to draw if we have either received
- // all the data or the size is known. Each chunk from the network causes
- // observers to repaint, which will force that chunk to decode.
- if (m_sizeAvailable == Image::SizeUnavailable && !allDataReceived)
- return;
-
- if (m_isPlaceholder && allDataReceived && m_image && !m_image->isNull()) {
- if (m_sizeAvailable == Image::SizeAvailable) {
- // TODO(sclittle): Show the original image if the response consists of the
- // entire image, such as if the entire image response body is smaller than
- // the requested range.
- IntSize dimensions = m_image->size();
- clearImage();
- m_image = PlaceholderImage::create(this, dimensions);
- } else {
- // Clear the image so that it gets treated like a decoding error, since
- // the attempt to build a placeholder image failed.
- clearImage();
- }
- }
+ if (!errorOccurred())
+ setStatus(DecodeError);
- if (!m_image || m_image->isNull()) {
- size_t size = encodedSize();
- clear();
- if (!errorOccurred())
- setStatus(DecodeError);
- if (!allDataReceived && loader()) {
- loader()->didFinishLoading(monotonicallyIncreasingTime(), size, size);
- }
- memoryCache()->remove(this);
+ if (!allDataReceived && loader()) {
+ // TODO(hiroshige): Do not call didFinishLoading() directly.
+ loader()->didFinishLoading(monotonicallyIncreasingTime(), size, size);
}
- // It would be nice to only redraw the decoded band of the image, but with the
- // current design (decoding delayed until painting) that seems hard.
- notifyObservers(allDataReceived ? ShouldNotifyFinish : DoNotNotifyFinish);
+ memoryCache()->remove(this);
}
void ImageResource::updateImageAndClearBuffer() {
- clearImage();
- updateImage(true);
+ getContent()->updateImage(data(), ImageResourceContent::ClearExistingImage,
+ true);
clearData();
}
@@ -524,7 +356,8 @@ void ImageResource::finish(double loadFinishTime) {
if (data())
updateImageAndClearBuffer();
} else {
- updateImage(true);
+ getContent()->updateImage(data(), ImageResourceContent::KeepExistingImage,
+ true);
// As encoded image data can be created from m_image (see
// ImageResource::resourceBuffer(), we don't have to keep m_data. Let's
// clear this. As for the lifetimes of m_image and m_data, see this
@@ -538,9 +371,10 @@ void ImageResource::finish(double loadFinishTime) {
void ImageResource::error(const ResourceError& error) {
if (m_multipartParser)
m_multipartParser->cancel();
- clear();
+ clearData();
yhirano 2016/12/05 09:02:03 Resource::error calls clearData().
yhirano 2016/12/05 09:02:03 +setEncodedSize(0)?
hiroshige 2016/12/06 09:32:50 Done to keep the current behavior. But I'm not so
hiroshige 2016/12/06 09:32:50 Done.
Resource::error(error);
- notifyObservers(ShouldNotifyFinish);
+ getContent()->updateImage(nullptr, ImageResourceContent::ClearExistingImage,
+ true);
}
void ImageResource::responseReceived(
@@ -567,59 +401,6 @@ void ImageResource::responseReceived(
}
}
-void ImageResource::decodedSizeChangedTo(const blink::Image* image,
- size_t newSize) {
- if (!image || image != m_image)
- return;
-
- setDecodedSize(newSize);
-}
-
-bool ImageResource::shouldPauseAnimation(const blink::Image* image) {
- if (!image || image != m_image)
- return false;
-
- for (auto* observer : m_finishedObservers.asVector()) {
- if (m_finishedObservers.contains(observer) && observer->willRenderImage())
- return false;
- }
-
- for (auto* observer : m_observers.asVector()) {
- if (m_observers.contains(observer) && observer->willRenderImage())
- return false;
- }
-
- return true;
-}
-
-void ImageResource::animationAdvanced(const blink::Image* image) {
- if (!image || image != m_image)
- return;
- notifyObservers(DoNotNotifyFinish);
-}
-
-void ImageResource::updateImageAnimationPolicy() {
- if (!m_image)
- return;
-
- ImageAnimationPolicy newPolicy = ImageAnimationPolicyAllowed;
- for (auto* observer : m_finishedObservers.asVector()) {
- if (m_finishedObservers.contains(observer) &&
- observer->getImageAnimationPolicy(newPolicy))
- break;
- }
- for (auto* observer : m_observers.asVector()) {
- if (m_observers.contains(observer) &&
- observer->getImageAnimationPolicy(newPolicy))
- break;
- }
-
- if (m_image->animationPolicy() != newPolicy) {
- m_image->resetAnimation();
- m_image->setAnimationPolicy(newPolicy);
- }
-}
-
static bool isLoFiImage(const ImageResource& resource) {
if (resource.resourceRequest().loFiState() != WebURLRequest::LoFiOn)
return false;
@@ -657,8 +438,10 @@ void ImageResource::reloadIfLoFiOrPlaceholder(
// clear() and notifyObservers(), so there's no need to call these again
// here.
} else {
- clear();
- notifyObservers(DoNotNotifyFinish);
+ clearData();
+ setEncodedSize(0);
+ getContent()->updateImage(nullptr, ImageResourceContent::ClearExistingImage,
+ false);
}
setStatus(NotStarted);
@@ -669,13 +452,6 @@ void ImageResource::reloadIfLoFiOrPlaceholder(
fetcher->startLoad(this);
}
-void ImageResource::changedInRect(const blink::Image* image,
- const IntRect& rect) {
- if (!image || image != m_image)
- return;
- notifyObservers(DoNotNotifyFinish, &rect);
-}
-
void ImageResource::onePartInMultipartReceived(
const ResourceResponse& response) {
DCHECK(m_multipartParser);
@@ -707,16 +483,26 @@ void ImageResource::multipartDataReceived(const char* bytes, size_t size) {
Resource::appendData(bytes, size);
}
-bool ImageResource::isAccessAllowed(SecurityOrigin* securityOrigin) {
+bool ImageResource::isAccessAllowed(
+ SecurityOrigin* securityOrigin,
+ bool doesCurrentFrameHasSingleSecurityOrigin) const {
if (response().wasFetchedViaServiceWorker()) {
return response().serviceWorkerResponseType() !=
WebServiceWorkerResponseTypeOpaque;
}
- if (!getImage()->currentFrameHasSingleSecurityOrigin())
+ if (!doesCurrentFrameHasSingleSecurityOrigin)
return false;
if (passesAccessControlCheck(securityOrigin))
return true;
return !securityOrigin->taintsCanvas(response().url());
}
+ImageResourceContent* ImageResource::getContent() const {
+ return m_content;
+}
+
+ResourcePriority ImageResource::priorityFromObservers() {
+ return getContent()->priorityFromObservers();
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698