1 /* 2 * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved. 3 * Copyright (C) 2006 Samuel Weinig <sam.weinig (at) gmail.com> 4 * Copyright (C) 2008 Google, Inc. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 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. 14 * 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. 26 */ 27 28 #ifndef ResourceRequest_h 29 #define ResourceRequest_h 30 31 #include "ResourceRequestBase.h" 32 33 namespace WebCore { 34 35 class Frame; 36 37 class ResourceRequest : public ResourceRequestBase { 38 public: 39 ResourceRequest(const String& url) 40 : ResourceRequestBase(KURL(ParsedURLString, url), UseProtocolCachePolicy) 41 , m_requestorID(0) 42 , m_requestorProcessID(0) 43 , m_appCacheHostID(0) 44 , m_hasUserGesture(false) 45 , m_downloadToFile(false) 46 { 47 } 48 49 ResourceRequest(const KURL& url) 50 : ResourceRequestBase(url, UseProtocolCachePolicy) 51 , m_requestorID(0) 52 , m_requestorProcessID(0) 53 , m_appCacheHostID(0) 54 , m_hasUserGesture(false) 55 , m_downloadToFile(false) 56 { 57 } 58 59 ResourceRequest(const KURL& url, const String& referrer, ResourceRequestCachePolicy policy = UseProtocolCachePolicy) 60 : ResourceRequestBase(url, policy) 61 , m_requestorID(0) 62 , m_requestorProcessID(0) 63 , m_appCacheHostID(0) 64 , m_hasUserGesture(false) 65 , m_downloadToFile(false) 66 { 67 setHTTPReferrer(referrer); 68 } 69 70 ResourceRequest() 71 : ResourceRequestBase(KURL(), UseProtocolCachePolicy) 72 , m_requestorID(0) 73 , m_requestorProcessID(0) 74 , m_appCacheHostID(0) 75 , m_hasUserGesture(false) 76 , m_downloadToFile(false) 77 { 78 } 79 80 // Allows the request to be matched up with its requestor. 81 int requestorID() const { return m_requestorID; } 82 void setRequestorID(int requestorID) { m_requestorID = requestorID; } 83 84 // The process id of the process from which this request originated. In 85 // the case of out-of-process plugins, this allows to link back the 86 // request to the plugin process (as it is processed through a render 87 // view process). 88 int requestorProcessID() const { return m_requestorProcessID; } 89 void setRequestorProcessID(int requestorProcessID) { m_requestorProcessID = requestorProcessID; } 90 91 // Allows the request to be matched up with its app cache host. 92 int appCacheHostID() const { return m_appCacheHostID; } 93 void setAppCacheHostID(int id) { m_appCacheHostID = id; } 94 95 // True if request was user initiated. 96 bool hasUserGesture() const { return m_hasUserGesture; } 97 void setHasUserGesture(bool hasUserGesture) { m_hasUserGesture = hasUserGesture; } 98 99 // True if request should be downloaded to file. 100 bool downloadToFile() const { return m_downloadToFile; } 101 void setDownloadToFile(bool downloadToFile) { m_downloadToFile = downloadToFile; } 102 103 private: 104 friend class ResourceRequestBase; 105 106 void doUpdatePlatformRequest() {} 107 void doUpdateResourceRequest() {} 108 109 PassOwnPtr<CrossThreadResourceRequestData> doPlatformCopyData(PassOwnPtr<CrossThreadResourceRequestData>) const; 110 void doPlatformAdopt(PassOwnPtr<CrossThreadResourceRequestData>); 111 112 int m_requestorID; 113 int m_requestorProcessID; 114 int m_appCacheHostID; 115 bool m_hasUserGesture; 116 bool m_downloadToFile; 117 }; 118 119 struct CrossThreadResourceRequestData : public CrossThreadResourceRequestDataBase { 120 int m_requestorID; 121 int m_requestorProcessID; 122 int m_appCacheHostID; 123 bool m_hasUserGesture; 124 bool m_downloadToFile; 125 }; 126 127 } // namespace WebCore 128 129 #endif 130