| 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 21 matching lines...) Expand all Loading... |
| 32 namespace blink { | 32 namespace blink { |
| 33 class FetchRequest; | 33 class FetchRequest; |
| 34 class RawResourceClient; | 34 class RawResourceClient; |
| 35 class ResourceFetcher; | 35 class ResourceFetcher; |
| 36 class SubstituteData; | 36 class SubstituteData; |
| 37 | 37 |
| 38 class CORE_EXPORT RawResource final : public Resource { | 38 class CORE_EXPORT RawResource final : public Resource { |
| 39 public: | 39 public: |
| 40 using ClientType = RawResourceClient; | 40 using ClientType = RawResourceClient; |
| 41 | 41 |
| 42 static PassRefPtrWillBeRawPtr<Resource> fetchSynchronously(FetchRequest&, Re
sourceFetcher*); | 42 static RawPtr<Resource> fetchSynchronously(FetchRequest&, ResourceFetcher*); |
| 43 static PassRefPtrWillBeRawPtr<RawResource> fetch(FetchRequest&, ResourceFetc
her*); | 43 static RawPtr<RawResource> fetch(FetchRequest&, ResourceFetcher*); |
| 44 static PassRefPtrWillBeRawPtr<RawResource> fetchMainResource(FetchRequest&,
ResourceFetcher*, const SubstituteData&); | 44 static RawPtr<RawResource> fetchMainResource(FetchRequest&, ResourceFetcher*
, const SubstituteData&); |
| 45 static PassRefPtrWillBeRawPtr<RawResource> fetchImport(FetchRequest&, Resour
ceFetcher*); | 45 static RawPtr<RawResource> fetchImport(FetchRequest&, ResourceFetcher*); |
| 46 static PassRefPtrWillBeRawPtr<RawResource> fetchMedia(FetchRequest&, Resourc
eFetcher*); | 46 static RawPtr<RawResource> fetchMedia(FetchRequest&, ResourceFetcher*); |
| 47 static PassRefPtrWillBeRawPtr<RawResource> fetchTextTrack(FetchRequest&, Res
ourceFetcher*); | 47 static RawPtr<RawResource> fetchTextTrack(FetchRequest&, ResourceFetcher*); |
| 48 static PassRefPtrWillBeRawPtr<RawResource> fetchManifest(FetchRequest&, Reso
urceFetcher*); | 48 static RawPtr<RawResource> fetchManifest(FetchRequest&, ResourceFetcher*); |
| 49 | 49 |
| 50 // Exposed for testing | 50 // Exposed for testing |
| 51 static RefPtrWillBeRawPtr<RawResource> create(const ResourceRequest& request
, Type type) | 51 static RawPtr<RawResource> create(const ResourceRequest& request, Type type) |
| 52 { | 52 { |
| 53 return adoptRefWillBeNoop(new RawResource(request, type)); | 53 return (new RawResource(request, type)); |
| 54 } | 54 } |
| 55 | 55 |
| 56 // FIXME: AssociatedURLLoader shouldn't be a DocumentThreadableLoader and th
erefore shouldn't | 56 // FIXME: AssociatedURLLoader shouldn't be a DocumentThreadableLoader and th
erefore shouldn't |
| 57 // use RawResource. However, it is, and it needs to be able to defer loading
. | 57 // use RawResource. However, it is, and it needs to be able to defer loading
. |
| 58 // This can be fixed by splitting CORS preflighting out of DocumentThreacabl
eLoader. | 58 // This can be fixed by splitting CORS preflighting out of DocumentThreacabl
eLoader. |
| 59 void setDefersLoading(bool); | 59 void setDefersLoading(bool); |
| 60 | 60 |
| 61 bool canReuse(const ResourceRequest&) const override; | 61 bool canReuse(const ResourceRequest&) const override; |
| 62 | 62 |
| 63 private: | 63 private: |
| 64 class RawResourceFactory : public ResourceFactory { | 64 class RawResourceFactory : public ResourceFactory { |
| 65 public: | 65 public: |
| 66 RawResourceFactory(Resource::Type type) | 66 RawResourceFactory(Resource::Type type) |
| 67 : ResourceFactory(type) { } | 67 : ResourceFactory(type) { } |
| 68 | 68 |
| 69 PassRefPtrWillBeRawPtr<Resource> create(const ResourceRequest& request,
const String& charset) const override | 69 RawPtr<Resource> create(const ResourceRequest& request, const String& ch
arset) const override |
| 70 { | 70 { |
| 71 return adoptRefWillBeNoop(new RawResource(request, m_type)); | 71 return (new RawResource(request, m_type)); |
| 72 } | 72 } |
| 73 }; | 73 }; |
| 74 | 74 |
| 75 RawResource(const ResourceRequest&, Type); | 75 RawResource(const ResourceRequest&, Type); |
| 76 | 76 |
| 77 void didAddClient(ResourceClient*) override; | 77 void didAddClient(ResourceClient*) override; |
| 78 void appendData(const char*, size_t) override; | 78 void appendData(const char*, size_t) override; |
| 79 | 79 |
| 80 bool shouldIgnoreHTTPStatusCodeErrors() const override { return !isLinkPrelo
ad(); } | 80 bool shouldIgnoreHTTPStatusCodeErrors() const override { return !isLinkPrelo
ad(); } |
| 81 | 81 |
| 82 void willFollowRedirect(ResourceRequest&, const ResourceResponse&) override; | 82 void willFollowRedirect(ResourceRequest&, const ResourceResponse&) override; |
| 83 void updateRequest(const ResourceRequest&) override; | 83 void updateRequest(const ResourceRequest&) override; |
| 84 void responseReceived(const ResourceResponse&, PassOwnPtr<WebDataConsumerHan
dle>) override; | 84 void responseReceived(const ResourceResponse&, PassOwnPtr<WebDataConsumerHan
dle>) override; |
| 85 void setSerializedCachedMetadata(const char*, size_t) override; | 85 void setSerializedCachedMetadata(const char*, size_t) override; |
| 86 void didSendData(unsigned long long bytesSent, unsigned long long totalBytes
ToBeSent) override; | 86 void didSendData(unsigned long long bytesSent, unsigned long long totalBytes
ToBeSent) override; |
| 87 void didDownloadData(int) override; | 87 void didDownloadData(int) override; |
| 88 void reportResourceTimingToClients(const ResourceTimingInfo&) override; | 88 void reportResourceTimingToClients(const ResourceTimingInfo&) override; |
| 89 }; | 89 }; |
| 90 | 90 |
| 91 #if ENABLE(SECURITY_ASSERT) | 91 #if ENABLE(SECURITY_ASSERT) |
| 92 inline bool isRawResource(const Resource& resource) | 92 inline bool isRawResource(const Resource& resource) |
| 93 { | 93 { |
| 94 Resource::Type type = resource.type(); | 94 Resource::Type type = resource.type(); |
| 95 return type == Resource::MainResource || type == Resource::Raw || type == Re
source::TextTrack || type == Resource::Media || type == Resource::Manifest || ty
pe == Resource::ImportResource; | 95 return type == Resource::MainResource || type == Resource::Raw || type == Re
source::TextTrack || type == Resource::Media || type == Resource::Manifest || ty
pe == Resource::ImportResource; |
| 96 } | 96 } |
| 97 #endif | 97 #endif |
| 98 inline PassRefPtrWillBeRawPtr<RawResource> toRawResource(const PassRefPtrWillBeR
awPtr<Resource>& resource) | 98 inline RawPtr<RawResource> toRawResource(const RawPtr<Resource>& resource) |
| 99 { | 99 { |
| 100 ASSERT_WITH_SECURITY_IMPLICATION(!resource || isRawResource(*resource.get())
); | 100 ASSERT_WITH_SECURITY_IMPLICATION(!resource || isRawResource(*resource.get())
); |
| 101 return static_cast<RawResource*>(resource.get()); | 101 return static_cast<RawResource*>(resource.get()); |
| 102 } | 102 } |
| 103 | 103 |
| 104 class CORE_EXPORT RawResourceClient : public ResourceClient { | 104 class CORE_EXPORT RawResourceClient : public ResourceClient { |
| 105 public: | 105 public: |
| 106 ~RawResourceClient() override {} | 106 ~RawResourceClient() override {} |
| 107 static ResourceClientType expectedType() { return RawResourceType; } | 107 static ResourceClientType expectedType() { return RawResourceType; } |
| 108 ResourceClientType resourceClientType() const final { return expectedType();
} | 108 ResourceClientType resourceClientType() const final { return expectedType();
} |
| 109 | 109 |
| 110 virtual void dataSent(Resource*, unsigned long long /* bytesSent */, unsigne
d long long /* totalBytesToBeSent */) { } | 110 virtual void dataSent(Resource*, unsigned long long /* bytesSent */, unsigne
d long long /* totalBytesToBeSent */) { } |
| 111 virtual void responseReceived(Resource*, const ResourceResponse&, PassOwnPtr
<WebDataConsumerHandle>) { } | 111 virtual void responseReceived(Resource*, const ResourceResponse&, PassOwnPtr
<WebDataConsumerHandle>) { } |
| 112 virtual void setSerializedCachedMetadata(Resource*, const char*, size_t) { } | 112 virtual void setSerializedCachedMetadata(Resource*, const char*, size_t) { } |
| 113 virtual void dataReceived(Resource*, const char* /* data */, size_t /* lengt
h */) { } | 113 virtual void dataReceived(Resource*, const char* /* data */, size_t /* lengt
h */) { } |
| 114 virtual void redirectReceived(Resource*, ResourceRequest&, const ResourceRes
ponse&) { } | 114 virtual void redirectReceived(Resource*, ResourceRequest&, const ResourceRes
ponse&) { } |
| 115 virtual void updateRequest(Resource*, const ResourceRequest&) { } | 115 virtual void updateRequest(Resource*, const ResourceRequest&) { } |
| 116 virtual void dataDownloaded(Resource*, int) { } | 116 virtual void dataDownloaded(Resource*, int) { } |
| 117 virtual void didReceiveResourceTiming(Resource*, const ResourceTimingInfo&)
{ } | 117 virtual void didReceiveResourceTiming(Resource*, const ResourceTimingInfo&)
{ } |
| 118 }; | 118 }; |
| 119 | 119 |
| 120 } // namespace blink | 120 } // namespace blink |
| 121 | 121 |
| 122 #endif // RawResource_h | 122 #endif // RawResource_h |
| OLD | NEW |