OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved. |
3 * Copyright (C) 2005-2007 Alexey Proskuryakov <ap@webkit.org> | 3 * Copyright (C) 2005-2007 Alexey Proskuryakov <ap@webkit.org> |
4 * Copyright (C) 2007, 2008 Julien Chaffraix <jchaffraix@webkit.org> | 4 * Copyright (C) 2007, 2008 Julien Chaffraix <jchaffraix@webkit.org> |
5 * Copyright (C) 2008, 2011 Google Inc. All rights reserved. | 5 * Copyright (C) 2008, 2011 Google Inc. All rights reserved. |
6 * Copyright (C) 2012 Intel Corporation | 6 * Copyright (C) 2012 Intel Corporation |
7 * | 7 * |
8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Lesser General Public | 9 * modify it under the terms of the GNU Lesser General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
51 #include "platform/SharedBuffer.h" | 51 #include "platform/SharedBuffer.h" |
52 #include "platform/blob/BlobData.h" | 52 #include "platform/blob/BlobData.h" |
53 #include "platform/network/HTTPParsers.h" | 53 #include "platform/network/HTTPParsers.h" |
54 #include "platform/network/ParsedContentType.h" | 54 #include "platform/network/ParsedContentType.h" |
55 #include "platform/network/ResourceError.h" | 55 #include "platform/network/ResourceError.h" |
56 #include "platform/network/ResourceRequest.h" | 56 #include "platform/network/ResourceRequest.h" |
57 #include "public/platform/WebURLRequest.h" | 57 #include "public/platform/WebURLRequest.h" |
58 #include "wtf/ArrayBuffer.h" | 58 #include "wtf/ArrayBuffer.h" |
59 #include "wtf/ArrayBufferView.h" | 59 #include "wtf/ArrayBufferView.h" |
60 #include "wtf/Assertions.h" | 60 #include "wtf/Assertions.h" |
61 #include "wtf/CurrentTime.h" | |
61 #include "wtf/RefCountedLeakCounter.h" | 62 #include "wtf/RefCountedLeakCounter.h" |
62 #include "wtf/StdLibExtras.h" | 63 #include "wtf/StdLibExtras.h" |
63 #include "wtf/text/CString.h" | 64 #include "wtf/text/CString.h" |
64 | 65 |
65 namespace blink { | 66 namespace blink { |
66 | 67 |
68 namespace { | |
tkent
2014/07/31 04:40:37
anonymous namespace is unnecessary.
|const| puts t
yhirano
2014/08/01 01:45:38
Done.
| |
69 | |
70 const double readyStateChangeFireInterval = 0.05; // 0.05s | |
tkent
2014/07/31 04:40:37
Why 0.05s? This needs a comment.
yhirano
2014/08/01 01:45:38
Done.
| |
71 | |
72 } // namespace | |
73 | |
67 DEFINE_DEBUG_ONLY_GLOBAL(WTF::RefCountedLeakCounter, xmlHttpRequestCounter, ("XM LHttpRequest")); | 74 DEFINE_DEBUG_ONLY_GLOBAL(WTF::RefCountedLeakCounter, xmlHttpRequestCounter, ("XM LHttpRequest")); |
68 | 75 |
69 struct XMLHttpRequestStaticData { | 76 struct XMLHttpRequestStaticData { |
70 WTF_MAKE_NONCOPYABLE(XMLHttpRequestStaticData); WTF_MAKE_FAST_ALLOCATED; | 77 WTF_MAKE_NONCOPYABLE(XMLHttpRequestStaticData); WTF_MAKE_FAST_ALLOCATED; |
71 public: | 78 public: |
72 XMLHttpRequestStaticData(); | 79 XMLHttpRequestStaticData(); |
73 String m_proxyHeaderPrefix; | 80 String m_proxyHeaderPrefix; |
74 String m_secHeaderPrefix; | 81 String m_secHeaderPrefix; |
75 HashSet<String, CaseFoldingHash> m_forbiddenRequestHeaders; | 82 HashSet<String, CaseFoldingHash> m_forbiddenRequestHeaders; |
76 }; | 83 }; |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
162 : ActiveDOMObject(context) | 169 : ActiveDOMObject(context) |
163 , m_timeoutMilliseconds(0) | 170 , m_timeoutMilliseconds(0) |
164 , m_state(UNSENT) | 171 , m_state(UNSENT) |
165 , m_downloadedBlobLength(0) | 172 , m_downloadedBlobLength(0) |
166 , m_receivedLength(0) | 173 , m_receivedLength(0) |
167 , m_lastSendLineNumber(0) | 174 , m_lastSendLineNumber(0) |
168 , m_exceptionCode(0) | 175 , m_exceptionCode(0) |
169 , m_progressEventThrottle(this) | 176 , m_progressEventThrottle(this) |
170 , m_responseTypeCode(ResponseTypeDefault) | 177 , m_responseTypeCode(ResponseTypeDefault) |
171 , m_securityOrigin(securityOrigin) | 178 , m_securityOrigin(securityOrigin) |
179 , m_previousReadyStateChangeFireTime(0) | |
172 , m_async(true) | 180 , m_async(true) |
173 , m_includeCredentials(false) | 181 , m_includeCredentials(false) |
174 , m_createdDocument(false) | 182 , m_createdDocument(false) |
175 , m_error(false) | 183 , m_error(false) |
176 , m_uploadEventsAllowed(true) | 184 , m_uploadEventsAllowed(true) |
177 , m_uploadComplete(false) | 185 , m_uploadComplete(false) |
178 , m_sameOriginRequest(true) | 186 , m_sameOriginRequest(true) |
179 { | 187 { |
180 initializeXMLHttpRequestStaticData(); | 188 initializeXMLHttpRequestStaticData(); |
181 #ifndef NDEBUG | 189 #ifndef NDEBUG |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
413 void XMLHttpRequest::trackProgress(int length) | 421 void XMLHttpRequest::trackProgress(int length) |
414 { | 422 { |
415 m_receivedLength += length; | 423 m_receivedLength += length; |
416 | 424 |
417 if (m_async) | 425 if (m_async) |
418 dispatchProgressEventFromSnapshot(EventTypeNames::progress); | 426 dispatchProgressEventFromSnapshot(EventTypeNames::progress); |
419 | 427 |
420 if (m_state != LOADING) { | 428 if (m_state != LOADING) { |
421 changeState(LOADING); | 429 changeState(LOADING); |
422 } else { | 430 } else { |
423 // Firefox calls readyStateChanged every time it receives data. Do | 431 // FIXME: Make our implementation and the spec consistent. This extra |
424 // the same to align with Firefox. | 432 // invocation of readystatechange event in LOADING state was needed |
425 // | 433 // when the progress event was not available. |
426 // FIXME: Make our implementation and the spec consistent. This | 434 double now = monotonicallyIncreasingTime(); |
427 // behavior was needed when the progress event was not available. | 435 bool shouldFire = now - m_previousReadyStateChangeFireTime >= readyState ChangeFireInterval; |
428 dispatchReadyStateChangeEvent(); | 436 if (shouldFire) { |
437 m_previousReadyStateChangeFireTime = now; | |
438 dispatchReadyStateChangeEvent(); | |
439 } | |
429 } | 440 } |
430 } | 441 } |
431 | 442 |
432 void XMLHttpRequest::changeState(State newState) | 443 void XMLHttpRequest::changeState(State newState) |
433 { | 444 { |
434 if (m_state != newState) { | 445 if (m_state != newState) { |
435 m_state = newState; | 446 m_state = newState; |
436 dispatchReadyStateChangeEvent(); | 447 dispatchReadyStateChangeEvent(); |
437 } | 448 } |
438 } | 449 } |
(...skipping 985 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1424 { | 1435 { |
1425 visitor->trace(m_responseBlob); | 1436 visitor->trace(m_responseBlob); |
1426 visitor->trace(m_responseStream); | 1437 visitor->trace(m_responseStream); |
1427 visitor->trace(m_responseDocument); | 1438 visitor->trace(m_responseDocument); |
1428 visitor->trace(m_progressEventThrottle); | 1439 visitor->trace(m_progressEventThrottle); |
1429 visitor->trace(m_upload); | 1440 visitor->trace(m_upload); |
1430 XMLHttpRequestEventTarget::trace(visitor); | 1441 XMLHttpRequestEventTarget::trace(visitor); |
1431 } | 1442 } |
1432 | 1443 |
1433 } // namespace blink | 1444 } // namespace blink |
OLD | NEW |