2 * Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 #ifndef ResourceHandle_h
27 #define ResourceHandle_h
29 #include "AuthenticationChallenge.h"
30 #include "HTTPHeaderMap.h"
31 #include <wtf/OwnPtr.h>
35 typedef unsigned long DWORD;
36 typedef unsigned long DWORD_PTR;
38 typedef LPVOID HINTERNET;
39 typedef unsigned WPARAM;
41 typedef struct HWND__* HWND;
42 typedef _W64 long LONG_PTR;
43 typedef LONG_PTR LRESULT;
48 #include <wtf/RetainPtr.h>
52 @class NSURLConnection;
53 @class WebCoreResourceHandleAsDelegate;
57 class NSURLConnection;
58 class WebCoreResourceHandleAsDelegate;
59 typedef struct objc_object *id;
64 typedef struct _CFURLConnection* CFURLConnectionRef;
65 typedef int CFHTTPCookieStorageAcceptPolicy;
66 typedef struct OpaqueCFHTTPCookieStorage* CFHTTPCookieStorageRef;
71 class AuthenticationChallenge;
77 class ResourceHandleClient;
78 class ResourceHandleInternal;
79 class ResourceRequest;
80 class ResourceResponse;
82 class SubresourceLoader;
83 class SubresourceLoaderClient;
85 template <typename T> class Timer;
87 class ResourceHandle : public Shared<ResourceHandle> {
89 ResourceHandle(const ResourceRequest&, ResourceHandleClient*, bool defersLoading, bool shouldContentSniff, bool mightDownloadFromHandle);
92 // FIXME: should not need the Frame
93 static PassRefPtr<ResourceHandle> create(const ResourceRequest&, ResourceHandleClient*, Frame*, bool defersLoading, bool shouldContentSniff, bool mightDownloadFromHandle = false);
95 static void loadResourceSynchronously(const ResourceRequest&, ResourceError&, ResourceResponse&, Vector<char>& data);
96 static bool willLoadFromCache(ResourceRequest&);
100 #if PLATFORM(MAC) || USE(CFNETWORK)
101 void didReceiveAuthenticationChallenge(const AuthenticationChallenge&);
102 void receivedCredential(const AuthenticationChallenge&, const Credential&);
103 void receivedRequestToContinueWithoutCredential(const AuthenticationChallenge&);
104 void receivedCancellation(const AuthenticationChallenge&);
107 void didCancelAuthenticationChallenge(const AuthenticationChallenge&);
108 NSURLConnection *connection() const;
109 WebCoreResourceHandleAsDelegate *delegate();
110 void releaseDelegate();
112 static CFRunLoopRef loaderRunLoop();
113 CFURLConnectionRef connection() const;
114 CFURLConnectionRef releaseConnectionForDownload();
116 static void setHostAllowsAnyHTTPSCertificate(const String&);
118 PassRefPtr<SharedBuffer> bufferedData();
119 static bool supportsBufferedData();
126 void setHasReceivedResponse(bool = true);
127 bool hasReceivedResponse() const;
128 void fileLoadTimer(Timer<ResourceHandle>*);
129 void onHandleCreated(LPARAM);
130 void onRequestRedirected(LPARAM);
131 void onRequestComplete(LPARAM);
132 friend void __stdcall transferJobStatusCallback(HINTERNET, DWORD_PTR, DWORD, LPVOID, DWORD);
133 friend LRESULT __stdcall ResourceHandleWndProc(HWND, unsigned message, WPARAM, LPARAM);
136 #if PLATFORM(GTK) || PLATFORM(QT)
137 ResourceHandleInternal* getInternal() { return d.get(); }
140 // Used to work around the fact that you don't get any more NSURLConnection callbacks until you return from the one you're in.
141 static bool loadsBlocked();
143 void clearAuthentication();
146 // The client may be 0, in which case no callbacks will be made.
147 ResourceHandleClient* client() const;
148 void setClient(ResourceHandleClient*);
150 void setDefersLoading(bool);
152 const ResourceRequest& request() const;
154 void fireBlockedFailure(Timer<ResourceHandle>*);
157 static bool portAllowed(const ResourceRequest&);
159 void scheduleBlockedFailure();
163 OwnPtr<ResourceHandleInternal> d;
168 #endif // ResourceHandle_h