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. |
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 | 22 |
23 #ifndef RawResource_h | 23 #ifndef RawResource_h |
24 #define RawResource_h | 24 #define RawResource_h |
25 | 25 |
26 #include "core/fetch/ResourceClient.h" | 26 #include "core/fetch/ResourceClient.h" |
27 #include "core/fetch/ResourcePtr.h" | 27 #include "core/fetch/ResourcePtr.h" |
| 28 #include "public/platform/WebDataConsumerHandle.h" |
| 29 #include "wtf/PassOwnPtr.h" |
28 | 30 |
29 namespace blink { | 31 namespace blink { |
30 class RawResourceClient; | 32 class RawResourceClient; |
31 | 33 |
32 class RawResource final : public Resource { | 34 class RawResource final : public Resource { |
33 public: | 35 public: |
34 typedef RawResourceClient ClientType; | 36 typedef RawResourceClient ClientType; |
35 | 37 |
36 RawResource(const ResourceRequest&, Type); | 38 RawResource(const ResourceRequest&, Type); |
37 | 39 |
38 // FIXME: AssociatedURLLoader shouldn't be a DocumentThreadableLoader and th
erefore shouldn't | 40 // FIXME: AssociatedURLLoader shouldn't be a DocumentThreadableLoader and th
erefore shouldn't |
39 // use RawResource. However, it is, and it needs to be able to defer loading
. | 41 // use RawResource. However, it is, and it needs to be able to defer loading
. |
40 // This can be fixed by splitting CORS preflighting out of DocumentThreacabl
eLoader. | 42 // This can be fixed by splitting CORS preflighting out of DocumentThreacabl
eLoader. |
41 void setDefersLoading(bool); | 43 void setDefersLoading(bool); |
42 | 44 |
43 bool canReuse(const ResourceRequest&) const override; | 45 bool canReuse(const ResourceRequest&) const override; |
44 | 46 |
45 private: | 47 private: |
46 void didAddClient(ResourceClient*) override; | 48 void didAddClient(ResourceClient*) override; |
47 void appendData(const char*, unsigned) override; | 49 void appendData(const char*, unsigned) override; |
48 | 50 |
49 bool shouldIgnoreHTTPStatusCodeErrors() const override { return true; } | 51 bool shouldIgnoreHTTPStatusCodeErrors() const override { return true; } |
50 | 52 |
51 void willFollowRedirect(ResourceRequest&, const ResourceResponse&) override; | 53 void willFollowRedirect(ResourceRequest&, const ResourceResponse&) override; |
52 void updateRequest(const ResourceRequest&) override; | 54 void updateRequest(const ResourceRequest&) override; |
53 void responseReceived(const ResourceResponse&) override; | 55 void responseReceived(const ResourceResponse&, PassOwnPtr<WebDataConsumerHan
dle>) override; |
54 void didSendData(unsigned long long bytesSent, unsigned long long totalBytes
ToBeSent) override; | 56 void didSendData(unsigned long long bytesSent, unsigned long long totalBytes
ToBeSent) override; |
55 void didDownloadData(int) override; | 57 void didDownloadData(int) override; |
56 }; | 58 }; |
57 | 59 |
58 #if ENABLE(SECURITY_ASSERT) | 60 #if ENABLE(SECURITY_ASSERT) |
59 inline bool isRawResource(const Resource& resource) | 61 inline bool isRawResource(const Resource& resource) |
60 { | 62 { |
61 Resource::Type type = resource.type(); | 63 Resource::Type type = resource.type(); |
62 return type == Resource::MainResource || type == Resource::Raw || type == Re
source::TextTrack || type == Resource::Media || type == Resource::ImportResource
; | 64 return type == Resource::MainResource || type == Resource::Raw || type == Re
source::TextTrack || type == Resource::Media || type == Resource::ImportResource
; |
63 } | 65 } |
64 #endif | 66 #endif |
65 inline RawResource* toRawResource(const ResourcePtr<Resource>& resource) | 67 inline RawResource* toRawResource(const ResourcePtr<Resource>& resource) |
66 { | 68 { |
67 ASSERT_WITH_SECURITY_IMPLICATION(!resource || isRawResource(*resource.get())
); | 69 ASSERT_WITH_SECURITY_IMPLICATION(!resource || isRawResource(*resource.get())
); |
68 return static_cast<RawResource*>(resource.get()); | 70 return static_cast<RawResource*>(resource.get()); |
69 } | 71 } |
70 | 72 |
71 class RawResourceClient : public ResourceClient { | 73 class RawResourceClient : public ResourceClient { |
72 public: | 74 public: |
73 virtual ~RawResourceClient() { } | 75 virtual ~RawResourceClient() { } |
74 static ResourceClientType expectedType() { return RawResourceType; } | 76 static ResourceClientType expectedType() { return RawResourceType; } |
75 virtual ResourceClientType resourceClientType() const override final { retur
n expectedType(); } | 77 virtual ResourceClientType resourceClientType() const override final { retur
n expectedType(); } |
76 | 78 |
77 virtual void dataSent(Resource*, unsigned long long /* bytesSent */, unsigne
d long long /* totalBytesToBeSent */) { } | 79 virtual void dataSent(Resource*, unsigned long long /* bytesSent */, unsigne
d long long /* totalBytesToBeSent */) { } |
78 virtual void responseReceived(Resource*, const ResourceResponse&) { } | 80 virtual void responseReceived(Resource*, const ResourceResponse&, PassOwnPtr
<WebDataConsumerHandle>) { } |
79 virtual void dataReceived(Resource*, const char* /* data */, unsigned /* len
gth */) { } | 81 virtual void dataReceived(Resource*, const char* /* data */, unsigned /* len
gth */) { } |
80 virtual void redirectReceived(Resource*, ResourceRequest&, const ResourceRes
ponse&) { } | 82 virtual void redirectReceived(Resource*, ResourceRequest&, const ResourceRes
ponse&) { } |
81 virtual void updateRequest(Resource*, const ResourceRequest&) { } | 83 virtual void updateRequest(Resource*, const ResourceRequest&) { } |
82 virtual void dataDownloaded(Resource*, int) { } | 84 virtual void dataDownloaded(Resource*, int) { } |
83 }; | 85 }; |
84 | 86 |
85 } | 87 } |
86 | 88 |
87 #endif // RawResource_h | 89 #endif // RawResource_h |
OLD | NEW |