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

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

Issue 2390583002: [WIP] WebFonts cache-aware timeout adaption (Closed)
Patch Set: 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 if (m_cachePolicy == WebCachePolicy::BypassingCache ||
Takashi Toyoshima 2016/10/03 09:06:35 Using switch is better to catch new cache policy b
Shao-Chuan Lee 2016/10/04 09:08:04 Done.
401 m_cachePolicy == WebCachePolicy::ReturnCacheDataDontLoad)
402 return;
403
404 m_savedCachePolicy = m_cachePolicy;
405 m_cachePolicy = WebCachePolicy::ReturnCacheDataDontLoad;
Takashi Toyoshima 2016/10/03 09:06:35 Should we have a TODO to use the right flag when /
Shao-Chuan Lee 2016/10/04 01:39:46 Do we already have a bug for this? Or we should fi
Takashi Toyoshima 2016/10/04 04:12:02 How about using crbug.com/570205 for this TODO.
Shao-Chuan Lee 2016/10/04 09:08:04 Done.
Shao-Chuan Lee 2016/10/05 10:16:09 Now crbug.com/652649 is available for tracking.
406 m_isCacheAwareLoadingActivated = true;
407 }
408
409 void ResourceRequest::deactivateCacheAwareLoading() {
410 DCHECK(m_isCacheAwareLoadingActivated);
411 m_cachePolicy = m_savedCachePolicy;
412 m_isCacheAwareLoadingActivated = false;
413 }
414
390 void ResourceRequest::initialize(const KURL& url) { 415 void ResourceRequest::initialize(const KURL& url) {
391 m_url = url; 416 m_url = url;
392 m_cachePolicy = WebCachePolicy::UseProtocolCachePolicy; 417 m_cachePolicy = WebCachePolicy::UseProtocolCachePolicy;
393 m_timeoutInterval = s_defaultTimeoutInterval; 418 m_timeoutInterval = s_defaultTimeoutInterval;
394 m_httpMethod = HTTPNames::GET; 419 m_httpMethod = HTTPNames::GET;
395 m_allowStoredCredentials = true; 420 m_allowStoredCredentials = true;
396 m_reportUploadProgress = false; 421 m_reportUploadProgress = false;
397 m_reportRawHeaders = false; 422 m_reportRawHeaders = false;
398 m_hasUserGesture = false; 423 m_hasUserGesture = false;
399 m_downloadToFile = false; 424 m_downloadToFile = false;
(...skipping 12 matching lines...) Expand all
412 m_fetchRedirectMode = WebURLRequest::FetchRedirectModeFollow; 437 m_fetchRedirectMode = WebURLRequest::FetchRedirectModeFollow;
413 m_referrerPolicy = ReferrerPolicyDefault; 438 m_referrerPolicy = ReferrerPolicyDefault;
414 m_loFiState = WebURLRequest::LoFiUnspecified; 439 m_loFiState = WebURLRequest::LoFiUnspecified;
415 m_didSetHTTPReferrer = false; 440 m_didSetHTTPReferrer = false;
416 m_checkForBrowserSideNavigation = true; 441 m_checkForBrowserSideNavigation = true;
417 m_uiStartTime = 0; 442 m_uiStartTime = 0;
418 m_isExternalRequest = false; 443 m_isExternalRequest = false;
419 m_inputPerfMetricReportPolicy = InputToLoadPerfMetricReportPolicy::NoReport; 444 m_inputPerfMetricReportPolicy = InputToLoadPerfMetricReportPolicy::NoReport;
420 m_redirectStatus = RedirectStatus::NoRedirect; 445 m_redirectStatus = RedirectStatus::NoRedirect;
421 m_requestorOrigin = SecurityOrigin::createUnique(); 446 m_requestorOrigin = SecurityOrigin::createUnique();
447 m_isCacheAwareLoadingEnabled = false;
448 m_isCacheAwareLoadingActivated = false;
449 m_savedCachePolicy = WebCachePolicy::UseProtocolCachePolicy;
422 } 450 }
423 451
424 } // namespace blink 452 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698