2 * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved.
3 * Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
4 * Copyright (C) 2008 Google, Inc.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
16 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
19 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
23 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 #ifndef ResourceRequest_h
29 #define ResourceRequest_h
31 #include "ResourceRequestBase.h"
33 #include <wtf/PassRefPtr.h>
34 #include <wtf/RefCounted.h>
40 class ResourceRequest : public ResourceRequestBase {
42 // The type of this ResourceRequest, based on how the resource will be used.
46 TargetIsSubresource, // Resource is a generic subresource. (Generally a specific type should be specified)
63 class ExtraData : public RefCounted<ExtraData> {
65 virtual ~ExtraData() { }
68 ResourceRequest(const String& url)
69 : ResourceRequestBase(KURL(ParsedURLString, url), UseProtocolCachePolicy)
71 , m_requestorProcessID(0)
73 , m_hasUserGesture(false)
74 , m_downloadToFile(false)
75 , m_targetType(TargetIsUnspecified)
79 ResourceRequest(const KURL& url)
80 : ResourceRequestBase(url, UseProtocolCachePolicy)
82 , m_requestorProcessID(0)
84 , m_hasUserGesture(false)
85 , m_downloadToFile(false)
86 , m_targetType(TargetIsUnspecified)
90 ResourceRequest(const KURL& url, const String& referrer, ResourceRequestCachePolicy policy = UseProtocolCachePolicy)
91 : ResourceRequestBase(url, policy)
93 , m_requestorProcessID(0)
95 , m_hasUserGesture(false)
96 , m_downloadToFile(false)
97 , m_targetType(TargetIsUnspecified)
99 setHTTPReferrer(referrer);
103 : ResourceRequestBase(KURL(), UseProtocolCachePolicy)
105 , m_requestorProcessID(0)
106 , m_appCacheHostID(0)
107 , m_hasUserGesture(false)
108 , m_downloadToFile(false)
109 , m_targetType(TargetIsUnspecified)
113 // Allows the request to be matched up with its requestor.
114 int requestorID() const { return m_requestorID; }
115 void setRequestorID(int requestorID) { m_requestorID = requestorID; }
117 // The process id of the process from which this request originated. In
118 // the case of out-of-process plugins, this allows to link back the
119 // request to the plugin process (as it is processed through a render
121 int requestorProcessID() const { return m_requestorProcessID; }
122 void setRequestorProcessID(int requestorProcessID) { m_requestorProcessID = requestorProcessID; }
124 // Allows the request to be matched up with its app cache host.
125 int appCacheHostID() const { return m_appCacheHostID; }
126 void setAppCacheHostID(int id) { m_appCacheHostID = id; }
128 // True if request was user initiated.
129 bool hasUserGesture() const { return m_hasUserGesture; }
130 void setHasUserGesture(bool hasUserGesture) { m_hasUserGesture = hasUserGesture; }
132 // True if request should be downloaded to file.
133 bool downloadToFile() const { return m_downloadToFile; }
134 void setDownloadToFile(bool downloadToFile) { m_downloadToFile = downloadToFile; }
136 // Extra data associated with this request.
137 ExtraData* extraData() const { return m_extraData.get(); }
138 void setExtraData(PassRefPtr<ExtraData> extraData) { m_extraData = extraData; }
140 // What this request is for.
141 TargetType targetType() const { return m_targetType; }
142 void setTargetType(TargetType type) { m_targetType = type; }
145 friend class ResourceRequestBase;
147 void doUpdatePlatformRequest() {}
148 void doUpdateResourceRequest() {}
150 PassOwnPtr<CrossThreadResourceRequestData> doPlatformCopyData(PassOwnPtr<CrossThreadResourceRequestData>) const;
151 void doPlatformAdopt(PassOwnPtr<CrossThreadResourceRequestData>);
154 int m_requestorProcessID;
155 int m_appCacheHostID;
156 bool m_hasUserGesture;
157 bool m_downloadToFile;
158 RefPtr<ExtraData> m_extraData;
159 TargetType m_targetType;
162 struct CrossThreadResourceRequestData : public CrossThreadResourceRequestDataBase {
164 int m_requestorProcessID;
165 int m_appCacheHostID;
166 bool m_hasUserGesture;
167 bool m_downloadToFile;
168 ResourceRequest::TargetType m_targetType;
171 } // namespace WebCore