| 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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 m_state = Initial; | 234 m_state = Initial; |
| 235 } else if (equalIgnoringCase(m_rule, "charset")) | 235 } else if (equalIgnoringCase(m_rule, "charset")) |
| 236 m_state = Initial; | 236 m_state = Initial; |
| 237 else | 237 else |
| 238 m_state = DoneParsingImportRules; | 238 m_state = DoneParsingImportRules; |
| 239 m_rule.clear(); | 239 m_rule.clear(); |
| 240 m_ruleValue.clear(); | 240 m_ruleValue.clear(); |
| 241 } | 241 } |
| 242 | 242 |
| 243 CSSPreloaderResourceClient::CSSPreloaderResourceClient(Resource* resource, HTMLR
esourcePreloader* preloader) | 243 CSSPreloaderResourceClient::CSSPreloaderResourceClient(Resource* resource, HTMLR
esourcePreloader* preloader) |
| 244 : m_preloader(preloader) | 244 : m_policy(preloader->document()->settings()->cssExternalScannerPreload() ?
ScanAndPreload : ScanOnly) |
| 245 , m_preloader(preloader) |
| 245 { | 246 { |
| 246 DCHECK(resource->getType() == Resource::Type::CSSStyleSheet); | 247 DCHECK(resource->getType() == Resource::Type::CSSStyleSheet); |
| 247 setResource(toCSSStyleSheetResource(resource), Resource::DontMarkAsReference
d); | 248 setResource(toCSSStyleSheetResource(resource), Resource::DontMarkAsReference
d); |
| 248 } | 249 } |
| 249 | 250 |
| 250 CSSPreloaderResourceClient::~CSSPreloaderResourceClient() | 251 CSSPreloaderResourceClient::~CSSPreloaderResourceClient() |
| 251 { | 252 { |
| 252 } | 253 } |
| 253 | 254 |
| 254 void CSSPreloaderResourceClient::setCSSStyleSheet(const String& href, const KURL
& baseURL, const String& charset, const CSSStyleSheetResource*) | 255 void CSSPreloaderResourceClient::setCSSStyleSheet(const String& href, const KURL
& baseURL, const String& charset, const CSSStyleSheetResource*) |
| (...skipping 29 matching lines...) Expand all Loading... |
| 284 cssScanTimeHistogram.count((monotonicallyIncreasingTimeMS() - startTime) * 1
000); | 285 cssScanTimeHistogram.count((monotonicallyIncreasingTimeMS() - startTime) * 1
000); |
| 285 fetchPreloads(preloads); | 286 fetchPreloads(preloads); |
| 286 } | 287 } |
| 287 | 288 |
| 288 void CSSPreloaderResourceClient::fetchPreloads(PreloadRequestStream& preloads) | 289 void CSSPreloaderResourceClient::fetchPreloads(PreloadRequestStream& preloads) |
| 289 { | 290 { |
| 290 if (preloads.size()) { | 291 if (preloads.size()) { |
| 291 m_preloader->document()->loader()->didObserveLoadingBehavior(WebLoadingB
ehaviorFlag::WebLoadingBehaviorCSSPreloadFound); | 292 m_preloader->document()->loader()->didObserveLoadingBehavior(WebLoadingB
ehaviorFlag::WebLoadingBehaviorCSSPreloadFound); |
| 292 } | 293 } |
| 293 | 294 |
| 294 Settings* settings = m_preloader->document()->settings(); | 295 if (m_policy == ScanAndPreload) { |
| 295 DCHECK(settings); | |
| 296 if (settings->cssExternalScannerPreload()) { | |
| 297 int currentPreloadCount = m_preloader->countPreloads(); | 296 int currentPreloadCount = m_preloader->countPreloads(); |
| 298 m_preloader->takeAndPreload(preloads); | 297 m_preloader->takeAndPreload(preloads); |
| 299 DEFINE_STATIC_LOCAL(CustomCountHistogram, cssImportHistogram, ("PreloadS
canner.ExternalCSS.PreloadCount", 1, 100, 50)); | 298 DEFINE_STATIC_LOCAL(CustomCountHistogram, cssImportHistogram, ("PreloadS
canner.ExternalCSS.PreloadCount", 1, 100, 50)); |
| 300 cssImportHistogram.count(m_preloader->countPreloads() - currentPreloadCo
unt); | 299 cssImportHistogram.count(m_preloader->countPreloads() - currentPreloadCo
unt); |
| 301 } | 300 } |
| 302 } | 301 } |
| 303 | 302 |
| 304 DEFINE_TRACE(CSSPreloaderResourceClient) | 303 DEFINE_TRACE(CSSPreloaderResourceClient) |
| 305 { | 304 { |
| 306 visitor->trace(m_preloader); | 305 visitor->trace(m_preloader); |
| 307 ResourceOwner<CSSStyleSheetResource>::trace(visitor); | 306 ResourceOwner<CSSStyleSheetResource>::trace(visitor); |
| 308 } | 307 } |
| 309 | 308 |
| 310 } // namespace blink | 309 } // namespace blink |
| OLD | NEW |