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

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

Issue 2390583002: [WIP] WebFonts cache-aware timeout adaption (Closed)
Patch Set: move callback impl to FontResource, remove unittests for now, fix 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
« no previous file with comments | « third_party/WebKit/Source/platform/network/ResourceRequest.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_isCacheAwareLoadingEnabled = data->m_isCacheAwareLoadingEnabled;
92 m_isCacheAwareLoadingActivated = data->m_isCacheAwareLoadingActivated;
93 m_savedCachePolicy = data->m_savedCachePolicy;
91 m_redirectStatus = data->m_redirectStatus; 94 m_redirectStatus = data->m_redirectStatus;
92 } 95 }
93 96
94 ResourceRequest::ResourceRequest(const ResourceRequest&) = default; 97 ResourceRequest::ResourceRequest(const ResourceRequest&) = default;
95 98
96 ResourceRequest& ResourceRequest::operator=(const ResourceRequest&) = default; 99 ResourceRequest& ResourceRequest::operator=(const ResourceRequest&) = default;
97 100
98 std::unique_ptr<CrossThreadResourceRequestData> ResourceRequest::copyData() 101 std::unique_ptr<CrossThreadResourceRequestData> ResourceRequest::copyData()
99 const { 102 const {
100 std::unique_ptr<CrossThreadResourceRequestData> data = 103 std::unique_ptr<CrossThreadResourceRequestData> data =
(...skipping 28 matching lines...) Expand all
129 data->m_fetchRequestMode = m_fetchRequestMode; 132 data->m_fetchRequestMode = m_fetchRequestMode;
130 data->m_fetchCredentialsMode = m_fetchCredentialsMode; 133 data->m_fetchCredentialsMode = m_fetchCredentialsMode;
131 data->m_fetchRedirectMode = m_fetchRedirectMode; 134 data->m_fetchRedirectMode = m_fetchRedirectMode;
132 data->m_loFiState = m_loFiState; 135 data->m_loFiState = m_loFiState;
133 data->m_referrerPolicy = m_referrerPolicy; 136 data->m_referrerPolicy = m_referrerPolicy;
134 data->m_didSetHTTPReferrer = m_didSetHTTPReferrer; 137 data->m_didSetHTTPReferrer = m_didSetHTTPReferrer;
135 data->m_checkForBrowserSideNavigation = m_checkForBrowserSideNavigation; 138 data->m_checkForBrowserSideNavigation = m_checkForBrowserSideNavigation;
136 data->m_uiStartTime = m_uiStartTime; 139 data->m_uiStartTime = m_uiStartTime;
137 data->m_isExternalRequest = m_isExternalRequest; 140 data->m_isExternalRequest = m_isExternalRequest;
138 data->m_inputPerfMetricReportPolicy = m_inputPerfMetricReportPolicy; 141 data->m_inputPerfMetricReportPolicy = m_inputPerfMetricReportPolicy;
142 data->m_isCacheAwareLoadingEnabled = m_isCacheAwareLoadingEnabled;
143 data->m_isCacheAwareLoadingActivated = m_isCacheAwareLoadingActivated;
144 data->m_savedCachePolicy = m_savedCachePolicy;
139 data->m_redirectStatus = m_redirectStatus; 145 data->m_redirectStatus = m_redirectStatus;
140 return data; 146 return data;
141 } 147 }
142 148
143 bool ResourceRequest::isEmpty() const { 149 bool ResourceRequest::isEmpty() const {
144 return m_url.isEmpty(); 150 return m_url.isEmpty();
145 } 151 }
146 152
147 bool ResourceRequest::isNull() const { 153 bool ResourceRequest::isNull() const {
148 return m_url.isNull(); 154 return m_url.isNull();
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 391
386 bool ResourceRequest::cacheControlContainsNoStore() const { 392 bool ResourceRequest::cacheControlContainsNoStore() const {
387 return cacheControlHeader().containsNoStore; 393 return cacheControlHeader().containsNoStore;
388 } 394 }
389 395
390 bool ResourceRequest::hasCacheValidatorFields() const { 396 bool ResourceRequest::hasCacheValidatorFields() const {
391 return !m_httpHeaderFields.get(HTTPNames::Last_Modified).isEmpty() || 397 return !m_httpHeaderFields.get(HTTPNames::Last_Modified).isEmpty() ||
392 !m_httpHeaderFields.get(HTTPNames::ETag).isEmpty(); 398 !m_httpHeaderFields.get(HTTPNames::ETag).isEmpty();
393 } 399 }
394 400
401 void ResourceRequest::mayActivateCacheAwareLoading() {
402 if (!m_isCacheAwareLoadingEnabled)
403 return;
yhirano 2016/10/06 11:57:06 DCHECK(!m_isCacheAwareLoadingActivated)?
Shao-Chuan Lee 2016/10/07 08:10:07 Done (now in activateCacheAwareLoading()).
404
405 switch (m_cachePolicy) {
406 case WebCachePolicy::BypassingCache:
407 case WebCachePolicy::ReturnCacheDataDontLoad:
408 return;
409 case WebCachePolicy::UseProtocolCachePolicy:
410 case WebCachePolicy::ValidatingCacheData:
411 case WebCachePolicy::ReturnCacheDataElseLoad:
412 break;
413 default:
yhirano 2016/10/06 11:57:06 This section is not needed.
Shao-Chuan Lee 2016/10/07 08:10:07 I'm using this to ensure new flags are handled in
yhirano 2016/10/11 04:17:07 The compiler checks if each switch statement inclu
Shao-Chuan Lee 2016/10/11 07:27:28 I see. Didn't notice we have -Wswitch enabled, tha
414 NOTREACHED();
415 }
416
417 m_savedCachePolicy = m_cachePolicy;
418 // TODO(652649): Stale data may be retrieved with this flag. Switch to new
419 // flag to load from disk cache with validation when available in net.
420 m_cachePolicy = WebCachePolicy::ReturnCacheDataDontLoad;
421 m_isCacheAwareLoadingActivated = true;
422 }
423
424 void ResourceRequest::deactivateCacheAwareLoading() {
425 DCHECK(m_isCacheAwareLoadingActivated);
426 m_cachePolicy = m_savedCachePolicy;
427 m_isCacheAwareLoadingActivated = false;
428 }
429
395 void ResourceRequest::initialize(const KURL& url) { 430 void ResourceRequest::initialize(const KURL& url) {
396 m_url = url; 431 m_url = url;
397 m_cachePolicy = WebCachePolicy::UseProtocolCachePolicy; 432 m_cachePolicy = WebCachePolicy::UseProtocolCachePolicy;
398 m_timeoutInterval = s_defaultTimeoutInterval; 433 m_timeoutInterval = s_defaultTimeoutInterval;
399 m_httpMethod = HTTPNames::GET; 434 m_httpMethod = HTTPNames::GET;
400 m_allowStoredCredentials = true; 435 m_allowStoredCredentials = true;
401 m_reportUploadProgress = false; 436 m_reportUploadProgress = false;
402 m_reportRawHeaders = false; 437 m_reportRawHeaders = false;
403 m_hasUserGesture = false; 438 m_hasUserGesture = false;
404 m_downloadToFile = false; 439 m_downloadToFile = false;
(...skipping 12 matching lines...) Expand all
417 m_fetchRedirectMode = WebURLRequest::FetchRedirectModeFollow; 452 m_fetchRedirectMode = WebURLRequest::FetchRedirectModeFollow;
418 m_referrerPolicy = ReferrerPolicyDefault; 453 m_referrerPolicy = ReferrerPolicyDefault;
419 m_loFiState = WebURLRequest::LoFiUnspecified; 454 m_loFiState = WebURLRequest::LoFiUnspecified;
420 m_didSetHTTPReferrer = false; 455 m_didSetHTTPReferrer = false;
421 m_checkForBrowserSideNavigation = true; 456 m_checkForBrowserSideNavigation = true;
422 m_uiStartTime = 0; 457 m_uiStartTime = 0;
423 m_isExternalRequest = false; 458 m_isExternalRequest = false;
424 m_inputPerfMetricReportPolicy = InputToLoadPerfMetricReportPolicy::NoReport; 459 m_inputPerfMetricReportPolicy = InputToLoadPerfMetricReportPolicy::NoReport;
425 m_redirectStatus = RedirectStatus::NoRedirect; 460 m_redirectStatus = RedirectStatus::NoRedirect;
426 m_requestorOrigin = SecurityOrigin::createUnique(); 461 m_requestorOrigin = SecurityOrigin::createUnique();
462 m_isCacheAwareLoadingEnabled = false;
463 m_isCacheAwareLoadingActivated = false;
464 m_savedCachePolicy = WebCachePolicy::UseProtocolCachePolicy;
427 } 465 }
428 466
429 } // namespace blink 467 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/network/ResourceRequest.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698