2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de)
3 Copyright (C) 2001 Dirk Mueller <mueller@kde.org>
4 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
5 Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version.
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details.
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
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA.
26 #include "core/fetch/ResourceClient.h"
27 #include "core/fetch/ResourcePtr.h"
30 class RawResourceCallback;
31 class RawResourceClient;
33 class RawResource FINAL : public Resource {
35 typedef RawResourceClient ClientType;
37 RawResource(const ResourceRequest&, Type);
39 // FIXME: AssociatedURLLoader shouldn't be a DocumentThreadableLoader and therefore shouldn't
40 // use RawResource. However, it is, and it needs to be able to defer loading.
41 // This can be fixed by splitting CORS preflighting out of DocumentThreacableLoader.
42 void setDefersLoading(bool);
44 virtual bool canReuse(const ResourceRequest&) const OVERRIDE;
47 virtual void didAddClient(ResourceClient*) OVERRIDE;
48 virtual void appendData(const char*, int) OVERRIDE;
50 virtual bool shouldIgnoreHTTPStatusCodeErrors() const OVERRIDE { return true; }
52 virtual void willSendRequest(ResourceRequest&, const ResourceResponse&) OVERRIDE;
53 virtual void updateRequest(const ResourceRequest&) OVERRIDE;
54 virtual void responseReceived(const ResourceResponse&) OVERRIDE;
55 virtual void didSendData(unsigned long long bytesSent, unsigned long long totalBytesToBeSent) OVERRIDE;
56 virtual void didDownloadData(int) OVERRIDE;
59 #ifdef SECURITY_ASSERT_ENABLED
60 inline bool isRawResource(const Resource& resource)
62 Resource::Type type = resource.type();
63 return type == Resource::MainResource || type == Resource::Raw || type == Resource::TextTrack || type == Resource::ImportResource;
66 inline RawResource* toRawResource(const ResourcePtr<Resource>& resource)
68 ASSERT_WITH_SECURITY_IMPLICATION(!resource || isRawResource(*resource.get()));
69 return static_cast<RawResource*>(resource.get());
72 class RawResourceClient : public ResourceClient {
74 virtual ~RawResourceClient() { }
75 static ResourceClientType expectedType() { return RawResourceType; }
76 virtual ResourceClientType resourceClientType() const OVERRIDE FINAL { return expectedType(); }
78 virtual void dataSent(Resource*, unsigned long long /* bytesSent */, unsigned long long /* totalBytesToBeSent */) { }
79 virtual void responseReceived(Resource*, const ResourceResponse&) { }
80 virtual void dataReceived(Resource*, const char* /* data */, int /* length */) { }
81 virtual void redirectReceived(Resource*, ResourceRequest&, const ResourceResponse&) { }
82 virtual void updateRequest(Resource*, const ResourceRequest&) { }
83 virtual void dataDownloaded(Resource*, int) { }
88 #endif // RawResource_h