| OLD | NEW |
| 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 14 matching lines...) Expand all Loading... |
| 25 */ | 25 */ |
| 26 | 26 |
| 27 #include "core/fetch/ScriptResource.h" | 27 #include "core/fetch/ScriptResource.h" |
| 28 | 28 |
| 29 #include "core/fetch/FetchRequest.h" | 29 #include "core/fetch/FetchRequest.h" |
| 30 #include "core/fetch/IntegrityMetadata.h" | 30 #include "core/fetch/IntegrityMetadata.h" |
| 31 #include "core/fetch/ResourceClientWalker.h" | 31 #include "core/fetch/ResourceClientWalker.h" |
| 32 #include "core/fetch/ResourceFetcher.h" | 32 #include "core/fetch/ResourceFetcher.h" |
| 33 #include "platform/MIMETypeRegistry.h" | 33 #include "platform/MIMETypeRegistry.h" |
| 34 #include "platform/SharedBuffer.h" | 34 #include "platform/SharedBuffer.h" |
| 35 #include "platform/network/HTTPParsers.h" | |
| 36 #include "public/platform/WebProcessMemoryDump.h" | 35 #include "public/platform/WebProcessMemoryDump.h" |
| 37 | 36 |
| 38 namespace blink { | 37 namespace blink { |
| 39 | 38 |
| 40 PassRefPtrWillBeRawPtr<ScriptResource> ScriptResource::fetch(FetchRequest& reque
st, ResourceFetcher* fetcher) | 39 PassRefPtrWillBeRawPtr<ScriptResource> ScriptResource::fetch(FetchRequest& reque
st, ResourceFetcher* fetcher) |
| 41 { | 40 { |
| 42 ASSERT(request.resourceRequest().frameType() == WebURLRequest::FrameTypeNone
); | 41 ASSERT(request.resourceRequest().frameType() == WebURLRequest::FrameTypeNone
); |
| 43 request.mutableResourceRequest().setRequestContext(WebURLRequest::RequestCon
textScript); | 42 request.mutableResourceRequest().setRequestContext(WebURLRequest::RequestCon
textScript); |
| 44 RefPtrWillBeRawPtr<ScriptResource> resource = toScriptResource(fetcher->requ
estResource(request, ScriptResourceFactory())); | 43 RefPtrWillBeRawPtr<ScriptResource> resource = toScriptResource(fetcher->requ
estResource(request, ScriptResourceFactory())); |
| 45 if (resource && !request.integrityMetadata().isEmpty()) | 44 if (resource && !request.integrityMetadata().isEmpty()) |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 | 77 |
| 79 void ScriptResource::onMemoryDump(WebMemoryDumpLevelOfDetail levelOfDetail, WebP
rocessMemoryDump* memoryDump) const | 78 void ScriptResource::onMemoryDump(WebMemoryDumpLevelOfDetail levelOfDetail, WebP
rocessMemoryDump* memoryDump) const |
| 80 { | 79 { |
| 81 Resource::onMemoryDump(levelOfDetail, memoryDump); | 80 Resource::onMemoryDump(levelOfDetail, memoryDump); |
| 82 const String name = getMemoryDumpName() + "/decoded_script"; | 81 const String name = getMemoryDumpName() + "/decoded_script"; |
| 83 auto dump = memoryDump->createMemoryAllocatorDump(name); | 82 auto dump = memoryDump->createMemoryAllocatorDump(name); |
| 84 dump->addScalar("size", "bytes", m_script.currentSizeInBytes()); | 83 dump->addScalar("size", "bytes", m_script.currentSizeInBytes()); |
| 85 memoryDump->addSuballocation(dump->guid(), String(WTF::Partitions::kAllocate
dObjectPoolName)); | 84 memoryDump->addSuballocation(dump->guid(), String(WTF::Partitions::kAllocate
dObjectPoolName)); |
| 86 } | 85 } |
| 87 | 86 |
| 88 AtomicString ScriptResource::mimeType() const | |
| 89 { | |
| 90 return extractMIMETypeFromMediaType(m_response.httpHeaderField(HTTPNames::Co
ntent_Type)).lower(); | |
| 91 } | |
| 92 | |
| 93 const CompressibleString& ScriptResource::script() | 87 const CompressibleString& ScriptResource::script() |
| 94 { | 88 { |
| 95 ASSERT(!isPurgeable()); | 89 ASSERT(!isPurgeable()); |
| 96 ASSERT(isLoaded()); | 90 ASSERT(isLoaded()); |
| 97 | 91 |
| 98 if (m_script.isNull() && m_data) { | 92 if (m_script.isNull() && m_data) { |
| 99 String script = decodedText(); | 93 String script = decodedText(); |
| 100 m_data.clear(); | 94 m_data.clear(); |
| 101 // We lie a it here and claim that script counts as encoded data (even t
hough it's really decoded data). | 95 // We lie a it here and claim that script counts as encoded data (even t
hough it's really decoded data). |
| 102 // That's because the MemoryCache thinks that it can clear out decoded d
ata by calling destroyDecodedData(), | 96 // That's because the MemoryCache thinks that it can clear out decoded d
ata by calling destroyDecodedData(), |
| 103 // but we can't destroy script in destroyDecodedData because that's our
only copy of the data! | 97 // but we can't destroy script in destroyDecodedData because that's our
only copy of the data! |
| 104 setEncodedSize(script.sizeInBytes()); | 98 setEncodedSize(script.sizeInBytes()); |
| 105 m_script = CompressibleString(script.impl()); | 99 m_script = CompressibleString(script.impl()); |
| 106 } | 100 } |
| 107 | 101 |
| 108 return m_script; | 102 return m_script; |
| 109 } | 103 } |
| 110 | 104 |
| 111 void ScriptResource::destroyDecodedDataForFailedRevalidation() | 105 void ScriptResource::destroyDecodedDataForFailedRevalidation() |
| 112 { | 106 { |
| 113 m_script = CompressibleString(); | 107 m_script = CompressibleString(); |
| 114 } | 108 } |
| 115 | 109 |
| 116 bool ScriptResource::mimeTypeAllowedByNosniff() const | 110 bool ScriptResource::mimeTypeAllowedByNosniff() const |
| 117 { | 111 { |
| 118 return parseContentTypeOptionsHeader(m_response.httpHeaderField(HTTPNames::X
_Content_Type_Options)) != ContentTypeOptionsNosniff || MIMETypeRegistry::isSupp
ortedJavaScriptMIMEType(mimeType()); | 112 return parseContentTypeOptionsHeader(m_response.httpHeaderField(HTTPNames::X
_Content_Type_Options)) != ContentTypeOptionsNosniff || MIMETypeRegistry::isSupp
ortedJavaScriptMIMEType(httpContentType()); |
| 119 } | 113 } |
| 120 | 114 |
| 121 void ScriptResource::setIntegrityDisposition(ScriptIntegrityDisposition disposit
ion) | 115 void ScriptResource::setIntegrityDisposition(ScriptIntegrityDisposition disposit
ion) |
| 122 { | 116 { |
| 123 ASSERT(disposition != ScriptIntegrityDisposition::NotChecked); | 117 ASSERT(disposition != ScriptIntegrityDisposition::NotChecked); |
| 124 m_integrityDisposition = disposition; | 118 m_integrityDisposition = disposition; |
| 125 } | 119 } |
| 126 bool ScriptResource::mustRefetchDueToIntegrityMetadata(const FetchRequest& reque
st) const | 120 bool ScriptResource::mustRefetchDueToIntegrityMetadata(const FetchRequest& reque
st) const |
| 127 { | 121 { |
| 128 if (request.integrityMetadata().isEmpty()) | 122 if (request.integrityMetadata().isEmpty()) |
| 129 return false; | 123 return false; |
| 130 | 124 |
| 131 return !IntegrityMetadata::setsEqual(m_integrityMetadata, request.integrityM
etadata()); | 125 return !IntegrityMetadata::setsEqual(m_integrityMetadata, request.integrityM
etadata()); |
| 132 } | 126 } |
| 133 | 127 |
| 134 } // namespace blink | 128 } // namespace blink |
| OLD | NEW |