~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to src/3rdparty/webkit/WebCore/xml/XMLHttpRequest.h

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi
  • Date: 2009-11-02 18:30:08 UTC
  • mfrom: (1.2.2 upstream)
  • mto: (15.2.5 experimental)
  • mto: This revision was merged to the branch mainline in revision 88.
  • Revision ID: james.westby@ubuntu.com-20091102183008-b6a4gcs128mvfb3m
Tags: upstream-4.6.0~beta1
ImportĀ upstreamĀ versionĀ 4.6.0~beta1

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
#include "ActiveDOMObject.h"
24
24
#include "AtomicStringHash.h"
25
25
#include "EventListener.h"
 
26
#include "EventNames.h"
26
27
#include "EventTarget.h"
27
28
#include "FormData.h"
28
29
#include "ResourceResponse.h"
29
 
#include "SubresourceLoaderClient.h"
30
30
#include "ScriptString.h"
 
31
#include "ThreadableLoaderClient.h"
31
32
#include <wtf/OwnPtr.h>
32
33
 
33
34
namespace WebCore {
34
35
 
35
36
class Document;
36
37
class File;
 
38
struct ResourceRequest;
37
39
class TextResourceDecoder;
 
40
class ThreadableLoader;
38
41
 
39
 
class XMLHttpRequest : public RefCounted<XMLHttpRequest>, public EventTarget, private SubresourceLoaderClient, public ActiveDOMObject {
 
42
class XMLHttpRequest : public RefCounted<XMLHttpRequest>, public EventTarget, private ThreadableLoaderClient, public ActiveDOMObject {
40
43
public:
41
 
    static PassRefPtr<XMLHttpRequest> create(Document* document) { return adoptRef(new XMLHttpRequest(document)); }
 
44
    static PassRefPtr<XMLHttpRequest> create(ScriptExecutionContext* context) { return adoptRef(new XMLHttpRequest(context)); }
42
45
    ~XMLHttpRequest();
43
46
 
44
47
    // These exact numeric values are important because JS expects them.
61
64
    String statusText(ExceptionCode&) const;
62
65
    int status(ExceptionCode&) const;
63
66
    State readyState() const;
 
67
    bool withCredentials() const { return m_includeCredentials; }
 
68
    void setWithCredentials(bool, ExceptionCode&);
64
69
    void open(const String& method, const KURL&, bool async, ExceptionCode&);
65
70
    void open(const String& method, const KURL&, bool async, const String& user, ExceptionCode&);
66
71
    void open(const String& method, const KURL&, bool async, const String& user, const String& password, ExceptionCode&);
81
86
    XMLHttpRequestUpload* upload();
82
87
    XMLHttpRequestUpload* optionalUpload() const { return m_upload.get(); }
83
88
 
84
 
    void setOnreadystatechange(PassRefPtr<EventListener> eventListener) { m_onReadyStateChangeListener = eventListener; }
85
 
    EventListener* onreadystatechange() const { return m_onReadyStateChangeListener.get(); }
86
 
 
87
 
    void setOnabort(PassRefPtr<EventListener> eventListener) { m_onAbortListener = eventListener; }
88
 
    EventListener* onabort() const { return m_onAbortListener.get(); }
89
 
 
90
 
    void setOnerror(PassRefPtr<EventListener> eventListener) { m_onErrorListener = eventListener; }
91
 
    EventListener* onerror() const { return m_onErrorListener.get(); }
92
 
 
93
 
    void setOnload(PassRefPtr<EventListener> eventListener) { m_onLoadListener = eventListener; }
94
 
    EventListener* onload() const { return m_onLoadListener.get(); }
95
 
 
96
 
    void setOnloadstart(PassRefPtr<EventListener> eventListener) { m_onLoadStartListener = eventListener; }
97
 
    EventListener* onloadstart() const { return m_onLoadStartListener.get(); }
98
 
 
99
 
    void setOnprogress(PassRefPtr<EventListener> eventListener) { m_onProgressListener = eventListener; }
100
 
    EventListener* onprogress() const { return m_onProgressListener.get(); }
101
 
 
102
 
    typedef Vector<RefPtr<EventListener> > ListenerVector;
103
 
    typedef HashMap<AtomicString, ListenerVector> EventListenersMap;
104
 
 
105
 
    // useCapture is not used, even for add/remove pairing (for Firefox compatibility).
106
 
    virtual void addEventListener(const AtomicString& eventType, PassRefPtr<EventListener>, bool useCapture);
107
 
    virtual void removeEventListener(const AtomicString& eventType, EventListener*, bool useCapture);
108
 
    virtual bool dispatchEvent(PassRefPtr<Event>, ExceptionCode&);
109
 
    EventListenersMap& eventListeners() { return m_eventListeners; }
 
89
    DEFINE_ATTRIBUTE_EVENT_LISTENER(readystatechange);
 
90
    DEFINE_ATTRIBUTE_EVENT_LISTENER(abort);
 
91
    DEFINE_ATTRIBUTE_EVENT_LISTENER(error);
 
92
    DEFINE_ATTRIBUTE_EVENT_LISTENER(load);
 
93
    DEFINE_ATTRIBUTE_EVENT_LISTENER(loadstart);
 
94
    DEFINE_ATTRIBUTE_EVENT_LISTENER(progress);
110
95
 
111
96
    using RefCounted<XMLHttpRequest>::ref;
112
97
    using RefCounted<XMLHttpRequest>::deref;
113
98
 
114
99
private:
115
 
    XMLHttpRequest(Document*);
116
 
    
 
100
    XMLHttpRequest(ScriptExecutionContext*);
 
101
 
117
102
    virtual void refEventTarget() { ref(); }
118
103
    virtual void derefEventTarget() { deref(); }
 
104
    virtual EventTargetData* eventTargetData();
 
105
    virtual EventTargetData* ensureEventTargetData();
119
106
 
120
107
    Document* document() const;
121
108
 
122
 
    virtual void willSendRequest(SubresourceLoader*, ResourceRequest& request, const ResourceResponse& redirectResponse);
123
 
    virtual void didSendData(SubresourceLoader*, unsigned long long bytesSent, unsigned long long totalBytesToBeSent);
124
 
    virtual void didReceiveResponse(SubresourceLoader*, const ResourceResponse&);
125
 
    virtual void didReceiveData(SubresourceLoader*, const char* data, int size);
126
 
    virtual void didFail(SubresourceLoader*, const ResourceError&);
127
 
    virtual void didFinishLoading(SubresourceLoader*);
128
 
    virtual void receivedCancellation(SubresourceLoader*, const AuthenticationChallenge&);
129
 
 
130
 
    // Special versions for the preflight
131
 
    void didReceiveResponsePreflight(SubresourceLoader*, const ResourceResponse&);
132
 
    void didFinishLoadingPreflight(SubresourceLoader*);
133
 
 
134
 
    void processSyncLoadResults(const Vector<char>& data, const ResourceResponse&, ExceptionCode&);
135
 
    void updateAndDispatchOnProgress(unsigned int len);
 
109
#if ENABLE(DASHBOARD_SUPPORT)
 
110
    bool usesDashboardBackwardCompatibilityMode() const;
 
111
#endif
 
112
 
 
113
    virtual void didSendData(unsigned long long bytesSent, unsigned long long totalBytesToBeSent);
 
114
    virtual void didReceiveResponse(const ResourceResponse&);
 
115
    virtual void didReceiveData(const char* data, int lengthReceived);
 
116
    virtual void didFinishLoading(unsigned long identifier);
 
117
    virtual void didFail(const ResourceError&);
 
118
    virtual void didFailRedirectCheck();
 
119
    virtual void didReceiveAuthenticationCancellation(const ResourceResponse&);
136
120
 
137
121
    String responseMIMEType() const;
138
122
    bool responseIsXML() const;
152
136
 
153
137
    void createRequest(ExceptionCode&);
154
138
 
155
 
    void makeSameOriginRequest(ExceptionCode&);
156
 
    void makeCrossSiteAccessRequest(ExceptionCode&);
157
 
 
158
 
    void makeSimpleCrossSiteAccessRequest(ExceptionCode&);
159
 
    void makeCrossSiteAccessRequestWithPreflight(ExceptionCode&);
160
 
    void handleAsynchronousPreflightResult();
161
 
 
162
 
    void loadRequestSynchronously(ResourceRequest&, ExceptionCode&);
163
 
    void loadRequestAsynchronously(ResourceRequest&);
164
 
 
165
 
    bool isOnAccessControlResponseHeaderWhitelist(const String&) const;
166
 
 
167
 
    bool isSimpleCrossSiteAccessRequest() const;
168
 
    String accessControlOrigin() const;
169
 
    bool accessControlCheck(const ResourceResponse&);
170
 
 
171
139
    void genericError();
172
140
    void networkError();
173
141
    void abortError();
174
142
 
175
 
    void dispatchReadyStateChangeEvent();
176
 
    void dispatchXMLHttpRequestProgressEvent(EventListener* listener, const AtomicString& type, bool lengthComputable, unsigned loaded, unsigned total);
177
 
    void dispatchAbortEvent();
178
 
    void dispatchErrorEvent();
179
 
    void dispatchLoadEvent();
180
 
    void dispatchLoadStartEvent();
181
 
    void dispatchProgressEvent(long long expectedLength);
182
 
 
183
 
    RefPtr<EventListener> m_onReadyStateChangeListener;
184
 
    RefPtr<EventListener> m_onAbortListener;
185
 
    RefPtr<EventListener> m_onErrorListener;
186
 
    RefPtr<EventListener> m_onLoadListener;
187
 
    RefPtr<EventListener> m_onLoadStartListener;
188
 
    RefPtr<EventListener> m_onProgressListener;
189
 
    EventListenersMap m_eventListeners;
190
 
 
191
143
    RefPtr<XMLHttpRequestUpload> m_upload;
192
144
 
193
145
    KURL m_url;
198
150
    bool m_async;
199
151
    bool m_includeCredentials;
200
152
 
201
 
    RefPtr<SubresourceLoader> m_loader;
 
153
    RefPtr<ThreadableLoader> m_loader;
202
154
    State m_state;
203
155
 
204
156
    ResourceResponse m_response;
205
157
    String m_responseEncoding;
206
158
 
207
159
    RefPtr<TextResourceDecoder> m_decoder;
208
 
    unsigned long m_identifier;
209
160
 
210
 
    // Unlike most strings in the DOM, we keep this as a JSC::UString, not a WebCore::String.
 
161
    // Unlike most strings in the DOM, we keep this as a ScriptString, not a WebCore::String.
211
162
    // That's because these strings can easily get huge (they are filled from the network with
212
163
    // no parsing) and because JS can easily observe many intermediate states, so it's very useful
213
164
    // to be able to share the buffer with JavaScript versions of the whole or partial string.
219
170
 
220
171
    bool m_error;
221
172
 
 
173
    bool m_uploadEventsAllowed;
222
174
    bool m_uploadComplete;
223
175
 
224
176
    bool m_sameOriginRequest;
225
 
    bool m_allowAccess;
226
 
    bool m_inPreflight;
 
177
    bool m_didTellLoaderAboutRequest;
227
178
 
228
179
    // Used for onprogress tracking
229
180
    long long m_receivedLength;
230
 
    
 
181
 
231
182
    unsigned m_lastSendLineNumber;
232
183
    String m_lastSendURL;
 
184
    ExceptionCode m_exceptionCode;
 
185
    
 
186
    EventTargetData m_eventTargetData;
233
187
};
234
188
 
235
189
} // namespace WebCore