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

Side by Side Diff: third_party/WebKit/Source/core/fetch/ScriptResource.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 | « third_party/WebKit/Source/core/fetch/ScriptResource.h ('k') | no next file » | 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) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) 2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de)
3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) 3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org)
4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) 4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org)
5 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) 5 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
6 Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 6 Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
7 7
8 This library is free software; you can redistribute it and/or 8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Library General Public 9 modify it under the terms of the GNU Library General Public
10 License as published by the Free Software Foundation; either 10 License as published by the Free Software Foundation; either
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 return resource; 50 return resource;
51 } 51 }
52 52
53 ScriptResource::ScriptResource(const ResourceRequest& resourceRequest, 53 ScriptResource::ScriptResource(const ResourceRequest& resourceRequest,
54 const ResourceLoaderOptions& options, 54 const ResourceLoaderOptions& options,
55 const String& charset) 55 const String& charset)
56 : TextResource(resourceRequest, 56 : TextResource(resourceRequest,
57 Script, 57 Script,
58 options, 58 options,
59 "application/javascript", 59 "application/javascript",
60 charset), 60 charset) {}
61 m_integrityDisposition(ScriptIntegrityDisposition::NotChecked) {}
62 61
63 ScriptResource::~ScriptResource() {} 62 ScriptResource::~ScriptResource() {}
64 63
65 void ScriptResource::didAddClient(ResourceClient* client) { 64 void ScriptResource::didAddClient(ResourceClient* client) {
66 DCHECK(ScriptResourceClient::isExpectedType(client)); 65 DCHECK(ScriptResourceClient::isExpectedType(client));
67 Resource::didAddClient(client); 66 Resource::didAddClient(client);
68 } 67 }
69 68
70 void ScriptResource::appendData(const char* data, size_t length) { 69 void ScriptResource::appendData(const char* data, size_t length) {
71 Resource::appendData(data, length); 70 Resource::appendData(data, length);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 void ScriptResource::destroyDecodedDataForFailedRevalidation() { 104 void ScriptResource::destroyDecodedDataForFailedRevalidation() {
106 m_script = AtomicString(); 105 m_script = AtomicString();
107 } 106 }
108 107
109 bool ScriptResource::mimeTypeAllowedByNosniff() const { 108 bool ScriptResource::mimeTypeAllowedByNosniff() const {
110 return parseContentTypeOptionsHeader(response().httpHeaderField( 109 return parseContentTypeOptionsHeader(response().httpHeaderField(
111 HTTPNames::X_Content_Type_Options)) != ContentTypeOptionsNosniff || 110 HTTPNames::X_Content_Type_Options)) != ContentTypeOptionsNosniff ||
112 MIMETypeRegistry::isSupportedJavaScriptMIMEType(httpContentType()); 111 MIMETypeRegistry::isSupportedJavaScriptMIMEType(httpContentType());
113 } 112 }
114 113
115 void ScriptResource::setIntegrityDisposition(
116 ScriptIntegrityDisposition disposition) {
117 DCHECK_NE(disposition, ScriptIntegrityDisposition::NotChecked);
118 m_integrityDisposition = disposition;
119 }
120 bool ScriptResource::mustRefetchDueToIntegrityMetadata(
121 const FetchRequest& request) const {
122 if (request.integrityMetadata().isEmpty())
123 return false;
124
125 return !IntegrityMetadata::setsEqual(m_integrityMetadata,
126 request.integrityMetadata());
127 }
128
129 } // namespace blink 114 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/fetch/ScriptResource.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698