Index: third_party/WebKit/Source/core/loader/resource/ScriptResource.cpp |
diff --git a/third_party/WebKit/Source/core/loader/resource/ScriptResource.cpp b/third_party/WebKit/Source/core/loader/resource/ScriptResource.cpp |
index dffe750fdb74e2e7e85858b53c75793f43dcb2a6..26e536e43f3da52994603a946e5796dca1c5222d 100644 |
--- a/third_party/WebKit/Source/core/loader/resource/ScriptResource.cpp |
+++ b/third_party/WebKit/Source/core/loader/resource/ScriptResource.cpp |
@@ -34,7 +34,6 @@ |
#include "platform/loader/fetch/IntegrityMetadata.h" |
#include "platform/loader/fetch/ResourceClientWalker.h" |
#include "platform/loader/fetch/ResourceFetcher.h" |
-#include "platform/network/mime/MIMETypeRegistry.h" |
namespace blink { |
@@ -78,56 +77,38 @@ void ScriptResource::OnMemoryDump(WebMemoryDumpLevelOfDetail level_of_detail, |
Resource::OnMemoryDump(level_of_detail, memory_dump); |
const String name = GetMemoryDumpName() + "/decoded_script"; |
auto dump = memory_dump->CreateMemoryAllocatorDump(name); |
- dump->AddScalar("size", "bytes", source_text_.CharactersSizeInBytes()); |
+ dump->AddScalar("size", "bytes", DecodedSize()); |
memory_dump->AddSuballocation( |
dump->Guid(), String(WTF::Partitions::kAllocatedObjectPoolName)); |
} |
-const String& ScriptResource::SourceText() { |
+const ScriptResourceData* ScriptResource::ResourceData() { |
DCHECK(IsLoaded()); |
+ if (script_data_) |
+ return script_data_; |
- if (source_text_.IsNull() && Data()) { |
+ AtomicString atomic_source_text; |
+ if (Data()) { |
String source_text = DecodedText(); |
ClearData(); |
SetDecodedSize(source_text.CharactersSizeInBytes()); |
- source_text_ = AtomicString(source_text); |
+ atomic_source_text = AtomicString(source_text); |
} |
- return source_text_; |
-} |
+ script_data_ = new ScriptResourceData(Url(), GetResponse(), ErrorOccurred(), |
+ atomic_source_text, CacheHandler(), |
+ GetStoredCredentials()); |
-void ScriptResource::DestroyDecodedDataForFailedRevalidation() { |
- source_text_ = AtomicString(); |
+ return script_data_; |
} |
-// static |
-bool ScriptResource::MimeTypeAllowedByNosniff( |
- const ResourceResponse& response) { |
- return ParseContentTypeOptionsHeader( |
- response.HttpHeaderField(HTTPNames::X_Content_Type_Options)) != |
- kContentTypeOptionsNosniff || |
- MIMETypeRegistry::IsSupportedJavaScriptMIMEType( |
- response.HttpContentType()); |
+void ScriptResource::DestroyDecodedDataForFailedRevalidation() { |
+ script_data_ = nullptr; |
} |
-AccessControlStatus ScriptResource::CalculateAccessControlStatus( |
- const SecurityOrigin* security_origin) const { |
- if (GetResponse().WasFetchedViaServiceWorker()) { |
- if (GetResponse().ServiceWorkerResponseType() == |
- kWebServiceWorkerResponseTypeOpaque) { |
- return kOpaqueResource; |
- } |
- |
- return kSharableCrossOrigin; |
- } |
- |
- if (CrossOriginAccessControl::CheckAccess( |
- GetResponse(), GetStoredCredentials(), security_origin) == |
- CrossOriginAccessControl::kAccessAllowed) { |
- return kSharableCrossOrigin; |
- } |
- |
- return kNotSharableCrossOrigin; |
+DEFINE_TRACE(ScriptResource) { |
+ visitor->Trace(script_data_); |
+ TextResource::Trace(visitor); |
} |
} // namespace blink |