1/* 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. 6 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. 11 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. 16 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. 21*/ 22 23#ifndef CachedRawResource_h 24#define CachedRawResource_h 25 26#include "CachedResource.h" 27 28namespace WebCore { 29 30class CachedResourceClient; 31class SubresourceLoader; 32 33class CachedRawResource final : public CachedResource { 34public: 35 CachedRawResource(ResourceRequest&, Type, SessionID); 36 37 // FIXME: AssociatedURLLoader shouldn't be a DocumentThreadableLoader and therefore shouldn't 38 // use CachedRawResource. However, it is, and it needs to be able to defer loading. 39 // This can be fixed by splitting CORS preflighting out of DocumentThreacableLoader. 40 virtual void setDefersLoading(bool); 41 42 virtual void setDataBufferingPolicy(DataBufferingPolicy); 43 44 // FIXME: This is exposed for the InpsectorInstrumentation for preflights in DocumentThreadableLoader. It's also really lame. 45 unsigned long identifier() const { return m_identifier; } 46 47 void clear(); 48 49private: 50 virtual void didAddClient(CachedResourceClient*) override; 51 virtual void addDataBuffer(ResourceBuffer*) override; 52 virtual void addData(const char* data, unsigned length) override; 53 virtual void finishLoading(ResourceBuffer*) override; 54 55 virtual bool shouldIgnoreHTTPStatusCodeErrors() const override { return true; } 56 virtual void allClientsRemoved() override; 57 58 virtual void willSendRequest(ResourceRequest&, const ResourceResponse&) override; 59 virtual void responseReceived(const ResourceResponse&) override; 60 virtual void didSendData(unsigned long long bytesSent, unsigned long long totalBytesToBeSent) override; 61 62 virtual void switchClientsToRevalidatedResource() override; 63 virtual bool mayTryReplaceEncodedData() const override { return true; } 64 65 virtual bool canReuse(const ResourceRequest&) const override; 66 67 const char* calculateIncrementalDataChunk(ResourceBuffer*, unsigned& incrementalDataLength); 68 void notifyClientsDataWasReceived(const char* data, unsigned length); 69 70#if USE(SOUP) 71 virtual char* getOrCreateReadBuffer(size_t requestedSize, size_t& actualSize); 72#endif 73 74 unsigned long m_identifier; 75 76 struct RedirectPair { 77 public: 78 explicit RedirectPair(const ResourceRequest& request, const ResourceResponse& redirectResponse) 79 : m_request(request) 80 , m_redirectResponse(redirectResponse) 81 { 82 } 83 84 const ResourceRequest m_request; 85 const ResourceResponse m_redirectResponse; 86 }; 87 88 Vector<RedirectPair> m_redirectChain; 89}; 90 91TYPE_CASTS_BASE(CachedRawResource, CachedResource, resource, resource->isMainOrRawResource(), resource.isMainOrRawResource()) 92 93} 94 95#endif // CachedRawResource_h 96