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

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

Issue 2390583002: [WIP] WebFonts cache-aware timeout adaption (Closed)
Patch Set: remove flag in finish() instead of responseReceived() 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_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 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 386
381 bool ResourceRequest::cacheControlContainsNoStore() const { 387 bool ResourceRequest::cacheControlContainsNoStore() const {
382 return cacheControlHeader().containsNoStore; 388 return cacheControlHeader().containsNoStore;
383 } 389 }
384 390
385 bool ResourceRequest::hasCacheValidatorFields() const { 391 bool ResourceRequest::hasCacheValidatorFields() const {
386 return !m_httpHeaderFields.get(HTTPNames::Last_Modified).isEmpty() || 392 return !m_httpHeaderFields.get(HTTPNames::Last_Modified).isEmpty() ||
387 !m_httpHeaderFields.get(HTTPNames::ETag).isEmpty(); 393 !m_httpHeaderFields.get(HTTPNames::ETag).isEmpty();
388 } 394 }
389 395
396 void ResourceRequest::mayActivateCacheAwareLoading() {
397 if (!m_isCacheAwareLoadingEnabled)
398 return;
399
400 switch (m_cachePolicy) {
401 case WebCachePolicy::BypassingCache:
402 case WebCachePolicy::ReturnCacheDataDontLoad:
403 return;
404 case WebCachePolicy::UseProtocolCachePolicy:
405 case WebCachePolicy::ValidatingCacheData:
406 case WebCachePolicy::ReturnCacheDataElseLoad:
407 break;
408 default:
409 NOTREACHED();
410 }
411
412 m_savedCachePolicy = m_cachePolicy;
413 // TODO(570205): Stale data may be retrieved with this flag. Switch to new
414 // flag to load from disk cache with validation when available in net.
415 m_cachePolicy = WebCachePolicy::ReturnCacheDataDontLoad;
416 m_isCacheAwareLoadingActivated = true;
417 }
418
419 void ResourceRequest::deactivateCacheAwareLoading() {
420 DCHECK(m_isCacheAwareLoadingActivated);
421 m_cachePolicy = m_savedCachePolicy;
422 m_isCacheAwareLoadingActivated = false;
423 }
424
390 void ResourceRequest::initialize(const KURL& url) { 425 void ResourceRequest::initialize(const KURL& url) {
391 m_url = url; 426 m_url = url;
392 m_cachePolicy = WebCachePolicy::UseProtocolCachePolicy; 427 m_cachePolicy = WebCachePolicy::UseProtocolCachePolicy;
393 m_timeoutInterval = s_defaultTimeoutInterval; 428 m_timeoutInterval = s_defaultTimeoutInterval;
394 m_httpMethod = HTTPNames::GET; 429 m_httpMethod = HTTPNames::GET;
395 m_allowStoredCredentials = true; 430 m_allowStoredCredentials = true;
396 m_reportUploadProgress = false; 431 m_reportUploadProgress = false;
397 m_reportRawHeaders = false; 432 m_reportRawHeaders = false;
398 m_hasUserGesture = false; 433 m_hasUserGesture = false;
399 m_downloadToFile = false; 434 m_downloadToFile = false;
(...skipping 12 matching lines...) Expand all
412 m_fetchRedirectMode = WebURLRequest::FetchRedirectModeFollow; 447 m_fetchRedirectMode = WebURLRequest::FetchRedirectModeFollow;
413 m_referrerPolicy = ReferrerPolicyDefault; 448 m_referrerPolicy = ReferrerPolicyDefault;
414 m_loFiState = WebURLRequest::LoFiUnspecified; 449 m_loFiState = WebURLRequest::LoFiUnspecified;
415 m_didSetHTTPReferrer = false; 450 m_didSetHTTPReferrer = false;
416 m_checkForBrowserSideNavigation = true; 451 m_checkForBrowserSideNavigation = true;
417 m_uiStartTime = 0; 452 m_uiStartTime = 0;
418 m_isExternalRequest = false; 453 m_isExternalRequest = false;
419 m_inputPerfMetricReportPolicy = InputToLoadPerfMetricReportPolicy::NoReport; 454 m_inputPerfMetricReportPolicy = InputToLoadPerfMetricReportPolicy::NoReport;
420 m_redirectStatus = RedirectStatus::NoRedirect; 455 m_redirectStatus = RedirectStatus::NoRedirect;
421 m_requestorOrigin = SecurityOrigin::createUnique(); 456 m_requestorOrigin = SecurityOrigin::createUnique();
457 m_isCacheAwareLoadingEnabled = false;
458 m_isCacheAwareLoadingActivated = false;
459 m_savedCachePolicy = WebCachePolicy::UseProtocolCachePolicy;
422 } 460 }
423 461
424 } // namespace blink 462 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698