Chromium Code Reviews| 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. |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 261 m_preloader(preloader), | 261 m_preloader(preloader), |
| 262 m_resource(toCSSStyleSheetResource(resource)) { | 262 m_resource(toCSSStyleSheetResource(resource)) { |
| 263 m_resource->addClient(this, Resource::DontMarkAsReferenced); | 263 m_resource->addClient(this, Resource::DontMarkAsReferenced); |
| 264 } | 264 } |
| 265 | 265 |
| 266 CSSPreloaderResourceClient::~CSSPreloaderResourceClient() {} | 266 CSSPreloaderResourceClient::~CSSPreloaderResourceClient() {} |
| 267 | 267 |
| 268 void CSSPreloaderResourceClient::setCSSStyleSheet( | 268 void CSSPreloaderResourceClient::setCSSStyleSheet( |
| 269 const String& href, | 269 const String& href, |
| 270 const KURL& baseURL, | 270 const KURL& baseURL, |
| 271 ReferrerPolicy referrerPolicy, | |
| 271 const String& charset, | 272 const String& charset, |
| 272 const CSSStyleSheetResource*) { | 273 const CSSStyleSheetResource*) { |
| 273 clearResource(); | 274 clearResource(); |
| 274 } | 275 } |
| 275 | 276 |
| 276 // Only attach for one appendData call, as that's where most imports will likely | 277 // Only attach for one appendData call, as that's where most imports will likely |
| 277 // be (according to spec). | 278 // be (according to spec). |
| 278 void CSSPreloaderResourceClient::didAppendFirstData( | 279 void CSSPreloaderResourceClient::didAppendFirstData( |
| 279 const CSSStyleSheetResource* resource) { | 280 const CSSStyleSheetResource* resource) { |
| 280 if (m_preloader) | 281 if (m_preloader) |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 295 // file/line information. | 296 // file/line information. |
| 296 // TODO(csharrison): If this becomes an issue the CSSPreloadScanner may be | 297 // TODO(csharrison): If this becomes an issue the CSSPreloadScanner may be |
| 297 // augmented to take care of this case without performing an additional | 298 // augmented to take care of this case without performing an additional |
| 298 // copy. | 299 // copy. |
| 299 double startTime = monotonicallyIncreasingTimeMS(); | 300 double startTime = monotonicallyIncreasingTimeMS(); |
| 300 const String& chunk = resource->sheetText(); | 301 const String& chunk = resource->sheetText(); |
| 301 if (chunk.isNull()) | 302 if (chunk.isNull()) |
| 302 return; | 303 return; |
| 303 CSSPreloadScanner cssPreloadScanner; | 304 CSSPreloadScanner cssPreloadScanner; |
| 304 PreloadRequestStream preloads; | 305 PreloadRequestStream preloads; |
| 305 cssPreloadScanner.scan(chunk, SegmentedString(), preloads, | 306 cssPreloadScanner.scan(chunk, SegmentedString(), preloads, |
|
estark
2017/03/28 11:26:23
I don't know this code very well, so I might be mi
jochen (gone - plz use gerrit)
2017/03/28 13:08:34
Excellent catch!
I don't know that code either, s
| |
| 306 resource->response().url()); | 307 resource->response().url()); |
| 307 DEFINE_STATIC_LOCAL(CustomCountHistogram, cssScanTimeHistogram, | 308 DEFINE_STATIC_LOCAL(CustomCountHistogram, cssScanTimeHistogram, |
| 308 ("PreloadScanner.ExternalCSS.ScanTime", 1, 1000000, 50)); | 309 ("PreloadScanner.ExternalCSS.ScanTime", 1, 1000000, 50)); |
| 309 cssScanTimeHistogram.count((monotonicallyIncreasingTimeMS() - startTime) * | 310 cssScanTimeHistogram.count((monotonicallyIncreasingTimeMS() - startTime) * |
| 310 1000); | 311 1000); |
| 311 fetchPreloads(preloads); | 312 fetchPreloads(preloads); |
| 312 } | 313 } |
| 313 | 314 |
| 314 void CSSPreloaderResourceClient::fetchPreloads(PreloadRequestStream& preloads) { | 315 void CSSPreloaderResourceClient::fetchPreloads(PreloadRequestStream& preloads) { |
| 315 if (preloads.size()) { | 316 if (preloads.size()) { |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 346 m_resource.clear(); | 347 m_resource.clear(); |
| 347 } | 348 } |
| 348 | 349 |
| 349 DEFINE_TRACE(CSSPreloaderResourceClient) { | 350 DEFINE_TRACE(CSSPreloaderResourceClient) { |
| 350 visitor->trace(m_preloader); | 351 visitor->trace(m_preloader); |
| 351 visitor->trace(m_resource); | 352 visitor->trace(m_resource); |
| 352 StyleSheetResourceClient::trace(visitor); | 353 StyleSheetResourceClient::trace(visitor); |
| 353 } | 354 } |
| 354 | 355 |
| 355 } // namespace blink | 356 } // namespace blink |
| OLD | NEW |