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

Side by Side Diff: third_party/WebKit/Source/platform/network/ResourceRequest.cpp

Issue 2390583002: [WIP] WebFonts cache-aware timeout adaption (Closed)
Patch Set: handle case in RemoteFontFaceSource if cache-aware deactivated in startLoad(), rebase Created 4 years, 2 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) 2003, 2006 Apple Computer, Inc. All rights reserved. 2 * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved.
3 * Copyright (C) 2009, 2012 Google Inc. All rights reserved. 3 * Copyright (C) 2009, 2012 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 setFetchRequestMode(data->m_fetchRequestMode); 81 setFetchRequestMode(data->m_fetchRequestMode);
82 setFetchCredentialsMode(data->m_fetchCredentialsMode); 82 setFetchCredentialsMode(data->m_fetchCredentialsMode);
83 setFetchRedirectMode(data->m_fetchRedirectMode); 83 setFetchRedirectMode(data->m_fetchRedirectMode);
84 setLoFiState(data->m_loFiState); 84 setLoFiState(data->m_loFiState);
85 m_referrerPolicy = data->m_referrerPolicy; 85 m_referrerPolicy = data->m_referrerPolicy;
86 m_didSetHTTPReferrer = data->m_didSetHTTPReferrer; 86 m_didSetHTTPReferrer = data->m_didSetHTTPReferrer;
87 m_checkForBrowserSideNavigation = data->m_checkForBrowserSideNavigation; 87 m_checkForBrowserSideNavigation = data->m_checkForBrowserSideNavigation;
88 m_uiStartTime = data->m_uiStartTime; 88 m_uiStartTime = data->m_uiStartTime;
89 m_isExternalRequest = data->m_isExternalRequest; 89 m_isExternalRequest = data->m_isExternalRequest;
90 m_inputPerfMetricReportPolicy = data->m_inputPerfMetricReportPolicy; 90 m_inputPerfMetricReportPolicy = data->m_inputPerfMetricReportPolicy;
91 m_isCacheAwareLoadingActivated = data->m_isCacheAwareLoadingActivated;
92 m_savedCachePolicy = data->m_savedCachePolicy;
91 m_redirectStatus = data->m_redirectStatus; 93 m_redirectStatus = data->m_redirectStatus;
92 } 94 }
93 95
94 ResourceRequest::ResourceRequest(const ResourceRequest&) = default; 96 ResourceRequest::ResourceRequest(const ResourceRequest&) = default;
95 97
96 ResourceRequest& ResourceRequest::operator=(const ResourceRequest&) = default; 98 ResourceRequest& ResourceRequest::operator=(const ResourceRequest&) = default;
97 99
98 std::unique_ptr<CrossThreadResourceRequestData> ResourceRequest::copyData() 100 std::unique_ptr<CrossThreadResourceRequestData> ResourceRequest::copyData()
99 const { 101 const {
100 std::unique_ptr<CrossThreadResourceRequestData> data = 102 std::unique_ptr<CrossThreadResourceRequestData> data =
(...skipping 28 matching lines...) Expand all
129 data->m_fetchRequestMode = m_fetchRequestMode; 131 data->m_fetchRequestMode = m_fetchRequestMode;
130 data->m_fetchCredentialsMode = m_fetchCredentialsMode; 132 data->m_fetchCredentialsMode = m_fetchCredentialsMode;
131 data->m_fetchRedirectMode = m_fetchRedirectMode; 133 data->m_fetchRedirectMode = m_fetchRedirectMode;
132 data->m_loFiState = m_loFiState; 134 data->m_loFiState = m_loFiState;
133 data->m_referrerPolicy = m_referrerPolicy; 135 data->m_referrerPolicy = m_referrerPolicy;
134 data->m_didSetHTTPReferrer = m_didSetHTTPReferrer; 136 data->m_didSetHTTPReferrer = m_didSetHTTPReferrer;
135 data->m_checkForBrowserSideNavigation = m_checkForBrowserSideNavigation; 137 data->m_checkForBrowserSideNavigation = m_checkForBrowserSideNavigation;
136 data->m_uiStartTime = m_uiStartTime; 138 data->m_uiStartTime = m_uiStartTime;
137 data->m_isExternalRequest = m_isExternalRequest; 139 data->m_isExternalRequest = m_isExternalRequest;
138 data->m_inputPerfMetricReportPolicy = m_inputPerfMetricReportPolicy; 140 data->m_inputPerfMetricReportPolicy = m_inputPerfMetricReportPolicy;
141 data->m_isCacheAwareLoadingActivated = m_isCacheAwareLoadingActivated;
142 data->m_savedCachePolicy = m_savedCachePolicy;
139 data->m_redirectStatus = m_redirectStatus; 143 data->m_redirectStatus = m_redirectStatus;
140 return data; 144 return data;
141 } 145 }
142 146
143 bool ResourceRequest::isEmpty() const { 147 bool ResourceRequest::isEmpty() const {
144 return m_url.isEmpty(); 148 return m_url.isEmpty();
145 } 149 }
146 150
147 bool ResourceRequest::isNull() const { 151 bool ResourceRequest::isNull() const {
148 return m_url.isNull(); 152 return m_url.isNull();
(...skipping 13 matching lines...) Expand all
162 166
163 m_url.setUser(String()); 167 m_url.setUser(String());
164 m_url.setPass(String()); 168 m_url.setPass(String());
165 } 169 }
166 170
167 WebCachePolicy ResourceRequest::getCachePolicy() const { 171 WebCachePolicy ResourceRequest::getCachePolicy() const {
168 return m_cachePolicy; 172 return m_cachePolicy;
169 } 173 }
170 174
171 void ResourceRequest::setCachePolicy(WebCachePolicy cachePolicy) { 175 void ResourceRequest::setCachePolicy(WebCachePolicy cachePolicy) {
172 m_cachePolicy = cachePolicy; 176 // TODO(632580): This may be called after cache-aware loading is activated,
177 // deactivate if cache policy is set to unsupported value.
178 if (m_isCacheAwareLoadingActivated &&
179 !isCacheAwareLoadingSupported(cachePolicy))
180 deactivateCacheAwareLoading();
181
182 if (m_isCacheAwareLoadingActivated)
183 m_savedCachePolicy = cachePolicy;
184 else
185 m_cachePolicy = cachePolicy;
173 } 186 }
174 187
175 double ResourceRequest::timeoutInterval() const { 188 double ResourceRequest::timeoutInterval() const {
176 return m_timeoutInterval; 189 return m_timeoutInterval;
177 } 190 }
178 191
179 void ResourceRequest::setTimeoutInterval(double timoutIntervalSeconds) { 192 void ResourceRequest::setTimeoutInterval(double timoutIntervalSeconds) {
180 m_timeoutInterval = timoutIntervalSeconds; 193 m_timeoutInterval = timoutIntervalSeconds;
181 } 194 }
182 195
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 398
386 bool ResourceRequest::cacheControlContainsNoStore() const { 399 bool ResourceRequest::cacheControlContainsNoStore() const {
387 return cacheControlHeader().containsNoStore; 400 return cacheControlHeader().containsNoStore;
388 } 401 }
389 402
390 bool ResourceRequest::hasCacheValidatorFields() const { 403 bool ResourceRequest::hasCacheValidatorFields() const {
391 return !m_httpHeaderFields.get(HTTPNames::Last_Modified).isEmpty() || 404 return !m_httpHeaderFields.get(HTTPNames::Last_Modified).isEmpty() ||
392 !m_httpHeaderFields.get(HTTPNames::ETag).isEmpty(); 405 !m_httpHeaderFields.get(HTTPNames::ETag).isEmpty();
393 } 406 }
394 407
408 bool ResourceRequest::isCacheAwareLoadingSupported(WebCachePolicy cachePolicy) {
409 switch (cachePolicy) {
410 case WebCachePolicy::BypassingCache:
411 case WebCachePolicy::ReturnCacheDataDontLoad:
412 return false;
413 case WebCachePolicy::UseProtocolCachePolicy:
414 case WebCachePolicy::ValidatingCacheData:
415 case WebCachePolicy::ReturnCacheDataElseLoad:
416 break;
kouhei (in TOK) 2016/10/20 10:43:07 default: ASSERT_NOT_REACHED()?
yhirano 2016/10/20 11:07:35 This CL once had the statements but I asked to rem
kouhei (in TOK) 2016/10/20 11:48:42 Got it. Please follow yhirano-san.
417 }
418 return true;
419 }
420
421 void ResourceRequest::mayActivateCacheAwareLoading() {
422 DCHECK(!m_isCacheAwareLoadingActivated);
423 if (!isCacheAwareLoadingSupported(m_cachePolicy))
424 return;
425
426 m_savedCachePolicy = m_cachePolicy;
427 // TODO(652649): Stale data may be retrieved with this flag. Switch to new
kouhei (in TOK) 2016/10/20 10:43:07 TODO(shaochuan): ... crbug.com/652649
Shao-Chuan Lee 2016/10/21 04:35:02 Done.
428 // flag to load from disk cache with validation when available in net.
429 m_cachePolicy = WebCachePolicy::ReturnCacheDataDontLoad;
430 m_isCacheAwareLoadingActivated = true;
431 }
432
433 void ResourceRequest::deactivateCacheAwareLoading() {
434 DCHECK(m_isCacheAwareLoadingActivated);
435 m_cachePolicy = m_savedCachePolicy;
436 m_isCacheAwareLoadingActivated = false;
437 }
438
395 void ResourceRequest::initialize(const KURL& url) { 439 void ResourceRequest::initialize(const KURL& url) {
396 m_url = url; 440 m_url = url;
397 m_cachePolicy = WebCachePolicy::UseProtocolCachePolicy; 441 m_cachePolicy = WebCachePolicy::UseProtocolCachePolicy;
398 m_timeoutInterval = s_defaultTimeoutInterval; 442 m_timeoutInterval = s_defaultTimeoutInterval;
399 m_httpMethod = HTTPNames::GET; 443 m_httpMethod = HTTPNames::GET;
400 m_allowStoredCredentials = true; 444 m_allowStoredCredentials = true;
401 m_reportUploadProgress = false; 445 m_reportUploadProgress = false;
402 m_reportRawHeaders = false; 446 m_reportRawHeaders = false;
403 m_hasUserGesture = false; 447 m_hasUserGesture = false;
404 m_downloadToFile = false; 448 m_downloadToFile = false;
(...skipping 12 matching lines...) Expand all
417 m_fetchRedirectMode = WebURLRequest::FetchRedirectModeFollow; 461 m_fetchRedirectMode = WebURLRequest::FetchRedirectModeFollow;
418 m_referrerPolicy = ReferrerPolicyDefault; 462 m_referrerPolicy = ReferrerPolicyDefault;
419 m_loFiState = WebURLRequest::LoFiUnspecified; 463 m_loFiState = WebURLRequest::LoFiUnspecified;
420 m_didSetHTTPReferrer = false; 464 m_didSetHTTPReferrer = false;
421 m_checkForBrowserSideNavigation = true; 465 m_checkForBrowserSideNavigation = true;
422 m_uiStartTime = 0; 466 m_uiStartTime = 0;
423 m_isExternalRequest = false; 467 m_isExternalRequest = false;
424 m_inputPerfMetricReportPolicy = InputToLoadPerfMetricReportPolicy::NoReport; 468 m_inputPerfMetricReportPolicy = InputToLoadPerfMetricReportPolicy::NoReport;
425 m_redirectStatus = RedirectStatus::NoRedirect; 469 m_redirectStatus = RedirectStatus::NoRedirect;
426 m_requestorOrigin = SecurityOrigin::createUnique(); 470 m_requestorOrigin = SecurityOrigin::createUnique();
471 m_isCacheAwareLoadingActivated = false;
472 m_savedCachePolicy = WebCachePolicy::UseProtocolCachePolicy;
427 } 473 }
428 474
429 } // namespace blink 475 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698