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

Side by Side Diff: third_party/WebKit/Source/core/dom/PendingScript.cpp

Issue 2398733003: Cache SubResourceIntegrity checks at Resource (Closed)
Patch Set: add include 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/fetch/IntegrityMetadata.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google, Inc. All Rights Reserved. 2 * Copyright (C) 2010 Google, Inc. All Rights Reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 String integrityAttr = 142 String integrityAttr =
143 m_element->fastGetAttribute(HTMLNames::integrityAttr); 143 m_element->fastGetAttribute(HTMLNames::integrityAttr);
144 144
145 // It is possible to get back a script resource with integrity metadata 145 // It is possible to get back a script resource with integrity metadata
146 // for a request with an empty integrity attribute. In that case, the 146 // for a request with an empty integrity attribute. In that case, the
147 // integrity check should be skipped, so this check ensures that the 147 // integrity check should be skipped, so this check ensures that the
148 // integrity attribute isn't empty in addition to checking if the 148 // integrity attribute isn't empty in addition to checking if the
149 // resource has empty integrity metadata. 149 // resource has empty integrity metadata.
150 if (!integrityAttr.isEmpty() && 150 if (!integrityAttr.isEmpty() &&
151 !scriptResource->integrityMetadata().isEmpty()) { 151 !scriptResource->integrityMetadata().isEmpty()) {
152 ScriptIntegrityDisposition disposition = 152 ResourceIntegrityDisposition disposition =
153 scriptResource->integrityDisposition(); 153 scriptResource->integrityDisposition();
154 if (disposition == ScriptIntegrityDisposition::Failed) { 154 if (disposition == ResourceIntegrityDisposition::Failed) {
155 // TODO(jww): This should probably also generate a console 155 // TODO(jww): This should probably also generate a console
156 // message identical to the one produced by 156 // message identical to the one produced by
157 // CheckSubresourceIntegrity below. See https://crbug.com/585267. 157 // CheckSubresourceIntegrity below. See https://crbug.com/585267.
158 m_integrityFailure = true; 158 m_integrityFailure = true;
159 } else if (disposition == ScriptIntegrityDisposition::NotChecked && 159 } else if (disposition == ResourceIntegrityDisposition::NotChecked &&
160 resource->resourceBuffer()) { 160 resource->resourceBuffer()) {
161 m_integrityFailure = !SubresourceIntegrity::CheckSubresourceIntegrity( 161 m_integrityFailure = !SubresourceIntegrity::CheckSubresourceIntegrity(
162 scriptResource->integrityMetadata(), *m_element, 162 scriptResource->integrityMetadata(), *m_element,
163 resource->resourceBuffer()->data(), 163 resource->resourceBuffer()->data(),
164 resource->resourceBuffer()->size(), resource->url(), *resource); 164 resource->resourceBuffer()->size(), resource->url(), *resource);
165 scriptResource->setIntegrityDisposition( 165 scriptResource->setIntegrityDisposition(
166 m_integrityFailure ? ScriptIntegrityDisposition::Failed 166 m_integrityFailure ? ResourceIntegrityDisposition::Failed
167 : ScriptIntegrityDisposition::Passed); 167 : ResourceIntegrityDisposition::Passed);
168 } 168 }
169 } 169 }
170 } 170 }
171 171
172 if (m_streamer) 172 if (m_streamer)
173 m_streamer->notifyFinished(resource); 173 m_streamer->notifyFinished(resource);
174 } 174 }
175 175
176 void PendingScript::notifyAppendData(ScriptResource* resource) { 176 void PendingScript::notifyAppendData(ScriptResource* resource) {
177 if (m_streamer) 177 if (m_streamer)
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 return false; 222 return false;
223 } 223 }
224 224
225 void PendingScript::prepareToSuspend() { 225 void PendingScript::prepareToSuspend() {
226 if (!m_streamer) 226 if (!m_streamer)
227 return; 227 return;
228 m_streamer->cancel(); 228 m_streamer->cancel();
229 } 229 }
230 230
231 } // namespace blink 231 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/fetch/IntegrityMetadata.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698