Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) | 2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) |
| 3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) | 3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) |
| 4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) | 4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) |
| 5 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) | 5 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) |
| 6 Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. | 6 Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. |
| 7 | 7 |
| 8 This library is free software; you can redistribute it and/or | 8 This library is free software; you can redistribute it and/or |
| 9 modify it under the terms of the GNU Library General Public | 9 modify it under the terms of the GNU Library General Public |
| 10 License as published by the Free Software Foundation; either | 10 License as published by the Free Software Foundation; either |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 38 #include "public/platform/WebCachePolicy.h" | 38 #include "public/platform/WebCachePolicy.h" |
| 39 #include "wtf/CurrentTime.h" | 39 #include "wtf/CurrentTime.h" |
| 40 #include "wtf/HashCountedSet.h" | 40 #include "wtf/HashCountedSet.h" |
| 41 #include "wtf/StdLibExtras.h" | 41 #include "wtf/StdLibExtras.h" |
| 42 #include "wtf/Vector.h" | 42 #include "wtf/Vector.h" |
| 43 #include <memory> | 43 #include <memory> |
| 44 #include <v8.h> | 44 #include <v8.h> |
| 45 | 45 |
| 46 namespace blink { | 46 namespace blink { |
| 47 | 47 |
| 48 // The amount of time to wait before informing the clients that the image has | |
| 49 // been updated (in seconds). This effectively throttles invalidations that | |
| 50 // result from new data arriving for this image. | |
| 51 static double flushDelaySeconds = 1.; | |
|
pdr.
2016/10/05 02:07:31
Should we use constexpr and a k prefix here?
E.g.,
| |
| 52 | |
| 48 ImageResource* ImageResource::fetch(FetchRequest& request, | 53 ImageResource* ImageResource::fetch(FetchRequest& request, |
| 49 ResourceFetcher* fetcher) { | 54 ResourceFetcher* fetcher) { |
| 50 if (request.resourceRequest().requestContext() == | 55 if (request.resourceRequest().requestContext() == |
| 51 WebURLRequest::RequestContextUnspecified) | 56 WebURLRequest::RequestContextUnspecified) |
| 52 request.mutableResourceRequest().setRequestContext( | 57 request.mutableResourceRequest().setRequestContext( |
| 53 WebURLRequest::RequestContextImage); | 58 WebURLRequest::RequestContextImage); |
| 54 if (fetcher->context().pageDismissalEventBeingDispatched()) { | 59 if (fetcher->context().pageDismissalEventBeingDispatched()) { |
| 55 KURL requestURL = request.resourceRequest().url(); | 60 KURL requestURL = request.resourceRequest().url(); |
| 56 if (requestURL.isValid() && | 61 if (requestURL.isValid() && |
| 57 fetcher->context().canRequest(Resource::Image, | 62 fetcher->context().canRequest(Resource::Image, |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 235 return m_image->data(); | 240 return m_image->data(); |
| 236 return nullptr; | 241 return nullptr; |
| 237 } | 242 } |
| 238 | 243 |
| 239 void ImageResource::appendData(const char* data, size_t length) { | 244 void ImageResource::appendData(const char* data, size_t length) { |
| 240 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(length); | 245 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(length); |
| 241 if (m_multipartParser) { | 246 if (m_multipartParser) { |
| 242 m_multipartParser->appendData(data, length); | 247 m_multipartParser->appendData(data, length); |
| 243 } else { | 248 } else { |
| 244 Resource::appendData(data, length); | 249 Resource::appendData(data, length); |
| 245 updateImage(false); | 250 |
| 251 // If we have an animated image, then update as soon as we have more data. | |
| 252 if (m_image && m_image->maybeAnimated()) { | |
| 253 updateImage(false); | |
| 254 return; | |
| 255 } | |
| 256 | |
| 257 // For other images, only update at |flushDelaySeconds| intervals. | |
|
pdr.
2016/10/05 02:07:31
Can you expand on this comment a bit? Similar to y
| |
| 258 double now = WTF::currentTime(); | |
| 259 if (m_lastFlushTime && (m_lastFlushTime + flushDelaySeconds <= now)) | |
| 260 updateImage(false); | |
| 261 m_lastFlushTime = now; | |
| 246 } | 262 } |
| 247 } | 263 } |
| 248 | 264 |
| 249 std::pair<blink::Image*, float> ImageResource::brokenImage( | 265 std::pair<blink::Image*, float> ImageResource::brokenImage( |
| 250 float deviceScaleFactor) { | 266 float deviceScaleFactor) { |
| 251 if (deviceScaleFactor >= 2) { | 267 if (deviceScaleFactor >= 2) { |
| 252 DEFINE_STATIC_REF(blink::Image, brokenImageHiRes, | 268 DEFINE_STATIC_REF(blink::Image, brokenImageHiRes, |
| 253 (blink::Image::loadPlatformResource("missingImage@2x"))); | 269 (blink::Image::loadPlatformResource("missingImage@2x"))); |
| 254 return std::make_pair(brokenImageHiRes, 2); | 270 return std::make_pair(brokenImageHiRes, 2); |
| 255 } | 271 } |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 586 return response().serviceWorkerResponseType() != | 602 return response().serviceWorkerResponseType() != |
| 587 WebServiceWorkerResponseTypeOpaque; | 603 WebServiceWorkerResponseTypeOpaque; |
| 588 if (!getImage()->currentFrameHasSingleSecurityOrigin()) | 604 if (!getImage()->currentFrameHasSingleSecurityOrigin()) |
| 589 return false; | 605 return false; |
| 590 if (passesAccessControlCheck(securityOrigin)) | 606 if (passesAccessControlCheck(securityOrigin)) |
| 591 return true; | 607 return true; |
| 592 return !securityOrigin->taintsCanvas(response().url()); | 608 return !securityOrigin->taintsCanvas(response().url()); |
| 593 } | 609 } |
| 594 | 610 |
| 595 } // namespace blink | 611 } // namespace blink |
| OLD | NEW |