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

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLLinkElement.cpp

Issue 2290983003: CSSStyleSheetResource should cache decoded text instead of raw bytes (Closed)
Patch Set: rebased 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) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2003, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights 5 * Copyright (C) 2003, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights
6 * reserved. 6 * reserved.
7 * Copyright (C) 2009 Rob Buis (rwlbuis@gmail.com) 7 * Copyright (C) 2009 Rob Buis (rwlbuis@gmail.com)
8 * Copyright (C) 2011 Google Inc. All rights reserved. 8 * Copyright (C) 2011 Google Inc. All rights reserved.
9 * 9 *
10 * This library is free software; you can redistribute it and/or 10 * This library is free software; you can redistribute it and/or
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 m_loading = false; 422 m_loading = false;
423 removePendingSheet(); 423 removePendingSheet();
424 if (m_sheet) 424 if (m_sheet)
425 clearSheet(); 425 clearSheet();
426 return; 426 return;
427 } 427 }
428 428
429 // See the comment in PendingScript.cpp about why this check is necessary 429 // See the comment in PendingScript.cpp about why this check is necessary
430 // here, instead of in the resource fetcher. https://crbug.com/500701. 430 // here, instead of in the resource fetcher. https://crbug.com/500701.
431 if (!cachedStyleSheet->errorOccurred() && 431 if (!cachedStyleSheet->errorOccurred() &&
432 m_owner->fastHasAttribute(HTMLNames::integrityAttr) && 432 !m_owner->fastGetAttribute(HTMLNames::integrityAttr).isEmpty() &&
433 cachedStyleSheet->resourceBuffer() && 433 !cachedStyleSheet->integrityMetadata().isEmpty()) {
434 !SubresourceIntegrity::CheckSubresourceIntegrity( 434 ResourceIntegrityDisposition disposition =
435 *m_owner, cachedStyleSheet->resourceBuffer()->data(), 435 cachedStyleSheet->integrityDisposition();
436 cachedStyleSheet->resourceBuffer()->size(), KURL(baseURL, href), 436
437 *cachedStyleSheet)) { 437 DCHECK(disposition != ResourceIntegrityDisposition::NotChecked ||
438 m_loading = false; 438 !cachedStyleSheet->sheetText().isNull());
439 removePendingSheet(); 439
440 notifyLoadedSheetAndAllCriticalSubresources( 440 if (disposition == ResourceIntegrityDisposition::NotChecked &&
441 Node::ErrorOccurredLoadingSubresource); 441 !cachedStyleSheet->loadFailedOrCanceled()) {
442 return; 442 DCHECK(cachedStyleSheet->resourceBuffer());
443 if (SubresourceIntegrity::CheckSubresourceIntegrity(
444 *m_owner, cachedStyleSheet->resourceBuffer()->data(),
445 cachedStyleSheet->resourceBuffer()->size(), KURL(baseURL, href),
446 *cachedStyleSheet))
447 disposition = ResourceIntegrityDisposition::Passed;
448 else
449 disposition = ResourceIntegrityDisposition::Failed;
450
451 // TODO(kouhei): Remove this const_cast crbug.com/653502
452 const_cast<CSSStyleSheetResource*>(cachedStyleSheet)
453 ->setIntegrityDisposition(disposition);
454 }
455
456 if (disposition == ResourceIntegrityDisposition::Failed) {
457 m_loading = false;
458 removePendingSheet();
459 notifyLoadedSheetAndAllCriticalSubresources(
460 Node::ErrorOccurredLoadingSubresource);
461 return;
462 }
443 } 463 }
444 464
445 CSSParserContext parserContext(m_owner->document(), nullptr, baseURL, 465 CSSParserContext parserContext(m_owner->document(), nullptr, baseURL,
446 charset); 466 charset);
447 467
448 DEFINE_STATIC_LOCAL(EnumerationHistogram, restoredCachedStyleSheetHistogram, 468 DEFINE_STATIC_LOCAL(EnumerationHistogram, restoredCachedStyleSheetHistogram,
449 ("Blink.RestoredCachedStyleSheet", 2)); 469 ("Blink.RestoredCachedStyleSheet", 2));
450 DEFINE_STATIC_LOCAL( 470 DEFINE_STATIC_LOCAL(
451 EnumerationHistogram, restoredCachedStyleSheet2Histogram, 471 EnumerationHistogram, restoredCachedStyleSheet2Histogram,
452 ("Blink.RestoredCachedStyleSheet2", StyleSheetCacheStatusCount)); 472 ("Blink.RestoredCachedStyleSheet2", StyleSheetCacheStatusCount));
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 removePendingSheet(); 762 removePendingSheet();
743 } 763 }
744 764
745 DEFINE_TRACE(LinkStyle) { 765 DEFINE_TRACE(LinkStyle) {
746 visitor->trace(m_sheet); 766 visitor->trace(m_sheet);
747 LinkResource::trace(visitor); 767 LinkResource::trace(visitor);
748 ResourceOwner<StyleSheetResource>::trace(visitor); 768 ResourceOwner<StyleSheetResource>::trace(visitor);
749 } 769 }
750 770
751 } // namespace blink 771 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/fetch/Resource.cpp ('k') | third_party/WebKit/Source/core/inspector/InspectorPageAgent.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698