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) 2006 Samuel Weinig (sam.weinig@gmail.com) | 4 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) |
5 Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. | 5 Copyright (C) 2004, 2005, 2006, 2007 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. |
(...skipping 13 matching lines...) Expand all Loading... |
24 #define RawResource_h | 24 #define RawResource_h |
25 | 25 |
26 #include <memory> | 26 #include <memory> |
27 #include "platform/PlatformExport.h" | 27 #include "platform/PlatformExport.h" |
28 #include "platform/loader/fetch/Resource.h" | 28 #include "platform/loader/fetch/Resource.h" |
29 #include "platform/loader/fetch/ResourceClient.h" | 29 #include "platform/loader/fetch/ResourceClient.h" |
30 #include "platform/wtf/WeakPtr.h" | 30 #include "platform/wtf/WeakPtr.h" |
31 #include "public/platform/WebDataConsumerHandle.h" | 31 #include "public/platform/WebDataConsumerHandle.h" |
32 | 32 |
33 namespace blink { | 33 namespace blink { |
| 34 class FetchContext; |
34 class FetchParameters; | 35 class FetchParameters; |
35 class RawResourceClient; | 36 class RawResourceClient; |
36 class ResourceFetcher; | 37 class ResourceFetcher; |
37 class SubstituteData; | 38 class SubstituteData; |
38 | 39 |
39 class PLATFORM_EXPORT RawResource final : public Resource { | 40 class PLATFORM_EXPORT RawResource final : public Resource { |
40 public: | 41 public: |
41 using ClientType = RawResourceClient; | 42 using ClientType = RawResourceClient; |
42 | 43 |
43 static RawResource* FetchSynchronously(FetchParameters&, ResourceFetcher*); | 44 static RawResource* FetchSynchronously(FetchParameters&, ResourceFetcher*); |
44 static RawResource* Fetch(FetchParameters&, ResourceFetcher*); | 45 static RawResource* Fetch(FetchParameters&, ResourceFetcher*); |
45 static RawResource* FetchMainResource(FetchParameters&, | 46 static RawResource* FetchMainResource(FetchParameters&, |
46 ResourceFetcher*, | 47 ResourceFetcher*, |
47 const SubstituteData&); | 48 const SubstituteData&); |
48 static RawResource* FetchImport(FetchParameters&, ResourceFetcher*); | 49 static RawResource* FetchImport(FetchParameters&, ResourceFetcher*); |
49 static RawResource* FetchMedia(FetchParameters&, ResourceFetcher*); | 50 static RawResource* FetchMedia(FetchParameters&, ResourceFetcher*); |
50 static RawResource* FetchTextTrack(FetchParameters&, ResourceFetcher*); | 51 static RawResource* FetchTextTrack(FetchParameters&, ResourceFetcher*); |
51 static RawResource* FetchManifest(FetchParameters&, ResourceFetcher*); | 52 static RawResource* FetchManifest(FetchParameters&, ResourceFetcher*); |
52 | 53 |
53 // Exposed for testing | 54 // Exposed for testing |
54 static RawResource* Create(const ResourceRequest& request, Type type) { | 55 static RawResource* Create(const ResourceRequest& request, Type type) { |
55 return new RawResource(request, type, ResourceLoaderOptions()); | 56 return new RawResource(request, type, ResourceLoaderOptions(), nullptr); |
56 } | 57 } |
57 | 58 |
58 // FIXME: AssociatedURLLoader shouldn't be a DocumentThreadableLoader and | 59 // FIXME: AssociatedURLLoader shouldn't be a DocumentThreadableLoader and |
59 // therefore shouldn't use RawResource. However, it is, and it needs to be | 60 // therefore shouldn't use RawResource. However, it is, and it needs to be |
60 // able to defer loading. This can be fixed by splitting CORS preflighting out | 61 // able to defer loading. This can be fixed by splitting CORS preflighting out |
61 // of DocumentThreadableLoader. | 62 // of DocumentThreadableLoader. |
62 void SetDefersLoading(bool); | 63 void SetDefersLoading(bool); |
63 | 64 |
64 // Resource implementation | 65 // Resource implementation |
65 bool CanReuse(const FetchParameters&) const override; | 66 bool CanReuse(const FetchParameters&) const override; |
66 bool WillFollowRedirect(const ResourceRequest&, | 67 bool WillFollowRedirect(const ResourceRequest&, |
67 const ResourceResponse&) override; | 68 const ResourceResponse&) override; |
68 | 69 |
69 private: | 70 private: |
70 class RawResourceFactory : public ResourceFactory { | 71 class RawResourceFactory : public ResourceFactory { |
71 public: | 72 public: |
72 explicit RawResourceFactory(Resource::Type type) : ResourceFactory(type) {} | 73 explicit RawResourceFactory(Resource::Type type) : ResourceFactory(type) {} |
73 | 74 |
74 Resource* Create(const ResourceRequest& request, | 75 Resource* Create(const ResourceRequest& request, |
75 const ResourceLoaderOptions& options, | 76 const ResourceLoaderOptions& options, |
76 const String& charset) const override { | 77 const String& charset, |
77 return new RawResource(request, type_, options); | 78 FetchContext* fetch_context) const override { |
| 79 return new RawResource(request, type_, options, fetch_context); |
78 } | 80 } |
79 }; | 81 }; |
80 | 82 |
81 RawResource(const ResourceRequest&, Type, const ResourceLoaderOptions&); | 83 RawResource(const ResourceRequest&, |
| 84 Type, |
| 85 const ResourceLoaderOptions&, |
| 86 FetchContext*); |
82 | 87 |
83 // Resource implementation | 88 // Resource implementation |
84 void DidAddClient(ResourceClient*) override; | 89 void DidAddClient(ResourceClient*) override; |
85 void AppendData(const char*, size_t) override; | 90 void AppendData(const char*, size_t) override; |
86 bool ShouldIgnoreHTTPStatusCodeErrors() const override { | 91 bool ShouldIgnoreHTTPStatusCodeErrors() const override { |
87 return !IsLinkPreload(); | 92 return !IsLinkPreload(); |
88 } | 93 } |
89 void WillNotFollowRedirect() override; | 94 void WillNotFollowRedirect() override; |
90 void ResponseReceived(const ResourceResponse&, | 95 void ResponseReceived(const ResourceResponse&, |
91 std::unique_ptr<WebDataConsumerHandle>) override; | 96 std::unique_ptr<WebDataConsumerHandle>) override; |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 kDataReceived, | 192 kDataReceived, |
188 kDataDownloaded, | 193 kDataDownloaded, |
189 kNotifyFinished | 194 kNotifyFinished |
190 }; | 195 }; |
191 State state_; | 196 State state_; |
192 }; | 197 }; |
193 | 198 |
194 } // namespace blink | 199 } // namespace blink |
195 | 200 |
196 #endif // RawResource_h | 201 #endif // RawResource_h |
OLD | NEW |