ResourceLoaderInternal.h 5.26 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// -*- mode: c++; c-basic-offset: 4 -*-
/*
 * Copyright (C) 2004, 2006 Apple Computer, Inc.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
 */

ggaren's avatar
ggaren committed
27
28
#ifndef ResourceLoaderInternal_h
#define ResourceLoaderInternal_h
29

darin's avatar
darin committed
30
#include "FormData.h"
weinig's avatar
weinig committed
31
#include "KURL.h"
mjs's avatar
mjs committed
32
#include <wtf/HashMap.h>
weinig's avatar
weinig committed
33
#include <wtf/Platform.h>
34

ggaren's avatar
ggaren committed
35
36
37
38
39
#if USE(CFNETWORK)
#include <CFNetwork/CFURLConnectionPriv.h>
#endif

#if USE(WININET)
40
#include <winsock2.h>
bdash's avatar
bdash committed
41
#include <windows.h>
darin's avatar
darin committed
42
43
#endif

44
#if USE(CURL)
ggaren's avatar
ggaren committed
45
46
47
typedef void CURL;
#endif

48
49
50
51
#if PLATFORM(QT)
#include <QString>
#endif

mjs's avatar
mjs committed
52
// The allocations and releases in ResourceLoaderInternal are
darin's avatar
darin committed
53
// Cocoa-exception-free (either simple Foundation classes or
darin's avatar
darin committed
54
// WebCoreResourceLoaderImp which avoids doing work in dealloc).
55
56
57

namespace WebCore {

mjs's avatar
mjs committed
58
    class ResourceLoaderInternal
59
60
    {
    public:
mjs's avatar
mjs committed
61
        ResourceLoaderInternal(ResourceLoader* job, ResourceLoaderClient* c, const String& method, const KURL& u)
62
            : client(c)
mjs's avatar
mjs committed
63
64
65
66
67
            , status(0)
            , URL(u)
            , method(method)
            , assembledResponseHeaders(true)
            , retrievedCharset(true)
mjs's avatar
mjs committed
68
69
            , m_loading(false)
            , m_cancelled(false)
ggaren's avatar
ggaren committed
70
71
72
#if USE(CFNETWORK)
            , m_connection(0)
#elif PLATFORM(MAC)
mjs's avatar
mjs committed
73
74
75
            , loader(nil)
            , response(nil)
#endif
ggaren's avatar
ggaren committed
76
#if USE(WININET)
bdash's avatar
bdash committed
77
            , m_fileHandle(INVALID_HANDLE_VALUE)
mjs's avatar
mjs committed
78
            , m_fileLoadTimer(job, &ResourceLoader::fileLoadTimer)
79
80
            , m_resourceHandle(0)
            , m_secondaryHandle(0)
81
82
            , m_jobId(0)
            , m_threadId(0)
83
84
85
86
            , m_writing(false)
            , m_formDataString(0)
            , m_formDataLength(0)
            , m_bytesRemainingToWrite(0)
aroben's avatar
aroben committed
87
            , m_hasReceivedResponse(false)
aroben's avatar
aroben committed
88
            , m_resend(false)
ggaren's avatar
ggaren committed
89
#endif
90
#if USE(CURL)
ggaren's avatar
ggaren committed
91
            , m_handle(0)
92
93
94
95
#endif
        {
        }
        
mjs's avatar
mjs committed
96
        ResourceLoaderInternal(ResourceLoader* job, ResourceLoaderClient* c, const String& method, const KURL& u, const FormData& p)
97
98
99
100
101
102
103
            : client(c)
            , status(0)
            , URL(u)
            , method(method)
            , postData(p)
            , assembledResponseHeaders(true)
            , retrievedCharset(true)
mjs's avatar
mjs committed
104
105
            , m_loading(false)
            , m_cancelled(false)
ggaren's avatar
ggaren committed
106
107
108
#if USE(CFNETWORK)
            , m_connection(0)
#elif PLATFORM(MAC)
109
110
            , loader(nil)
            , response(nil)
mjs's avatar
mjs committed
111
#endif
ggaren's avatar
ggaren committed
112
#if USE(WININET)
bdash's avatar
bdash committed
113
            , m_fileHandle(INVALID_HANDLE_VALUE)
mjs's avatar
mjs committed
114
            , m_fileLoadTimer(job, &ResourceLoader::fileLoadTimer)
115
116
            , m_resourceHandle(0)
            , m_secondaryHandle(0)
117
118
            , m_jobId(0)
            , m_threadId(0)
119
120
121
122
            , m_writing(false)
            , m_formDataString(0)
            , m_formDataLength(0)
            , m_bytesRemainingToWrite(0)
aroben's avatar
aroben committed
123
            , m_hasReceivedResponse(false)
aroben's avatar
aroben committed
124
            , m_resend(false)
ggaren's avatar
ggaren committed
125
#endif
126
#if USE(CURL)
ggaren's avatar
ggaren committed
127
            , m_handle(0)
128
129
130
131
#endif
        {
        }

mjs's avatar
mjs committed
132
        ~ResourceLoaderInternal();
133
        
mjs's avatar
mjs committed
134
        ResourceLoaderClient* client;
135
136
137
138
139
140
141
142
143
        
        int status;
        HashMap<String, String> metaData;
        KURL URL;
        String method;
        FormData postData;
        
        bool assembledResponseHeaders;
        bool retrievedCharset;
darin's avatar
darin committed
144
        DeprecatedString responseHeaders;
mjs's avatar
mjs committed
145
146
147
148
    
        bool m_loading;
        bool m_cancelled;

ggaren's avatar
ggaren committed
149
150
151
#if USE(CFNETWORK)
        CFURLConnectionRef m_connection;
#elif PLATFORM(MAC)
darin's avatar
darin committed
152
        WebCoreResourceLoaderImp* loader;
153
154
        NSURLResponse* response;
#endif
ggaren's avatar
ggaren committed
155
#if USE(WININET)
mjs's avatar
mjs committed
156
        HANDLE m_fileHandle;
mjs's avatar
mjs committed
157
        Timer<ResourceLoader> m_fileLoadTimer;
mjs's avatar
mjs committed
158
        HINTERNET m_resourceHandle;
159
        HINTERNET m_secondaryHandle;
160
161
        unsigned m_jobId;
        DWORD m_threadId;
162
163
164
165
        bool m_writing;
        char* m_formDataString;
        int m_formDataLength;
        int m_bytesRemainingToWrite;
aroben's avatar
aroben committed
166
        String m_postReferrer;
aroben's avatar
aroben committed
167
        bool m_hasReceivedResponse;
aroben's avatar
aroben committed
168
        bool m_resend;
ggaren's avatar
ggaren committed
169
#endif
170
#if USE(CURL)
ggaren's avatar
ggaren committed
171
        CURL *m_handle;
mjs's avatar
mjs committed
172
#endif
173
#if PLATFORM(QT)
rwlbuis's avatar
rwlbuis committed
174
        QString m_charset;
175
176
        QString m_mimetype;
        QString m_response;
177
#endif
mjs's avatar
mjs committed
178
        };
179
180
181

} // namespace WebCore

ggaren's avatar
ggaren committed
182
#endif // ResourceLoaderInternal_h