Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(292)

Side by Side Diff: Source/core/xml/XMLHttpRequest.h

Issue 454313002: [WIP] XMLHttpRequest should parse as it receives chunks. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: add test Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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.
(...skipping 23 matching lines...) Expand all
34 #include "platform/weborigin/SecurityOrigin.h" 34 #include "platform/weborigin/SecurityOrigin.h"
35 #include "wtf/OwnPtr.h" 35 #include "wtf/OwnPtr.h"
36 #include "wtf/text/AtomicStringHash.h" 36 #include "wtf/text/AtomicStringHash.h"
37 #include "wtf/text/StringBuilder.h" 37 #include "wtf/text/StringBuilder.h"
38 38
39 namespace blink { 39 namespace blink {
40 40
41 class Blob; 41 class Blob;
42 class DOMFormData; 42 class DOMFormData;
43 class Document; 43 class Document;
44 class DocumentParser;
44 class ExceptionState; 45 class ExceptionState;
45 class ResourceRequest; 46 class ResourceRequest;
46 class SecurityOrigin; 47 class SecurityOrigin;
47 class SharedBuffer; 48 class SharedBuffer;
48 class Stream; 49 class Stream;
49 class TextResourceDecoder; 50 class TextResourceDecoder;
50 class ThreadableLoader; 51 class ThreadableLoader;
51 52
52 typedef int ExceptionCode; 53 typedef int ExceptionCode;
53 54
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 // When responseType is set to "blob", didDownloadData() is called instead 157 // When responseType is set to "blob", didDownloadData() is called instead
157 // of didReceiveData(). 158 // of didReceiveData().
158 virtual void didDownloadData(int dataLength) OVERRIDE; 159 virtual void didDownloadData(int dataLength) OVERRIDE;
159 virtual void didFinishLoading(unsigned long identifier, double finishTime) O VERRIDE; 160 virtual void didFinishLoading(unsigned long identifier, double finishTime) O VERRIDE;
160 virtual void didFail(const ResourceError&) OVERRIDE; 161 virtual void didFail(const ResourceError&) OVERRIDE;
161 virtual void didFailRedirectCheck() OVERRIDE; 162 virtual void didFailRedirectCheck() OVERRIDE;
162 163
163 AtomicString responseMIMEType() const; 164 AtomicString responseMIMEType() const;
164 bool responseIsXML() const; 165 bool responseIsXML() const;
165 166
167 PassOwnPtr<TextResourceDecoder> createDecoder() const;
168
169 void initResponseDocument();
170 void parseDocumentChunk(const char* data, int dataLength);
171
166 bool areMethodAndURLValidForSend(); 172 bool areMethodAndURLValidForSend();
167 173
168 bool initSend(ExceptionState&); 174 bool initSend(ExceptionState&);
169 void sendBytesData(const void*, size_t, ExceptionState&); 175 void sendBytesData(const void*, size_t, ExceptionState&);
170 176
171 const AtomicString& getRequestHeader(const AtomicString& name) const; 177 const AtomicString& getRequestHeader(const AtomicString& name) const;
172 void setRequestHeaderInternal(const AtomicString& name, const AtomicString& value); 178 void setRequestHeaderInternal(const AtomicString& name, const AtomicString& value);
173 179
174 void trackProgress(int dataLength); 180 void trackProgress(int dataLength);
175 // Changes m_state and dispatches a readyStateChange event if new m_state 181 // Changes m_state and dispatches a readyStateChange event if new m_state
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 RefPtr<ThreadableLoader> m_loader; 223 RefPtr<ThreadableLoader> m_loader;
218 State m_state; 224 State m_state;
219 225
220 ResourceResponse m_response; 226 ResourceResponse m_response;
221 String m_responseEncoding; 227 String m_responseEncoding;
222 228
223 OwnPtr<TextResourceDecoder> m_decoder; 229 OwnPtr<TextResourceDecoder> m_decoder;
224 230
225 ScriptString m_responseText; 231 ScriptString m_responseText;
226 RefPtrWillBeMember<Document> m_responseDocument; 232 RefPtrWillBeMember<Document> m_responseDocument;
233 RefPtrWillBeMember<DocumentParser> m_documentParser;
227 234
228 RefPtr<SharedBuffer> m_binaryResponseBuilder; 235 RefPtr<SharedBuffer> m_binaryResponseBuilder;
229 long long m_downloadedBlobLength; 236 long long m_downloadedBlobLength;
230 237
231 RefPtr<ArrayBuffer> m_responseArrayBuffer; 238 RefPtr<ArrayBuffer> m_responseArrayBuffer;
232 239
233 // Used for onprogress tracking 240 // Used for onprogress tracking
234 long long m_receivedLength; 241 long long m_receivedLength;
235 242
236 unsigned m_lastSendLineNumber; 243 unsigned m_lastSendLineNumber;
237 String m_lastSendURL; 244 String m_lastSendURL;
238 // An exception to throw in synchronous mode. It's set when failure 245 // An exception to throw in synchronous mode. It's set when failure
239 // notification is received from m_loader and thrown at the end of send() if 246 // notification is received from m_loader and thrown at the end of send() if
240 // any. 247 // any.
241 ExceptionCode m_exceptionCode; 248 ExceptionCode m_exceptionCode;
242 249
243 XMLHttpRequestProgressEventThrottle m_progressEventThrottle; 250 XMLHttpRequestProgressEventThrottle m_progressEventThrottle;
244 251
245 // An enum corresponding to the allowed string values for the responseType a ttribute. 252 // An enum corresponding to the allowed string values for the responseType a ttribute.
246 ResponseTypeCode m_responseTypeCode; 253 ResponseTypeCode m_responseTypeCode;
247 RefPtr<SecurityOrigin> m_securityOrigin; 254 RefPtr<SecurityOrigin> m_securityOrigin;
248 255
249 double m_previousReadyStateChangeFireTime; 256 double m_previousReadyStateChangeFireTime;
250 257
251 bool m_async; 258 bool m_async;
252 bool m_includeCredentials; 259 bool m_includeCredentials;
253 // Used to skip m_responseDocument creation if it's done previously. We need 260 // Used to skip m_responseDocument creation if it's done previously. We need
254 // this separate flag since m_responseDocument can be 0 for some cases. 261 // this separate flag since m_responseDocument can be 0 for some cases.
255 bool m_createdDocument; 262 bool m_parsedResponse;
256 bool m_error; 263 bool m_error;
257 bool m_uploadEventsAllowed; 264 bool m_uploadEventsAllowed;
258 bool m_uploadComplete; 265 bool m_uploadComplete;
259 bool m_sameOriginRequest; 266 bool m_sameOriginRequest;
260 }; 267 };
261 268
262 } // namespace blink 269 } // namespace blink
263 270
264 #endif // XMLHttpRequest_h 271 #endif // XMLHttpRequest_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698