OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2008, 2010 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008, 2010 Apple Inc. All Rights Reserved. |
3 * Copyright (C) 2009 Torch Mobile, Inc. http://www.torchmobile.com/ | 3 * Copyright (C) 2009 Torch Mobile, Inc. http://www.torchmobile.com/ |
4 * Copyright (C) 2010 Google Inc. All Rights Reserved. | 4 * Copyright (C) 2010 Google Inc. All Rights Reserved. |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
11 * 2. Redistributions in binary form must reproduce the above copyright | 11 * 2. Redistributions in binary form must reproduce the above copyright |
12 * notice, this list of conditions and the following disclaimer in the | 12 * notice, this list of conditions and the following disclaimer in the |
13 * documentation and/or other materials provided with the distribution. | 13 * documentation and/or other materials provided with the distribution. |
14 * | 14 * |
15 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY | 15 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY |
16 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 16 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
18 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR | 18 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR |
19 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 19 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
22 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 22 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
23 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 */ | 26 */ |
27 | 27 |
28 #include "core/html/parser/CSSPreloadScanner.h" | 28 #include "core/html/parser/CSSPreloadScanner.h" |
29 | 29 |
30 #include <memory> | |
30 #include "core/dom/Document.h" | 31 #include "core/dom/Document.h" |
31 #include "core/frame/Settings.h" | 32 #include "core/frame/Settings.h" |
32 #include "core/html/parser/HTMLParserIdioms.h" | 33 #include "core/html/parser/HTMLParserIdioms.h" |
33 #include "core/html/parser/HTMLResourcePreloader.h" | 34 #include "core/html/parser/HTMLResourcePreloader.h" |
34 #include "core/loader/DocumentLoader.h" | 35 #include "core/loader/DocumentLoader.h" |
35 #include "core/loader/resource/CSSStyleSheetResource.h" | 36 #include "core/loader/resource/CSSStyleSheetResource.h" |
37 #include "platform/HTTPNames.h" | |
36 #include "platform/Histogram.h" | 38 #include "platform/Histogram.h" |
37 #include "platform/loader/fetch/FetchInitiatorTypeNames.h" | 39 #include "platform/loader/fetch/FetchInitiatorTypeNames.h" |
38 #include "platform/text/SegmentedString.h" | 40 #include "platform/text/SegmentedString.h" |
39 #include <memory> | 41 #include "platform/weborigin/SecurityPolicy.h" |
40 | 42 |
41 namespace blink { | 43 namespace blink { |
42 | 44 |
43 CSSPreloadScanner::CSSPreloadScanner() {} | 45 CSSPreloadScanner::CSSPreloadScanner() {} |
44 | 46 |
45 CSSPreloadScanner::~CSSPreloadScanner() {} | 47 CSSPreloadScanner::~CSSPreloadScanner() {} |
46 | 48 |
47 void CSSPreloadScanner::reset() { | 49 void CSSPreloadScanner::reset() { |
48 m_state = Initial; | 50 m_state = Initial; |
49 m_rule.clear(); | 51 m_rule.clear(); |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
261 m_preloader(preloader), | 263 m_preloader(preloader), |
262 m_resource(toCSSStyleSheetResource(resource)) { | 264 m_resource(toCSSStyleSheetResource(resource)) { |
263 m_resource->addClient(this, Resource::DontMarkAsReferenced); | 265 m_resource->addClient(this, Resource::DontMarkAsReferenced); |
264 } | 266 } |
265 | 267 |
266 CSSPreloaderResourceClient::~CSSPreloaderResourceClient() {} | 268 CSSPreloaderResourceClient::~CSSPreloaderResourceClient() {} |
267 | 269 |
268 void CSSPreloaderResourceClient::setCSSStyleSheet( | 270 void CSSPreloaderResourceClient::setCSSStyleSheet( |
269 const String& href, | 271 const String& href, |
270 const KURL& baseURL, | 272 const KURL& baseURL, |
273 ReferrerPolicy referrerPolicy, | |
271 const String& charset, | 274 const String& charset, |
272 const CSSStyleSheetResource*) { | 275 const CSSStyleSheetResource*) { |
273 clearResource(); | 276 clearResource(); |
274 } | 277 } |
275 | 278 |
276 // Only attach for one appendData call, as that's where most imports will likely | 279 // Only attach for one appendData call, as that's where most imports will likely |
277 // be (according to spec). | 280 // be (according to spec). |
278 void CSSPreloaderResourceClient::didAppendFirstData( | 281 void CSSPreloaderResourceClient::didAppendFirstData( |
279 const CSSStyleSheetResource* resource) { | 282 const CSSStyleSheetResource* resource) { |
280 if (m_preloader) | 283 if (m_preloader) |
(...skipping 13 matching lines...) Expand all Loading... | |
294 // Passing an empty SegmentedString here results in PreloadRequest with no | 297 // Passing an empty SegmentedString here results in PreloadRequest with no |
295 // file/line information. | 298 // file/line information. |
296 // TODO(csharrison): If this becomes an issue the CSSPreloadScanner may be | 299 // TODO(csharrison): If this becomes an issue the CSSPreloadScanner may be |
297 // augmented to take care of this case without performing an additional | 300 // augmented to take care of this case without performing an additional |
298 // copy. | 301 // copy. |
299 double startTime = monotonicallyIncreasingTimeMS(); | 302 double startTime = monotonicallyIncreasingTimeMS(); |
300 const String& chunk = resource->sheetText(); | 303 const String& chunk = resource->sheetText(); |
301 if (chunk.isNull()) | 304 if (chunk.isNull()) |
302 return; | 305 return; |
303 CSSPreloadScanner cssPreloadScanner; | 306 CSSPreloadScanner cssPreloadScanner; |
307 | |
308 ReferrerPolicy referrerPolicy = ReferrerPolicyDefault; | |
309 String referrerPolicyHeader = | |
310 resource->response().httpHeaderField(HTTPNames::Referrer_Policy); | |
311 if (!referrerPolicyHeader.isNull()) { | |
312 SecurityPolicy::referrerPolicyFromHeaderValue( | |
313 referrerPolicyHeader, DoNotSupportReferrerPolicyLegacyKeywords, | |
314 &referrerPolicy); | |
315 } | |
316 cssPreloadScanner.setReferrerPolicy(referrerPolicy); | |
estark
2017/03/28 18:17:21
Hmmm... I think this will end up using the documen
jochen (gone - plz use gerrit)
2017/03/28 18:49:37
I changed that code (see two files down)
estark
2017/03/28 18:59:53
Doh, sorry!
| |
304 PreloadRequestStream preloads; | 317 PreloadRequestStream preloads; |
305 cssPreloadScanner.scan(chunk, SegmentedString(), preloads, | 318 cssPreloadScanner.scan(chunk, SegmentedString(), preloads, |
306 resource->response().url()); | 319 resource->response().url()); |
307 DEFINE_STATIC_LOCAL(CustomCountHistogram, cssScanTimeHistogram, | 320 DEFINE_STATIC_LOCAL(CustomCountHistogram, cssScanTimeHistogram, |
308 ("PreloadScanner.ExternalCSS.ScanTime", 1, 1000000, 50)); | 321 ("PreloadScanner.ExternalCSS.ScanTime", 1, 1000000, 50)); |
309 cssScanTimeHistogram.count((monotonicallyIncreasingTimeMS() - startTime) * | 322 cssScanTimeHistogram.count((monotonicallyIncreasingTimeMS() - startTime) * |
310 1000); | 323 1000); |
311 fetchPreloads(preloads); | 324 fetchPreloads(preloads); |
312 } | 325 } |
313 | 326 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
346 m_resource.clear(); | 359 m_resource.clear(); |
347 } | 360 } |
348 | 361 |
349 DEFINE_TRACE(CSSPreloaderResourceClient) { | 362 DEFINE_TRACE(CSSPreloaderResourceClient) { |
350 visitor->trace(m_preloader); | 363 visitor->trace(m_preloader); |
351 visitor->trace(m_resource); | 364 visitor->trace(m_resource); |
352 StyleSheetResourceClient::trace(visitor); | 365 StyleSheetResourceClient::trace(visitor); |
353 } | 366 } |
354 | 367 |
355 } // namespace blink | 368 } // namespace blink |
OLD | NEW |