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

Side by Side Diff: third_party/WebKit/Source/core/loader/resource/ScriptResource.h

Issue 2724673002: [WIP] Introduce ScriptResourceData
Patch Set: Fix Created 3 years, 7 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
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) 2006 Samuel Weinig (sam.weinig@gmail.com) 4 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
5 Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 5 Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
6 6
7 This library is free software; you can redistribute it and/or 7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public 8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either 9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version. 10 version 2 of the License, or (at your option) any later version.
11 11
12 This library is distributed in the hope that it will be useful, 12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details. 15 Library General Public License for more details.
16 16
17 You should have received a copy of the GNU Library General Public License 17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to 18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA. 20 Boston, MA 02110-1301, USA.
21 21
22 This class provides all functionality needed for loading images, style 22 This class provides all functionality needed for loading images, style
23 sheets and html pages from the web. It has a memory cache for these objects. 23 sheets and html pages from the web. It has a memory cache for these objects.
24 */ 24 */
25 25
26 #ifndef ScriptResource_h 26 #ifndef ScriptResource_h
27 #define ScriptResource_h 27 #define ScriptResource_h
28 28
29 #include "core/CoreExport.h" 29 #include "core/CoreExport.h"
30 #include "core/loader/resource/ScriptResourceData.h"
30 #include "core/loader/resource/TextResource.h" 31 #include "core/loader/resource/TextResource.h"
31 #include "platform/loader/fetch/AccessControlStatus.h"
32 #include "platform/loader/fetch/IntegrityMetadata.h" 32 #include "platform/loader/fetch/IntegrityMetadata.h"
33 #include "platform/loader/fetch/ResourceClient.h" 33 #include "platform/loader/fetch/ResourceClient.h"
34 34
35 namespace blink { 35 namespace blink {
36 36
37 enum class ScriptIntegrityDisposition { kNotChecked = 0, kFailed, kPassed }; 37 enum class ScriptIntegrityDisposition { kNotChecked = 0, kFailed, kPassed };
38 38
39 class FetchParameters; 39 class FetchParameters;
40 class ResourceFetcher; 40 class ResourceFetcher;
41 class ScriptResource; 41 class ScriptResource;
(...skipping 15 matching lines...) Expand all
57 static ScriptResource* Fetch(FetchParameters&, ResourceFetcher*); 57 static ScriptResource* Fetch(FetchParameters&, ResourceFetcher*);
58 58
59 // Public for testing 59 // Public for testing
60 static ScriptResource* Create(const ResourceRequest& request, 60 static ScriptResource* Create(const ResourceRequest& request,
61 const String& charset) { 61 const String& charset) {
62 return new ScriptResource(request, ResourceLoaderOptions(), charset); 62 return new ScriptResource(request, ResourceLoaderOptions(), charset);
63 } 63 }
64 64
65 ~ScriptResource() override; 65 ~ScriptResource() override;
66 66
67 DECLARE_VIRTUAL_TRACE();
68
69 const ScriptResourceData* ResourceData();
70
71 void AppendData(const char*, size_t) override;
72
73 private:
67 void DidAddClient(ResourceClient*) override; 74 void DidAddClient(ResourceClient*) override;
68 void AppendData(const char*, size_t) override;
69 75
70 void OnMemoryDump(WebMemoryDumpLevelOfDetail, 76 void OnMemoryDump(WebMemoryDumpLevelOfDetail,
71 WebProcessMemoryDump*) const override; 77 WebProcessMemoryDump*) const override;
72 78
73 void DestroyDecodedDataForFailedRevalidation() override; 79 void DestroyDecodedDataForFailedRevalidation() override;
74 80
75 const String& SourceText();
76
77 static bool MimeTypeAllowedByNosniff(const ResourceResponse&);
78
79 AccessControlStatus CalculateAccessControlStatus(const SecurityOrigin*) const;
80
81 private:
82 class ScriptResourceFactory : public ResourceFactory { 81 class ScriptResourceFactory : public ResourceFactory {
83 public: 82 public:
84 ScriptResourceFactory() : ResourceFactory(Resource::kScript) {} 83 ScriptResourceFactory() : ResourceFactory(Resource::kScript) {}
85 84
86 Resource* Create(const ResourceRequest& request, 85 Resource* Create(const ResourceRequest& request,
87 const ResourceLoaderOptions& options, 86 const ResourceLoaderOptions& options,
88 const String& charset) const override { 87 const String& charset) const override {
89 return new ScriptResource(request, options, charset); 88 return new ScriptResource(request, options, charset);
90 } 89 }
91 }; 90 };
92 91
93 ScriptResource(const ResourceRequest&, 92 ScriptResource(const ResourceRequest&,
94 const ResourceLoaderOptions&, 93 const ResourceLoaderOptions&,
95 const String& charset); 94 const String& charset);
96 95
97 AtomicString source_text_; 96 Member<ScriptResourceData> script_data_;
98 }; 97 };
99 98
100 DEFINE_RESOURCE_TYPE_CASTS(Script); 99 DEFINE_RESOURCE_TYPE_CASTS(Script);
101 100
102 } // namespace blink 101 } // namespace blink
103 102
104 #endif 103 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698