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

Side by Side Diff: third_party/WebKit/Source/platform/loader/fetch/FetchRequest.cpp

Issue 2676163002: Refactor the forPreload flag to mean speculative preload. (Closed)
Patch Set: Renamed ReportingPolicy and moved comments Created 3 years, 10 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google, Inc. All rights reserved. 2 * Copyright (C) 2012 Google, Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 21 matching lines...) Expand all
32 #include "platform/weborigin/Suborigin.h" 32 #include "platform/weborigin/Suborigin.h"
33 33
34 namespace blink { 34 namespace blink {
35 35
36 FetchRequest::FetchRequest(const ResourceRequest& resourceRequest, 36 FetchRequest::FetchRequest(const ResourceRequest& resourceRequest,
37 const AtomicString& initiator, 37 const AtomicString& initiator,
38 const String& charset) 38 const String& charset)
39 : m_resourceRequest(resourceRequest), 39 : m_resourceRequest(resourceRequest),
40 m_charset(charset), 40 m_charset(charset),
41 m_options(ResourceFetcher::defaultResourceOptions()), 41 m_options(ResourceFetcher::defaultResourceOptions()),
42 m_forPreload(false), 42 m_speculativePreload(false),
43 m_linkPreload(false), 43 m_linkPreload(false),
44 m_preloadDiscoveryTime(0.0), 44 m_preloadDiscoveryTime(0.0),
45 m_defer(NoDefer), 45 m_defer(NoDefer),
46 m_originRestriction(UseDefaultOriginRestrictionForType), 46 m_originRestriction(UseDefaultOriginRestrictionForType),
47 m_placeholderImageRequestType(DisallowPlaceholder) { 47 m_placeholderImageRequestType(DisallowPlaceholder) {
48 m_options.initiatorInfo.name = initiator; 48 m_options.initiatorInfo.name = initiator;
49 } 49 }
50 50
51 FetchRequest::FetchRequest(const ResourceRequest& resourceRequest, 51 FetchRequest::FetchRequest(const ResourceRequest& resourceRequest,
52 const AtomicString& initiator, 52 const AtomicString& initiator,
53 const ResourceLoaderOptions& options) 53 const ResourceLoaderOptions& options)
54 : m_resourceRequest(resourceRequest), 54 : m_resourceRequest(resourceRequest),
55 m_options(options), 55 m_options(options),
56 m_forPreload(false), 56 m_speculativePreload(false),
57 m_linkPreload(false), 57 m_linkPreload(false),
58 m_preloadDiscoveryTime(0.0), 58 m_preloadDiscoveryTime(0.0),
59 m_defer(NoDefer), 59 m_defer(NoDefer),
60 m_originRestriction(UseDefaultOriginRestrictionForType), 60 m_originRestriction(UseDefaultOriginRestrictionForType),
61 m_placeholderImageRequestType( 61 m_placeholderImageRequestType(
62 PlaceholderImageRequestType::DisallowPlaceholder) { 62 PlaceholderImageRequestType::DisallowPlaceholder) {
63 m_options.initiatorInfo.name = initiator; 63 m_options.initiatorInfo.name = initiator;
64 } 64 }
65 65
66 FetchRequest::FetchRequest(const ResourceRequest& resourceRequest, 66 FetchRequest::FetchRequest(const ResourceRequest& resourceRequest,
67 const FetchInitiatorInfo& initiator) 67 const FetchInitiatorInfo& initiator)
68 : m_resourceRequest(resourceRequest), 68 : m_resourceRequest(resourceRequest),
69 m_options(ResourceFetcher::defaultResourceOptions()), 69 m_options(ResourceFetcher::defaultResourceOptions()),
70 m_forPreload(false), 70 m_speculativePreload(false),
71 m_linkPreload(false), 71 m_linkPreload(false),
72 m_preloadDiscoveryTime(0.0), 72 m_preloadDiscoveryTime(0.0),
73 m_defer(NoDefer), 73 m_defer(NoDefer),
74 m_originRestriction(UseDefaultOriginRestrictionForType), 74 m_originRestriction(UseDefaultOriginRestrictionForType),
75 m_placeholderImageRequestType( 75 m_placeholderImageRequestType(
76 PlaceholderImageRequestType::DisallowPlaceholder) { 76 PlaceholderImageRequestType::DisallowPlaceholder) {
77 m_options.initiatorInfo = initiator; 77 m_options.initiatorInfo = initiator;
78 } 78 }
79 79
80 FetchRequest::~FetchRequest() {} 80 FetchRequest::~FetchRequest() {}
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 m_resourceRequest.setHTTPOrigin(origin); 125 m_resourceRequest.setHTTPOrigin(origin);
126 } 126 }
127 127
128 void FetchRequest::setResourceWidth(ResourceWidth resourceWidth) { 128 void FetchRequest::setResourceWidth(ResourceWidth resourceWidth) {
129 if (resourceWidth.isSet) { 129 if (resourceWidth.isSet) {
130 m_resourceWidth.width = resourceWidth.width; 130 m_resourceWidth.width = resourceWidth.width;
131 m_resourceWidth.isSet = true; 131 m_resourceWidth.isSet = true;
132 } 132 }
133 } 133 }
134 134
135 void FetchRequest::setForPreload(bool forPreload, double discoveryTime) { 135 void FetchRequest::setSpeculativePreload(bool speculativePreload,
136 m_forPreload = forPreload; 136 double discoveryTime) {
137 m_speculativePreload = speculativePreload;
137 m_preloadDiscoveryTime = discoveryTime; 138 m_preloadDiscoveryTime = discoveryTime;
138 } 139 }
139 140
140 void FetchRequest::makeSynchronous() { 141 void FetchRequest::makeSynchronous() {
141 // Synchronous requests should always be max priority, lest they hang the 142 // Synchronous requests should always be max priority, lest they hang the
142 // renderer. 143 // renderer.
143 m_resourceRequest.setPriority(ResourceLoadPriorityHighest); 144 m_resourceRequest.setPriority(ResourceLoadPriorityHighest);
144 m_resourceRequest.setTimeoutInterval(10); 145 m_resourceRequest.setTimeoutInterval(10);
145 m_options.synchronousPolicy = RequestSynchronously; 146 m_options.synchronousPolicy = RequestSynchronously;
146 } 147 }
(...skipping 13 matching lines...) Expand all
160 // the dimensions for larger images. 161 // the dimensions for larger images.
161 // TODO(sclittle): Calculate the optimal value for this number. 162 // TODO(sclittle): Calculate the optimal value for this number.
162 m_resourceRequest.setHTTPHeaderField("range", "bytes=0-2047"); 163 m_resourceRequest.setHTTPHeaderField("range", "bytes=0-2047");
163 164
164 // TODO(sclittle): Indicate somehow (e.g. through a new request bit) to the 165 // TODO(sclittle): Indicate somehow (e.g. through a new request bit) to the
165 // embedder that it should return the full resource if the entire resource is 166 // embedder that it should return the full resource if the entire resource is
166 // fresh in the cache. 167 // fresh in the cache.
167 } 168 }
168 169
169 } // namespace blink 170 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698