Index: third_party/WebKit/Source/core/loader/resource/ScriptResourceData.cpp |
diff --git a/third_party/WebKit/Source/core/loader/resource/ScriptResource.cpp b/third_party/WebKit/Source/core/loader/resource/ScriptResourceData.cpp |
similarity index 19% |
copy from third_party/WebKit/Source/core/loader/resource/ScriptResource.cpp |
copy to third_party/WebKit/Source/core/loader/resource/ScriptResourceData.cpp |
index dffe750fdb74e2e7e85858b53c75793f43dcb2a6..cfca812776db93a41c1e79c070593aac362516d9 100644 |
--- a/third_party/WebKit/Source/core/loader/resource/ScriptResource.cpp |
+++ b/third_party/WebKit/Source/core/loader/resource/ScriptResourceData.cpp |
@@ -1,107 +1,17 @@ |
-/* |
- Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) |
- Copyright (C) 2001 Dirk Mueller (mueller@kde.org) |
- Copyright (C) 2002 Waldo Bastian (bastian@kde.org) |
- Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) |
- Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. |
+// Copyright 2017 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
- This library is free software; you can redistribute it and/or |
- modify it under the terms of the GNU Library General Public |
- License as published by the Free Software Foundation; either |
- version 2 of the License, or (at your option) any later version. |
+#include "core/loader/resource/ScriptResourceData.h" |
- This library is distributed in the hope that it will be useful, |
- but WITHOUT ANY WARRANTY; without even the implied warranty of |
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
- Library General Public License for more details. |
- |
- You should have received a copy of the GNU Library General Public License |
- along with this library; see the file COPYING.LIB. If not, write to |
- the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
- Boston, MA 02110-1301, USA. |
- |
- This class provides all functionality needed for loading images, style |
- sheets and html pages from the web. It has a memory cache for these objects. |
-*/ |
- |
-#include "core/loader/resource/ScriptResource.h" |
- |
-#include "platform/SharedBuffer.h" |
-#include "platform/instrumentation/tracing/web_memory_allocator_dump.h" |
-#include "platform/instrumentation/tracing/web_process_memory_dump.h" |
+#include "platform/HTTPNames.h" |
#include "platform/loader/fetch/CrossOriginAccessControl.h" |
-#include "platform/loader/fetch/FetchParameters.h" |
-#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 { |
-ScriptResource* ScriptResource::Fetch(FetchParameters& params, |
- ResourceFetcher* fetcher) { |
- DCHECK_EQ(params.GetResourceRequest().GetFrameType(), |
- WebURLRequest::kFrameTypeNone); |
- params.SetRequestContext(WebURLRequest::kRequestContextScript); |
- ScriptResource* resource = ToScriptResource( |
- fetcher->RequestResource(params, ScriptResourceFactory())); |
- if (resource && !params.IntegrityMetadata().IsEmpty()) |
- resource->SetIntegrityMetadata(params.IntegrityMetadata()); |
- return resource; |
-} |
- |
-ScriptResource::ScriptResource(const ResourceRequest& resource_request, |
- const ResourceLoaderOptions& options, |
- const String& charset) |
- : TextResource(resource_request, |
- kScript, |
- options, |
- "application/javascript", |
- charset) {} |
- |
-ScriptResource::~ScriptResource() {} |
- |
-void ScriptResource::DidAddClient(ResourceClient* client) { |
- DCHECK(ScriptResourceClient::IsExpectedType(client)); |
- Resource::DidAddClient(client); |
-} |
- |
-void ScriptResource::AppendData(const char* data, size_t length) { |
- Resource::AppendData(data, length); |
- ResourceClientWalker<ScriptResourceClient> walker(Clients()); |
- while (ScriptResourceClient* client = walker.Next()) |
- client->NotifyAppendData(this); |
-} |
- |
-void ScriptResource::OnMemoryDump(WebMemoryDumpLevelOfDetail level_of_detail, |
- WebProcessMemoryDump* memory_dump) const { |
- 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()); |
- memory_dump->AddSuballocation( |
- dump->Guid(), String(WTF::Partitions::kAllocatedObjectPoolName)); |
-} |
- |
-const String& ScriptResource::SourceText() { |
- DCHECK(IsLoaded()); |
- |
- if (source_text_.IsNull() && Data()) { |
- String source_text = DecodedText(); |
- ClearData(); |
- SetDecodedSize(source_text.CharactersSizeInBytes()); |
- source_text_ = AtomicString(source_text); |
- } |
- |
- return source_text_; |
-} |
- |
-void ScriptResource::DestroyDecodedDataForFailedRevalidation() { |
- source_text_ = AtomicString(); |
-} |
- |
// static |
-bool ScriptResource::MimeTypeAllowedByNosniff( |
+bool ScriptResourceData::MimeTypeAllowedByNosniff( |
const ResourceResponse& response) { |
return ParseContentTypeOptionsHeader( |
response.HttpHeaderField(HTTPNames::X_Content_Type_Options)) != |
@@ -110,7 +20,7 @@ bool ScriptResource::MimeTypeAllowedByNosniff( |
response.HttpContentType()); |
} |
-AccessControlStatus ScriptResource::CalculateAccessControlStatus( |
+AccessControlStatus ScriptResourceData::CalculateAccessControlStatus( |
const SecurityOrigin* security_origin) const { |
if (GetResponse().WasFetchedViaServiceWorker()) { |
if (GetResponse().ServiceWorkerResponseType() == |