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

Side by Side Diff: third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequestUpload.cpp

Issue 2746333002: DevTools: move recurring flag into AsyncTask, control cancelation from embedder only. (Closed)
Patch Set: Created 3 years, 9 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
OLDNEW
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
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");
56 asyncTask.setEnabled(m_xmlHttpRequest->isAsync());
56 dispatchEvent(ProgressEvent::create(EventTypeNames::progress, true, bytesSent, 57 dispatchEvent(ProgressEvent::create(EventTypeNames::progress, true, bytesSent,
57 totalBytesToBeSent)); 58 totalBytesToBeSent));
58 } 59 }
59 60
60 void XMLHttpRequestUpload::dispatchEventAndLoadEnd(const AtomicString& type, 61 void XMLHttpRequestUpload::dispatchEventAndLoadEnd(const AtomicString& type,
61 bool lengthComputable, 62 bool lengthComputable,
62 unsigned long long bytesSent, 63 unsigned long long bytesSent,
63 unsigned long long total) { 64 unsigned long long total) {
64 DCHECK(type == EventTypeNames::load || type == EventTypeNames::abort || 65 DCHECK(type == EventTypeNames::load || type == EventTypeNames::abort ||
65 type == EventTypeNames::error || type == EventTypeNames::timeout); 66 type == EventTypeNames::error || type == EventTypeNames::timeout);
66 probe::AsyncTask asyncTask(getExecutionContext(), m_xmlHttpRequest, 67 probe::AsyncTask asyncTask(getExecutionContext(), m_xmlHttpRequest, "event");
67 m_xmlHttpRequest->isAsync()); 68 asyncTask.setEnabled(m_xmlHttpRequest->isAsync());
68 dispatchEvent( 69 dispatchEvent(
69 ProgressEvent::create(type, lengthComputable, bytesSent, total)); 70 ProgressEvent::create(type, lengthComputable, bytesSent, total));
70 dispatchEvent(ProgressEvent::create(EventTypeNames::loadend, lengthComputable, 71 dispatchEvent(ProgressEvent::create(EventTypeNames::loadend, lengthComputable,
71 bytesSent, total)); 72 bytesSent, total));
72 } 73 }
73 74
74 void XMLHttpRequestUpload::handleRequestError(const AtomicString& type) { 75 void XMLHttpRequestUpload::handleRequestError(const AtomicString& type) {
75 bool lengthComputable = m_lastTotalBytesToBeSent > 0 && 76 bool lengthComputable = m_lastTotalBytesToBeSent > 0 &&
76 m_lastBytesSent <= m_lastTotalBytesToBeSent; 77 m_lastBytesSent <= m_lastTotalBytesToBeSent;
77 probe::AsyncTask asyncTask(getExecutionContext(), m_xmlHttpRequest, 78 probe::AsyncTask asyncTask(getExecutionContext(), m_xmlHttpRequest, "error");
78 m_xmlHttpRequest->isAsync()); 79 asyncTask.setEnabled(m_xmlHttpRequest->isAsync());
79 dispatchEvent(ProgressEvent::create(EventTypeNames::progress, 80 dispatchEvent(ProgressEvent::create(EventTypeNames::progress,
80 lengthComputable, m_lastBytesSent, 81 lengthComputable, m_lastBytesSent,
81 m_lastTotalBytesToBeSent)); 82 m_lastTotalBytesToBeSent));
82 dispatchEventAndLoadEnd(type, lengthComputable, m_lastBytesSent, 83 dispatchEventAndLoadEnd(type, lengthComputable, m_lastBytesSent,
83 m_lastTotalBytesToBeSent); 84 m_lastTotalBytesToBeSent);
84 } 85 }
85 86
86 DEFINE_TRACE(XMLHttpRequestUpload) { 87 DEFINE_TRACE(XMLHttpRequestUpload) {
87 visitor->trace(m_xmlHttpRequest); 88 visitor->trace(m_xmlHttpRequest);
88 XMLHttpRequestEventTarget::trace(visitor); 89 XMLHttpRequestEventTarget::trace(visitor);
89 } 90 }
90 91
91 } // namespace blink 92 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698