| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 ExecutionContext* XMLHttpRequestUpload::getExecutionContext() const { | 45 ExecutionContext* XMLHttpRequestUpload::getExecutionContext() const { |
| 46 return m_xmlHttpRequest->getExecutionContext(); | 46 return m_xmlHttpRequest->getExecutionContext(); |
| 47 } | 47 } |
| 48 | 48 |
| 49 void XMLHttpRequestUpload::dispatchProgressEvent( | 49 void XMLHttpRequestUpload::dispatchProgressEvent( |
| 50 unsigned long long bytesSent, | 50 unsigned long long bytesSent, |
| 51 unsigned long long totalBytesToBeSent) { | 51 unsigned long long totalBytesToBeSent) { |
| 52 m_lastBytesSent = bytesSent; | 52 m_lastBytesSent = bytesSent; |
| 53 m_lastTotalBytesToBeSent = totalBytesToBeSent; | 53 m_lastTotalBytesToBeSent = totalBytesToBeSent; |
| 54 probe::AsyncTask asyncTask(getExecutionContext(), m_xmlHttpRequest, | 54 probe::AsyncTask asyncTask(getExecutionContext(), m_xmlHttpRequest, |
| 55 m_xmlHttpRequest->isAsync()); | 55 "progress", m_xmlHttpRequest->isAsync()); |
| 56 dispatchEvent(ProgressEvent::create(EventTypeNames::progress, true, bytesSent, | 56 dispatchEvent(ProgressEvent::create(EventTypeNames::progress, true, bytesSent, |
| 57 totalBytesToBeSent)); | 57 totalBytesToBeSent)); |
| 58 } | 58 } |
| 59 | 59 |
| 60 void XMLHttpRequestUpload::dispatchEventAndLoadEnd(const AtomicString& type, | 60 void XMLHttpRequestUpload::dispatchEventAndLoadEnd(const AtomicString& type, |
| 61 bool lengthComputable, | 61 bool lengthComputable, |
| 62 unsigned long long bytesSent, | 62 unsigned long long bytesSent, |
| 63 unsigned long long total) { | 63 unsigned long long total) { |
| 64 DCHECK(type == EventTypeNames::load || type == EventTypeNames::abort || | 64 DCHECK(type == EventTypeNames::load || type == EventTypeNames::abort || |
| 65 type == EventTypeNames::error || type == EventTypeNames::timeout); | 65 type == EventTypeNames::error || type == EventTypeNames::timeout); |
| 66 probe::AsyncTask asyncTask(getExecutionContext(), m_xmlHttpRequest, | 66 probe::AsyncTask asyncTask(getExecutionContext(), m_xmlHttpRequest, "event", |
| 67 m_xmlHttpRequest->isAsync()); | 67 m_xmlHttpRequest->isAsync()); |
| 68 dispatchEvent( | 68 dispatchEvent( |
| 69 ProgressEvent::create(type, lengthComputable, bytesSent, total)); | 69 ProgressEvent::create(type, lengthComputable, bytesSent, total)); |
| 70 dispatchEvent(ProgressEvent::create(EventTypeNames::loadend, lengthComputable, | 70 dispatchEvent(ProgressEvent::create(EventTypeNames::loadend, lengthComputable, |
| 71 bytesSent, total)); | 71 bytesSent, total)); |
| 72 } | 72 } |
| 73 | 73 |
| 74 void XMLHttpRequestUpload::handleRequestError(const AtomicString& type) { | 74 void XMLHttpRequestUpload::handleRequestError(const AtomicString& type) { |
| 75 bool lengthComputable = m_lastTotalBytesToBeSent > 0 && | 75 bool lengthComputable = m_lastTotalBytesToBeSent > 0 && |
| 76 m_lastBytesSent <= m_lastTotalBytesToBeSent; | 76 m_lastBytesSent <= m_lastTotalBytesToBeSent; |
| 77 probe::AsyncTask asyncTask(getExecutionContext(), m_xmlHttpRequest, | 77 probe::AsyncTask asyncTask(getExecutionContext(), m_xmlHttpRequest, "error", |
| 78 m_xmlHttpRequest->isAsync()); | 78 m_xmlHttpRequest->isAsync()); |
| 79 dispatchEvent(ProgressEvent::create(EventTypeNames::progress, | 79 dispatchEvent(ProgressEvent::create(EventTypeNames::progress, |
| 80 lengthComputable, m_lastBytesSent, | 80 lengthComputable, m_lastBytesSent, |
| 81 m_lastTotalBytesToBeSent)); | 81 m_lastTotalBytesToBeSent)); |
| 82 dispatchEventAndLoadEnd(type, lengthComputable, m_lastBytesSent, | 82 dispatchEventAndLoadEnd(type, lengthComputable, m_lastBytesSent, |
| 83 m_lastTotalBytesToBeSent); | 83 m_lastTotalBytesToBeSent); |
| 84 } | 84 } |
| 85 | 85 |
| 86 DEFINE_TRACE(XMLHttpRequestUpload) { | 86 DEFINE_TRACE(XMLHttpRequestUpload) { |
| 87 visitor->trace(m_xmlHttpRequest); | 87 visitor->trace(m_xmlHttpRequest); |
| 88 XMLHttpRequestEventTarget::trace(visitor); | 88 XMLHttpRequestEventTarget::trace(visitor); |
| 89 } | 89 } |
| 90 | 90 |
| 91 } // namespace blink | 91 } // namespace blink |
| OLD | NEW |