~ubuntu-branches/ubuntu/raring/qtwebkit-source/raring-proposed

« back to all changes in this revision

Viewing changes to Source/WebCore/platform/network/ResourceHandleInternal.h

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2013-02-18 14:24:18 UTC
  • Revision ID: package-import@ubuntu.com-20130218142418-eon0jmjg3nj438uy
Tags: upstream-2.3
ImportĀ upstreamĀ versionĀ 2.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2004, 2006 Apple Computer, Inc.  All rights reserved.
 
3
 *
 
4
 * Redistribution and use in source and binary forms, with or without
 
5
 * modification, are permitted provided that the following conditions
 
6
 * are met:
 
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.
 
12
 *
 
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. 
 
24
 */
 
25
 
 
26
#ifndef ResourceHandleInternal_h
 
27
#define ResourceHandleInternal_h
 
28
 
 
29
#include "ResourceHandle.h"
 
30
#include "ResourceRequest.h"
 
31
#include "AuthenticationChallenge.h"
 
32
#include "Timer.h"
 
33
 
 
34
#if USE(CFNETWORK)
 
35
#include <CFNetwork/CFURLConnectionPriv.h>
 
36
#endif
 
37
 
 
38
#if USE(WININET) || (USE(CURL) && PLATFORM(WIN))
 
39
#include <winsock2.h>
 
40
#include <windows.h>
 
41
#endif
 
42
 
 
43
#if USE(CURL)
 
44
#include <curl/curl.h>
 
45
#include "FormDataStreamCurl.h"
 
46
#endif
 
47
 
 
48
#if USE(SOUP)
 
49
#include <wtf/gobject/GRefPtr.h>
 
50
#define LIBSOUP_USE_UNSTABLE_REQUEST_API
 
51
#include <libsoup/soup-request.h>
 
52
#include <libsoup/soup.h>
 
53
class Frame;
 
54
#endif
 
55
 
 
56
#if PLATFORM(QT)
 
57
QT_BEGIN_NAMESPACE
 
58
class QWebNetworkJob;
 
59
QT_END_NAMESPACE
 
60
namespace WebCore {
 
61
class QNetworkReplyHandler;
 
62
}
 
63
#endif
 
64
 
 
65
#if PLATFORM(MAC)
 
66
OBJC_CLASS NSURLAuthenticationChallenge;
 
67
OBJC_CLASS NSURLConnection;
 
68
#endif
 
69
 
 
70
#if PLATFORM(MAC) || USE(CFNETWORK)
 
71
typedef const struct __CFURLStorageSession* CFURLStorageSessionRef;
 
72
#endif
 
73
 
 
74
// The allocations and releases in ResourceHandleInternal are
 
75
// Cocoa-exception-free (either simple Foundation classes or
 
76
// WebCoreResourceLoaderImp which avoids doing work in dealloc).
 
77
 
 
78
namespace WebCore {
 
79
    class ResourceHandleClient;
 
80
 
 
81
    class ResourceHandleInternal {
 
82
        WTF_MAKE_NONCOPYABLE(ResourceHandleInternal); WTF_MAKE_FAST_ALLOCATED;
 
83
    public:
 
84
        ResourceHandleInternal(ResourceHandle* loader, const ResourceRequest& request, ResourceHandleClient* c, bool defersLoading, bool shouldContentSniff)
 
85
            : m_client(c)
 
86
            , m_firstRequest(request)
 
87
            , m_lastHTTPMethod(request.httpMethod())
 
88
            , status(0)
 
89
            , m_defersLoading(defersLoading)
 
90
            , m_shouldContentSniff(shouldContentSniff)
 
91
#if USE(CFNETWORK)
 
92
            , m_connection(0)
 
93
#endif
 
94
#if USE(WININET)
 
95
            , m_fileLoadTimer(loader, &ResourceHandle::fileLoadTimer)
 
96
            , m_internetHandle(0)
 
97
            , m_connectHandle(0)
 
98
            , m_requestHandle(0)
 
99
            , m_sentEndRequest(false)
 
100
            , m_bytesRemainingToWrite(0)
 
101
            , m_loadSynchronously(false)
 
102
            , m_hasReceivedResponse(false)
 
103
#endif
 
104
#if USE(CURL)
 
105
            , m_handle(0)
 
106
            , m_url(0)
 
107
            , m_customHeaders(0)
 
108
            , m_cancelled(false)
 
109
            , m_formDataStream(loader)
 
110
#endif
 
111
#if USE(SOUP)
 
112
            , m_cancelled(false)
 
113
            , m_buffer(0)
 
114
            , m_bodySize(0)
 
115
            , m_bodyDataSent(0)
 
116
#endif
 
117
#if PLATFORM(QT)
 
118
            , m_job(0)
 
119
#endif
 
120
#if PLATFORM(MAC)
 
121
            , m_startWhenScheduled(false)
 
122
            , m_needsSiteSpecificQuirks(false)
 
123
            , m_currentMacChallenge(nil)
 
124
#endif
 
125
            , m_scheduledFailureType(ResourceHandle::NoFailure)
 
126
            , m_failureTimer(loader, &ResourceHandle::fireFailure)
 
127
        {
 
128
            const KURL& url = m_firstRequest.url();
 
129
            m_user = url.user();
 
130
            m_pass = url.pass();
 
131
            m_firstRequest.removeCredentials();
 
132
        }
 
133
        
 
134
        ~ResourceHandleInternal();
 
135
 
 
136
        ResourceHandleClient* client() { return m_client; }
 
137
        ResourceHandleClient* m_client;
 
138
        
 
139
        ResourceRequest m_firstRequest;
 
140
        String m_lastHTTPMethod;
 
141
 
 
142
        // Suggested credentials for the current redirection step.
 
143
        String m_user;
 
144
        String m_pass;
 
145
        
 
146
        Credential m_initialCredential;
 
147
        
 
148
        int status;
 
149
 
 
150
        bool m_defersLoading;
 
151
        bool m_shouldContentSniff;
 
152
#if USE(CFNETWORK)
 
153
        RetainPtr<CFURLConnectionRef> m_connection;
 
154
#endif
 
155
#if PLATFORM(MAC) && !USE(CFNETWORK)
 
156
        RetainPtr<NSURLConnection> m_connection;
 
157
        RetainPtr<WebCoreResourceHandleAsDelegate> m_delegate;
 
158
        RetainPtr<id> m_proxy;
 
159
#endif
 
160
#if PLATFORM(MAC)
 
161
        bool m_startWhenScheduled;
 
162
        bool m_needsSiteSpecificQuirks;
 
163
#endif
 
164
#if PLATFORM(MAC) || USE(CFNETWORK)
 
165
        RetainPtr<CFURLStorageSessionRef> m_storageSession;
 
166
#endif
 
167
#if USE(WININET)
 
168
        Timer<ResourceHandle> m_fileLoadTimer;
 
169
        HINTERNET m_internetHandle;
 
170
        HINTERNET m_connectHandle;
 
171
        HINTERNET m_requestHandle;
 
172
        bool m_sentEndRequest;
 
173
        Vector<char> m_formData;
 
174
        size_t m_bytesRemainingToWrite;
 
175
        bool m_loadSynchronously;
 
176
        bool m_hasReceivedResponse;
 
177
        String m_redirectUrl;
 
178
#endif
 
179
#if USE(CURL)
 
180
        CURL* m_handle;
 
181
        char* m_url;
 
182
        struct curl_slist* m_customHeaders;
 
183
        ResourceResponse m_response;
 
184
        bool m_cancelled;
 
185
 
 
186
        FormDataStream m_formDataStream;
 
187
        Vector<char> m_postBytes;
 
188
#endif
 
189
#if USE(SOUP)
 
190
        GRefPtr<SoupMessage> m_soupMessage;
 
191
        ResourceResponse m_response;
 
192
        bool m_cancelled;
 
193
        GRefPtr<SoupRequest> m_soupRequest;
 
194
        GRefPtr<GInputStream> m_inputStream;
 
195
        GRefPtr<GCancellable> m_cancellable;
 
196
        GRefPtr<GAsyncResult> m_deferredResult;
 
197
        GRefPtr<GSource> m_timeoutSource;
 
198
        char* m_buffer;
 
199
        unsigned long m_bodySize;
 
200
        unsigned long m_bodyDataSent;
 
201
        RefPtr<NetworkingContext> m_context;
 
202
        SoupSession* soupSession();
 
203
#endif
 
204
#if PLATFORM(GTK)
 
205
        struct {
 
206
            Credential credential;
 
207
            AuthenticationChallenge challenge;
 
208
        } m_credentialDataToSaveInPersistentStore;
 
209
#endif
 
210
#if PLATFORM(QT)
 
211
        QNetworkReplyHandler* m_job;
 
212
        RefPtr<NetworkingContext> m_context;
 
213
#endif
 
214
 
 
215
#if PLATFORM(MAC)
 
216
        // We need to keep a reference to the original challenge to be able to cancel it.
 
217
        // It is almost identical to m_currentWebChallenge.nsURLAuthenticationChallenge(), but has a different sender.
 
218
        NSURLAuthenticationChallenge *m_currentMacChallenge;
 
219
#endif
 
220
        AuthenticationChallenge m_currentWebChallenge;
 
221
 
 
222
        ResourceHandle::FailureType m_scheduledFailureType;
 
223
        Timer<ResourceHandle> m_failureTimer;
 
224
    };
 
225
 
 
226
} // namespace WebCore
 
227
 
 
228
#endif // ResourceHandleInternal_h