OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2003, 2006, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2003, 2006, 2008 Apple Inc. All rights reserved. |
3 * Copyright (C) 2005, 2006 Alexey Proskuryakov <ap@nypop.com> | 3 * Copyright (C) 2005, 2006 Alexey Proskuryakov <ap@nypop.com> |
4 * Copyright (C) 2011 Google Inc. All rights reserved. | 4 * Copyright (C) 2011 Google Inc. All rights reserved. |
5 * Copyright (C) 2012 Intel Corporation | 5 * Copyright (C) 2012 Intel Corporation |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Lesser General Public | 8 * modify it under the terms of the GNU Lesser General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
11 * | 11 * |
12 * This library is distributed in the hope that it will be useful, | 12 * This library is distributed in the hope that it will be useful, |
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 * Lesser General Public License for more details. | 15 * Lesser General Public License for more details. |
16 * | 16 * |
17 * You should have received a copy of the GNU Lesser General Public | 17 * You should have received a copy of the GNU Lesser General Public |
18 * License along with this library; if not, write to the Free Software | 18 * License along with this library; if not, write to the Free Software |
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 U
SA | 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 U
SA |
20 */ | 20 */ |
21 | 21 |
22 #ifndef XMLHttpRequest_h | 22 #ifndef XMLHttpRequest_h |
23 #define XMLHttpRequest_h | 23 #define XMLHttpRequest_h |
24 | 24 |
25 #include "bindings/v8/ScriptString.h" | 25 #include "bindings/v8/ScriptString.h" |
26 #include "bindings/v8/ScriptWrappable.h" | 26 #include "bindings/v8/ScriptWrappable.h" |
27 #include "core/dom/ActiveDOMObject.h" | 27 #include "core/dom/ActiveDOMObject.h" |
28 #include "core/dom/EventListener.h" | 28 #include "core/dom/EventListener.h" |
29 #include "core/dom/EventNames.h" | 29 #include "core/dom/EventNames.h" |
30 #include "core/dom/EventTarget.h" | |
31 #include "core/loader/ThreadableLoaderClient.h" | 30 #include "core/loader/ThreadableLoaderClient.h" |
32 #include "core/platform/network/FormData.h" | 31 #include "core/platform/network/FormData.h" |
33 #include "core/platform/network/ResourceResponse.h" | 32 #include "core/platform/network/ResourceResponse.h" |
| 33 #include "core/xml/XMLHttpRequestEventTarget.h" |
34 #include "core/xml/XMLHttpRequestProgressEventThrottle.h" | 34 #include "core/xml/XMLHttpRequestProgressEventThrottle.h" |
35 #include "weborigin/SecurityOrigin.h" | 35 #include "weborigin/SecurityOrigin.h" |
36 #include "wtf/OwnPtr.h" | 36 #include "wtf/OwnPtr.h" |
37 #include "wtf/text/AtomicStringHash.h" | 37 #include "wtf/text/AtomicStringHash.h" |
38 #include "wtf/text/StringBuilder.h" | 38 #include "wtf/text/StringBuilder.h" |
39 | 39 |
40 namespace WebCore { | 40 namespace WebCore { |
41 | 41 |
42 class Blob; | 42 class Blob; |
43 class DOMFormData; | 43 class DOMFormData; |
44 class Document; | 44 class Document; |
45 class ExceptionState; | 45 class ExceptionState; |
46 class ResourceRequest; | 46 class ResourceRequest; |
47 class SecurityOrigin; | 47 class SecurityOrigin; |
48 class SharedBuffer; | 48 class SharedBuffer; |
49 class TextResourceDecoder; | 49 class TextResourceDecoder; |
50 class ThreadableLoader; | 50 class ThreadableLoader; |
51 | 51 |
52 typedef int ExceptionCode; | 52 typedef int ExceptionCode; |
53 | 53 |
54 class XMLHttpRequest : public ScriptWrappable, public RefCounted<XMLHttpRequest>
, public EventTarget, private ThreadableLoaderClient, public ActiveDOMObject { | 54 class XMLHttpRequest : public ScriptWrappable, public RefCounted<XMLHttpRequest>
, public XMLHttpRequestEventTarget, private ThreadableLoaderClient, public Activ
eDOMObject { |
55 WTF_MAKE_FAST_ALLOCATED; | 55 WTF_MAKE_FAST_ALLOCATED; |
56 public: | 56 public: |
57 static PassRefPtr<XMLHttpRequest> create(ScriptExecutionContext*, PassRefPtr
<SecurityOrigin> = 0); | 57 static PassRefPtr<XMLHttpRequest> create(ScriptExecutionContext*, PassRefPtr
<SecurityOrigin> = 0); |
58 ~XMLHttpRequest(); | 58 ~XMLHttpRequest(); |
59 | 59 |
60 // These exact numeric values are important because JS expects them. | 60 // These exact numeric values are important because JS expects them. |
61 enum State { | 61 enum State { |
62 UNSENT = 0, | 62 UNSENT = 0, |
63 OPENED = 1, | 63 OPENED = 1, |
64 HEADERS_RECEIVED = 2, | 64 HEADERS_RECEIVED = 2, |
65 LOADING = 3, | 65 LOADING = 3, |
66 DONE = 4 | 66 DONE = 4 |
67 }; | 67 }; |
68 | 68 |
69 enum ResponseTypeCode { | 69 enum ResponseTypeCode { |
70 ResponseTypeDefault, | 70 ResponseTypeDefault, |
71 ResponseTypeText, | 71 ResponseTypeText, |
72 ResponseTypeDocument, | 72 ResponseTypeDocument, |
73 ResponseTypeBlob, | 73 ResponseTypeBlob, |
74 ResponseTypeArrayBuffer | 74 ResponseTypeArrayBuffer |
75 }; | 75 }; |
76 | 76 |
77 virtual void contextDestroyed(); | 77 virtual void contextDestroyed(); |
78 virtual void didTimeout(); | 78 virtual void didTimeout(); |
79 virtual bool canSuspend() const; | 79 virtual bool canSuspend() const; |
80 virtual void suspend(ReasonForSuspension); | 80 virtual void suspend(ReasonForSuspension); |
81 virtual void resume(); | 81 virtual void resume(); |
82 virtual void stop(); | 82 virtual void stop(); |
83 | 83 |
84 virtual const AtomicString& interfaceName() const; | 84 virtual const AtomicString& interfaceName() const OVERRIDE; |
85 virtual ScriptExecutionContext* scriptExecutionContext() const; | 85 virtual ScriptExecutionContext* scriptExecutionContext() const OVERRIDE; |
86 | 86 |
87 const KURL& url() const { return m_url; } | 87 const KURL& url() const { return m_url; } |
88 String statusText(ExceptionState&) const; | 88 String statusText(ExceptionState&) const; |
89 int status(ExceptionState&) const; | 89 int status(ExceptionState&) const; |
90 State readyState() const; | 90 State readyState() const; |
91 bool withCredentials() const { return m_includeCredentials; } | 91 bool withCredentials() const { return m_includeCredentials; } |
92 void setWithCredentials(bool, ExceptionState&); | 92 void setWithCredentials(bool, ExceptionState&); |
93 void open(const String& method, const KURL&, ExceptionState&); | 93 void open(const String& method, const KURL&, ExceptionState&); |
94 void open(const String& method, const KURL&, bool async, ExceptionState&); | 94 void open(const String& method, const KURL&, bool async, ExceptionState&); |
95 void open(const String& method, const KURL&, bool async, const String& user,
ExceptionState&); | 95 void open(const String& method, const KURL&, bool async, const String& user,
ExceptionState&); |
(...skipping 29 matching lines...) Expand all Loading... |
125 | 125 |
126 // response attribute has custom getter. | 126 // response attribute has custom getter. |
127 ArrayBuffer* responseArrayBuffer(); | 127 ArrayBuffer* responseArrayBuffer(); |
128 | 128 |
129 void setLastSendLineNumber(unsigned lineNumber) { m_lastSendLineNumber = lin
eNumber; } | 129 void setLastSendLineNumber(unsigned lineNumber) { m_lastSendLineNumber = lin
eNumber; } |
130 void setLastSendURL(const String& url) { m_lastSendURL = url; } | 130 void setLastSendURL(const String& url) { m_lastSendURL = url; } |
131 | 131 |
132 XMLHttpRequestUpload* upload(); | 132 XMLHttpRequestUpload* upload(); |
133 | 133 |
134 DEFINE_ATTRIBUTE_EVENT_LISTENER(readystatechange); | 134 DEFINE_ATTRIBUTE_EVENT_LISTENER(readystatechange); |
135 DEFINE_ATTRIBUTE_EVENT_LISTENER(abort); | |
136 DEFINE_ATTRIBUTE_EVENT_LISTENER(error); | |
137 DEFINE_ATTRIBUTE_EVENT_LISTENER(load); | |
138 DEFINE_ATTRIBUTE_EVENT_LISTENER(loadend); | |
139 DEFINE_ATTRIBUTE_EVENT_LISTENER(loadstart); | |
140 DEFINE_ATTRIBUTE_EVENT_LISTENER(progress); | |
141 DEFINE_ATTRIBUTE_EVENT_LISTENER(timeout); | |
142 | 135 |
143 using RefCounted<XMLHttpRequest>::ref; | 136 using RefCounted<XMLHttpRequest>::ref; |
144 using RefCounted<XMLHttpRequest>::deref; | 137 using RefCounted<XMLHttpRequest>::deref; |
145 | 138 |
146 private: | 139 private: |
147 XMLHttpRequest(ScriptExecutionContext*, PassRefPtr<SecurityOrigin>); | 140 XMLHttpRequest(ScriptExecutionContext*, PassRefPtr<SecurityOrigin>); |
148 | 141 |
149 virtual void refEventTarget() { ref(); } | 142 virtual void refEventTarget() OVERRIDE { ref(); } |
150 virtual void derefEventTarget() { deref(); } | 143 virtual void derefEventTarget() OVERRIDE { deref(); } |
151 virtual EventTargetData* eventTargetData(); | |
152 virtual EventTargetData* ensureEventTargetData(); | |
153 | 144 |
154 Document* document() const; | 145 Document* document() const; |
155 SecurityOrigin* securityOrigin() const; | 146 SecurityOrigin* securityOrigin() const; |
156 | 147 |
157 virtual void didSendData(unsigned long long bytesSent, unsigned long long to
talBytesToBeSent); | 148 virtual void didSendData(unsigned long long bytesSent, unsigned long long to
talBytesToBeSent); |
158 virtual void didReceiveResponse(unsigned long identifier, const ResourceResp
onse&); | 149 virtual void didReceiveResponse(unsigned long identifier, const ResourceResp
onse&); |
159 virtual void didReceiveData(const char* data, int dataLength); | 150 virtual void didReceiveData(const char* data, int dataLength); |
160 virtual void didFinishLoading(unsigned long identifier, double finishTime); | 151 virtual void didFinishLoading(unsigned long identifier, double finishTime); |
161 virtual void didFail(const ResourceError&); | 152 virtual void didFail(const ResourceError&); |
162 virtual void didFailRedirectCheck(); | 153 virtual void didFailRedirectCheck(); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 bool m_sameOriginRequest; | 213 bool m_sameOriginRequest; |
223 bool m_allowCrossOriginRequests; | 214 bool m_allowCrossOriginRequests; |
224 | 215 |
225 // Used for onprogress tracking | 216 // Used for onprogress tracking |
226 long long m_receivedLength; | 217 long long m_receivedLength; |
227 | 218 |
228 unsigned m_lastSendLineNumber; | 219 unsigned m_lastSendLineNumber; |
229 String m_lastSendURL; | 220 String m_lastSendURL; |
230 ExceptionCode m_exceptionCode; | 221 ExceptionCode m_exceptionCode; |
231 | 222 |
232 EventTargetData m_eventTargetData; | |
233 | |
234 XMLHttpRequestProgressEventThrottle m_progressEventThrottle; | 223 XMLHttpRequestProgressEventThrottle m_progressEventThrottle; |
235 | 224 |
236 // An enum corresponding to the allowed string values for the responseType a
ttribute. | 225 // An enum corresponding to the allowed string values for the responseType a
ttribute. |
237 ResponseTypeCode m_responseTypeCode; | 226 ResponseTypeCode m_responseTypeCode; |
238 Timer<XMLHttpRequest> m_protectionTimer; | 227 Timer<XMLHttpRequest> m_protectionTimer; |
239 RefPtr<SecurityOrigin> m_securityOrigin; | 228 RefPtr<SecurityOrigin> m_securityOrigin; |
240 }; | 229 }; |
241 | 230 |
242 } // namespace WebCore | 231 } // namespace WebCore |
243 | 232 |
244 #endif // XMLHttpRequest_h | 233 #endif // XMLHttpRequest_h |
OLD | NEW |