| 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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 request.isSpeculativePreload() | 164 request.isSpeculativePreload() |
| 165 ? SecurityViolationReportingPolicy::SuppressReporting | 165 ? SecurityViolationReportingPolicy::SuppressReporting |
| 166 : SecurityViolationReportingPolicy::Report, | 166 : SecurityViolationReportingPolicy::Report, |
| 167 request.getOriginRestriction()); | 167 request.getOriginRestriction()); |
| 168 if (blockReason == ResourceRequestBlockedReason::None) | 168 if (blockReason == ResourceRequestBlockedReason::None) |
| 169 fetcher->context().sendImagePing(requestURL); | 169 fetcher->context().sendImagePing(requestURL); |
| 170 } | 170 } |
| 171 return nullptr; | 171 return nullptr; |
| 172 } | 172 } |
| 173 | 173 |
| 174 ImageResource* resource = toImageResource( | 174 return toImageResource( |
| 175 fetcher->requestResource(request, ImageResourceFactory(request))); | 175 fetcher->requestResource(request, ImageResourceFactory(request))); |
| 176 if (resource && | 176 } |
| 177 request.placeholderImageRequestType() != FetchRequest::AllowPlaceholder && | 177 |
| 178 resource->shouldShowPlaceholder()) { | 178 bool ImageResource::canReuse(const FetchRequest& request) const { |
| 179 // If the image is a placeholder, but this fetch doesn't allow a | 179 // If the image is a placeholder, but this fetch doesn't allow a |
| 180 // placeholder, then load the original image. Note that the cache is not | 180 // placeholder, then do not reuse this resource. |
| 181 // bypassed here - it should be fine to use a cached copy if possible. | 181 if (request.placeholderImageRequestType() != FetchRequest::AllowPlaceholder && |
| 182 resource->reloadIfLoFiOrPlaceholderImage( | 182 m_placeholderOption != PlaceholderOption::DoNotReloadPlaceholder) |
| 183 fetcher, kReloadAlwaysWithExistingCachePolicy); | 183 return false; |
| 184 } | 184 return true; |
| 185 return resource; | |
| 186 } | 185 } |
| 187 | 186 |
| 188 ImageResource* ImageResource::create(const ResourceRequest& request) { | 187 ImageResource* ImageResource::create(const ResourceRequest& request) { |
| 189 return new ImageResource(request, ResourceLoaderOptions(), | 188 return new ImageResource(request, ResourceLoaderOptions(), |
| 190 ImageResourceContent::create(), false); | 189 ImageResourceContent::create(), false); |
| 191 } | 190 } |
| 192 | 191 |
| 193 ImageResource::ImageResource(const ResourceRequest& resourceRequest, | 192 ImageResource::ImageResource(const ResourceRequest& resourceRequest, |
| 194 const ResourceLoaderOptions& options, | 193 const ResourceLoaderOptions& options, |
| 195 ImageResourceContent* content, | 194 ImageResourceContent* content, |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 !isLoFiImage(*this)) | 480 !isLoFiImage(*this)) |
| 482 return; | 481 return; |
| 483 | 482 |
| 484 // Prevent clients and observers from being notified of completion while the | 483 // Prevent clients and observers from being notified of completion while the |
| 485 // reload is being scheduled, so that e.g. canceling an existing load in | 484 // reload is being scheduled, so that e.g. canceling an existing load in |
| 486 // progress doesn't cause clients and observers to be notified of completion | 485 // progress doesn't cause clients and observers to be notified of completion |
| 487 // prematurely. | 486 // prematurely. |
| 488 DCHECK(!m_isSchedulingReload); | 487 DCHECK(!m_isSchedulingReload); |
| 489 m_isSchedulingReload = true; | 488 m_isSchedulingReload = true; |
| 490 | 489 |
| 491 if (policy != kReloadAlwaysWithExistingCachePolicy) | 490 setCachePolicyBypassingCache(); |
| 492 setCachePolicyBypassingCache(); | |
| 493 | 491 |
| 494 setPreviewsStateNoTransform(); | 492 setPreviewsStateNoTransform(); |
| 495 | 493 |
| 496 if (m_placeholderOption != PlaceholderOption::DoNotReloadPlaceholder) | 494 if (m_placeholderOption != PlaceholderOption::DoNotReloadPlaceholder) |
| 497 clearRangeRequestHeader(); | 495 clearRangeRequestHeader(); |
| 498 m_placeholderOption = PlaceholderOption::DoNotReloadPlaceholder; | 496 m_placeholderOption = PlaceholderOption::DoNotReloadPlaceholder; |
| 499 | 497 |
| 500 if (isLoading()) { | 498 if (isLoading()) { |
| 501 loader()->cancel(); | 499 loader()->cancel(); |
| 502 // Canceling the loader causes error() to be called, which in turn calls | 500 // Canceling the loader causes error() to be called, which in turn calls |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 // reloading in Step 3 due to notifyObservers()'s | 593 // reloading in Step 3 due to notifyObservers()'s |
| 596 // schedulingReloadOrShouldReloadBrokenPlaceholder() check. | 594 // schedulingReloadOrShouldReloadBrokenPlaceholder() check. |
| 597 // 3. reloadIfLoFiOrPlaceholderImage() is called via ResourceFetcher | 595 // 3. reloadIfLoFiOrPlaceholderImage() is called via ResourceFetcher |
| 598 // (a) via didFinishLoading() called in decodeError(), or | 596 // (a) via didFinishLoading() called in decodeError(), or |
| 599 // (b) after returning ImageResource::updateImage(). | 597 // (b) after returning ImageResource::updateImage(). |
| 600 decodeError(allDataReceived); | 598 decodeError(allDataReceived); |
| 601 } | 599 } |
| 602 } | 600 } |
| 603 | 601 |
| 604 } // namespace blink | 602 } // namespace blink |
| OLD | NEW |