- add third_party src.
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / fetch / RawResource.h
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 RawResource_h
24 #define RawResource_h
25
26 #include "core/fetch/Resource.h"
27 #include "core/fetch/ResourceClient.h"
28
29 namespace WebCore {
30 class RawResourceCallback;
31 class RawResourceClient;
32
33 class RawResource : public Resource {
34 public:
35     RawResource(const ResourceRequest&, Type);
36
37     // FIXME: AssociatedURLLoader shouldn't be a DocumentThreadableLoader and therefore shouldn't
38     // use RawResource. 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     void clear();
45
46     virtual bool canReuse(const ResourceRequest&) const;
47
48 private:
49     virtual void didAddClient(ResourceClient*);
50     virtual void appendData(const char*, int) OVERRIDE;
51
52     virtual bool shouldIgnoreHTTPStatusCodeErrors() const { return true; }
53
54     virtual void willSendRequest(ResourceRequest&, const ResourceResponse&);
55     virtual void responseReceived(const ResourceResponse&);
56     virtual void didSendData(unsigned long long bytesSent, unsigned long long totalBytesToBeSent);
57     virtual void didDownloadData(int);
58
59     struct RedirectPair {
60     public:
61         explicit RedirectPair(const ResourceRequest& request, const ResourceResponse& redirectResponse)
62             : m_request(request)
63             , m_redirectResponse(redirectResponse)
64         {
65         }
66
67         const ResourceRequest m_request;
68         const ResourceResponse m_redirectResponse;
69     };
70
71     Vector<RedirectPair> m_redirectChain;
72 };
73
74
75 class RawResourceClient : public ResourceClient {
76 public:
77     virtual ~RawResourceClient() { }
78     static ResourceClientType expectedType() { return RawResourceType; }
79     virtual ResourceClientType resourceClientType() const { return expectedType(); }
80
81     virtual void dataSent(Resource*, unsigned long long /* bytesSent */, unsigned long long /* totalBytesToBeSent */) { }
82     virtual void responseReceived(Resource*, const ResourceResponse&) { }
83     virtual void dataReceived(Resource*, const char* /* data */, int /* length */) { }
84     virtual void redirectReceived(Resource*, ResourceRequest&, const ResourceResponse&) { }
85     virtual void dataDownloaded(Resource*, int) { }
86 };
87
88 }
89
90 #endif // RawResource_h