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

Unified Diff: third_party/WebKit/Source/core/loader/resource/ImageResource.cpp

Issue 2873793002: Record Data Savings for Client-Side LoFi (Closed)
Patch Set: fix crash in DRPNetworkDelegate when lofi_ui_service is null. Created 3 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
Index: third_party/WebKit/Source/core/loader/resource/ImageResource.cpp
diff --git a/third_party/WebKit/Source/core/loader/resource/ImageResource.cpp b/third_party/WebKit/Source/core/loader/resource/ImageResource.cpp
index 0537ade286012b5626f6cd80dc25801b246ad731..c5c664d4ceb9389c92184cfe591a4619b93c23a9 100644
--- a/third_party/WebKit/Source/core/loader/resource/ImageResource.cpp
+++ b/third_party/WebKit/Source/core/loader/resource/ImageResource.cpp
@@ -494,7 +494,20 @@ void ImageResource::ReloadIfLoFiOrPlaceholderImage(
SetCachePolicyBypassingCache();
- SetPreviewsStateNoTransform();
+ // The reloaded image should not use any previews transformations.
+ WebURLRequest::PreviewsState previews_state_for_reload =
+ WebURLRequest::kPreviewsNoTransform;
+
+ if (policy == kReloadIfNeeded && (GetResourceRequest().GetPreviewsState() &
+ WebURLRequest::kClientLoFiOn)) {
+ // If the image attempted to use Client LoFi, but encountered a decoding
+ // error and is being automatically reloaded, then also set the appropriate
+ // PreviewsState bit for that. This allows the embedder to count the
+ // bandwidth used for this reload against the data savings of the initial
+ // response.
+ previews_state_for_reload |= WebURLRequest::kClientLoFiAutoReload;
+ }
+ SetPreviewsState(previews_state_for_reload);
if (placeholder_option_ != PlaceholderOption::kDoNotReloadPlaceholder)
ClearRangeRequestHeader();
« no previous file with comments | « content/public/common/previews_state.h ('k') | third_party/WebKit/Source/core/loader/resource/ImageResourceTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698