| 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 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 m_state = Initial; | 230 m_state = Initial; |
| 231 } else if (equalIgnoringCase(m_rule, "charset")) | 231 } else if (equalIgnoringCase(m_rule, "charset")) |
| 232 m_state = Initial; | 232 m_state = Initial; |
| 233 else | 233 else |
| 234 m_state = DoneParsingImportRules; | 234 m_state = DoneParsingImportRules; |
| 235 m_rule.clear(); | 235 m_rule.clear(); |
| 236 m_ruleValue.clear(); | 236 m_ruleValue.clear(); |
| 237 } | 237 } |
| 238 | 238 |
| 239 CSSPreloaderResourceClient::CSSPreloaderResourceClient(Resource* resource, HTMLR
esourcePreloader* preloader) | 239 CSSPreloaderResourceClient::CSSPreloaderResourceClient(Resource* resource, HTMLR
esourcePreloader* preloader) |
| 240 : m_resource(resource) | 240 : m_preloader(preloader) |
| 241 , m_preloader(preloader) | |
| 242 { | 241 { |
| 242 ASSERT(resource->getType() == Resource::CSSStyleSheet); |
| 243 setResource(static_cast<CSSStyleSheetResource*>(resource)); |
| 243 } | 244 } |
| 244 | 245 |
| 245 void CSSPreloaderResourceClient::notifyFinished(Resource* resource) | 246 void CSSPreloaderResourceClient::notifyFinished(Resource* resource) |
| 246 { | 247 { |
| 247 resource->removeClient(this); | 248 clearResource(); |
| 248 m_resource.clear(); | |
| 249 } | 249 } |
| 250 | 250 |
| 251 // Only attach for one appendData call, as that's where most imports will likely | 251 // Only attach for one appendData call, as that's where most imports will likely |
| 252 // be (according to spec). | 252 // be (according to spec). |
| 253 void CSSPreloaderResourceClient::didAppendFirstData(const CSSStyleSheetResource*
resource) | 253 void CSSPreloaderResourceClient::didAppendFirstData(const CSSStyleSheetResource*
resource) |
| 254 { | 254 { |
| 255 const String& chunk = resource->decodedText(); | 255 const String& chunk = resource->decodedText(); |
| 256 if (!chunk.isNull() && m_preloader) { | 256 if (!chunk.isNull() && m_preloader) { |
| 257 CSSPreloadScanner cssPreloadScanner; | 257 CSSPreloadScanner cssPreloadScanner; |
| 258 PreloadRequestStream preloads; | 258 PreloadRequestStream preloads; |
| 259 // Passing an empty SegmentedString here results in PreloadRequests | 259 // Passing an empty SegmentedString here results in PreloadRequests |
| 260 // with no file/line information. | 260 // with no file/line information. |
| 261 // TODO(csharrison): If this becomes an issue the CSSPreloadScanner | 261 // TODO(csharrison): If this becomes an issue the CSSPreloadScanner |
| 262 // may be augmented to take care of this case without performing an | 262 // may be augmented to take care of this case without performing an |
| 263 // additional copy. | 263 // additional copy. |
| 264 cssPreloadScanner.scan(chunk, SegmentedString(), preloads, resource->res
ponse().url()); | 264 cssPreloadScanner.scan(chunk, SegmentedString(), preloads, resource->res
ponse().url()); |
| 265 int currentPreloadCount = m_preloader->countPreloads(); | 265 int currentPreloadCount = m_preloader->countPreloads(); |
| 266 m_preloader->takeAndPreload(preloads); | 266 m_preloader->takeAndPreload(preloads); |
| 267 DEFINE_STATIC_LOCAL(CustomCountHistogram, cssImportHistogram, ("PreloadS
canner.ExternalCSS.PreloadCount", 1, 100, 50)); | 267 DEFINE_STATIC_LOCAL(CustomCountHistogram, cssImportHistogram, ("PreloadS
canner.ExternalCSS.PreloadCount", 1, 100, 50)); |
| 268 cssImportHistogram.count(m_preloader->countPreloads() - currentPreloadCo
unt); | 268 cssImportHistogram.count(m_preloader->countPreloads() - currentPreloadCo
unt); |
| 269 } | 269 } |
| 270 m_resource->removeClient(this); | 270 clearResource(); |
| 271 m_resource.clear(); | 271 } |
| 272 |
| 273 DEFINE_TRACE(CSSPreloaderResourceClient) |
| 274 { |
| 275 visitor->trace(m_preloader); |
| 276 ResourceOwner<StyleSheetResource>::trace(visitor); |
| 272 } | 277 } |
| 273 | 278 |
| 274 } // namespace blink | 279 } // namespace blink |
| OLD | NEW |