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 45 matching lines...) Loading... | |
56 #include "platform/SharedBuffer.h" | 56 #include "platform/SharedBuffer.h" |
57 #include "platform/blob/BlobData.h" | 57 #include "platform/blob/BlobData.h" |
58 #include "platform/network/HTTPParsers.h" | 58 #include "platform/network/HTTPParsers.h" |
59 #include "platform/network/ParsedContentType.h" | 59 #include "platform/network/ParsedContentType.h" |
60 #include "platform/network/ResourceError.h" | 60 #include "platform/network/ResourceError.h" |
61 #include "platform/network/ResourceRequest.h" | 61 #include "platform/network/ResourceRequest.h" |
62 #include "public/platform/WebURLRequest.h" | 62 #include "public/platform/WebURLRequest.h" |
63 #include "wtf/ArrayBuffer.h" | 63 #include "wtf/ArrayBuffer.h" |
64 #include "wtf/ArrayBufferView.h" | 64 #include "wtf/ArrayBufferView.h" |
65 #include "wtf/Assertions.h" | 65 #include "wtf/Assertions.h" |
66 #include "wtf/CurrentTime.h" | |
67 #include "wtf/RefCountedLeakCounter.h" | 66 #include "wtf/RefCountedLeakCounter.h" |
68 #include "wtf/StdLibExtras.h" | 67 #include "wtf/StdLibExtras.h" |
69 #include "wtf/text/CString.h" | 68 #include "wtf/text/CString.h" |
70 | 69 |
71 namespace blink { | 70 namespace blink { |
72 | 71 |
73 // To throttle readystatechange event fired when readystatechange is not | |
74 // changed, we don't dispatch the event within 50ms. | |
75 // As dispatching readystatechange when readystatechange is NOT changed is not | |
76 // specified, 50ms is not specified, too. | |
77 // We choose this value because progress event is dispatched every 50ms, but | |
78 // actually this value doesn't have to equal to the interval. | |
79 // Note: When readystate is actually changed readystatechange event must be | |
80 // dispatched no matter how recently dispatched the event was. | |
81 const double readyStateChangeFireInterval = 0.05; | |
82 | |
83 DEFINE_DEBUG_ONLY_GLOBAL(WTF::RefCountedLeakCounter, xmlHttpRequestCounter, ("XM LHttpRequest")); | 72 DEFINE_DEBUG_ONLY_GLOBAL(WTF::RefCountedLeakCounter, xmlHttpRequestCounter, ("XM LHttpRequest")); |
84 | 73 |
85 static bool isSetCookieHeader(const AtomicString& name) | 74 static bool isSetCookieHeader(const AtomicString& name) |
86 { | 75 { |
87 return equalIgnoringCase(name, "set-cookie") || equalIgnoringCase(name, "set -cookie2"); | 76 return equalIgnoringCase(name, "set-cookie") || equalIgnoringCase(name, "set -cookie2"); |
88 } | 77 } |
89 | 78 |
90 static void replaceCharsetInMediaType(String& mediaType, const String& charsetVa lue) | 79 static void replaceCharsetInMediaType(String& mediaType, const String& charsetVa lue) |
91 { | 80 { |
92 unsigned pos = 0, len = 0; | 81 unsigned pos = 0, len = 0; |
(...skipping 62 matching lines...) Loading... | |
155 : ActiveDOMObject(context) | 144 : ActiveDOMObject(context) |
156 , m_timeoutMilliseconds(0) | 145 , m_timeoutMilliseconds(0) |
157 , m_state(UNSENT) | 146 , m_state(UNSENT) |
158 , m_downloadedBlobLength(0) | 147 , m_downloadedBlobLength(0) |
159 , m_receivedLength(0) | 148 , m_receivedLength(0) |
160 , m_lastSendLineNumber(0) | 149 , m_lastSendLineNumber(0) |
161 , m_exceptionCode(0) | 150 , m_exceptionCode(0) |
162 , m_progressEventThrottle(this) | 151 , m_progressEventThrottle(this) |
163 , m_responseTypeCode(ResponseTypeDefault) | 152 , m_responseTypeCode(ResponseTypeDefault) |
164 , m_securityOrigin(securityOrigin) | 153 , m_securityOrigin(securityOrigin) |
165 , m_previousReadyStateChangeFireTime(0) | |
166 , m_async(true) | 154 , m_async(true) |
167 , m_includeCredentials(false) | 155 , m_includeCredentials(false) |
168 , m_parsedResponse(false) | 156 , m_parsedResponse(false) |
169 , m_error(false) | 157 , m_error(false) |
170 , m_uploadEventsAllowed(true) | 158 , m_uploadEventsAllowed(true) |
171 , m_uploadComplete(false) | 159 , m_uploadComplete(false) |
172 , m_sameOriginRequest(true) | 160 , m_sameOriginRequest(true) |
173 { | 161 { |
174 #ifndef NDEBUG | 162 #ifndef NDEBUG |
175 xmlHttpRequestCounter.increment(); | 163 xmlHttpRequestCounter.increment(); |
(...skipping 269 matching lines...) Loading... | |
445 void XMLHttpRequest::trackProgress(int length) | 433 void XMLHttpRequest::trackProgress(int length) |
446 { | 434 { |
447 m_receivedLength += length; | 435 m_receivedLength += length; |
448 | 436 |
449 if (m_async) | 437 if (m_async) |
450 dispatchProgressEventFromSnapshot(EventTypeNames::progress); | 438 dispatchProgressEventFromSnapshot(EventTypeNames::progress); |
451 | 439 |
452 if (m_state != LOADING) { | 440 if (m_state != LOADING) { |
453 changeState(LOADING); | 441 changeState(LOADING); |
454 } else { | 442 } else { |
455 // FIXME: Make our implementation and the spec consistent. This extra | 443 // Firefox calls readyStateChanged every time it receives data. Do |
tyoshino (SeeGerritForStatus)
2014/08/19 10:22:17
Changed -> Change
maybe my mistake...
yhirano1
2014/08/19 10:34:50
I will fix it in the future.
| |
456 // invocation of readystatechange event in LOADING state was needed | 444 // the same to align with Firefox. |
457 // when the progress event was not available. | 445 // |
458 double now = monotonicallyIncreasingTime(); | 446 // FIXME: Make our implementation and the spec consistent. This |
459 bool shouldFire = now - m_previousReadyStateChangeFireTime >= readyState ChangeFireInterval; | 447 // behavior was needed when the progress event was not available. |
460 if (shouldFire) { | 448 dispatchReadyStateChangeEvent(); |
461 m_previousReadyStateChangeFireTime = now; | |
462 dispatchReadyStateChangeEvent(); | |
463 } | |
464 } | 449 } |
465 } | 450 } |
466 | 451 |
467 void XMLHttpRequest::changeState(State newState) | 452 void XMLHttpRequest::changeState(State newState) |
468 { | 453 { |
469 if (m_state != newState) { | 454 if (m_state != newState) { |
470 m_state = newState; | 455 m_state = newState; |
471 dispatchReadyStateChangeEvent(); | 456 dispatchReadyStateChangeEvent(); |
472 } | 457 } |
473 } | 458 } |
(...skipping 1011 matching lines...) Loading... | |
1485 visitor->trace(m_responseLegacyStream); | 1470 visitor->trace(m_responseLegacyStream); |
1486 visitor->trace(m_responseStream); | 1471 visitor->trace(m_responseStream); |
1487 visitor->trace(m_streamSource); | 1472 visitor->trace(m_streamSource); |
1488 visitor->trace(m_responseDocument); | 1473 visitor->trace(m_responseDocument); |
1489 visitor->trace(m_progressEventThrottle); | 1474 visitor->trace(m_progressEventThrottle); |
1490 visitor->trace(m_upload); | 1475 visitor->trace(m_upload); |
1491 XMLHttpRequestEventTarget::trace(visitor); | 1476 XMLHttpRequestEventTarget::trace(visitor); |
1492 } | 1477 } |
1493 | 1478 |
1494 } // namespace blink | 1479 } // namespace blink |
OLD | NEW |