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

Issue 2427553002: Fix XHR's logic to determine whether or not to dispatch upload progress events

Created:
4 years, 2 months ago by tyoshino (SeeGerritForStatus)
Modified:
4 years, 2 months ago
Reviewers:
yhirano
CC:
chromium-reviews, blink-reviews, tyoshino+watch_chromium.org
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Fix XHR's logic to determine whether or not to dispatch upload progress events Fix the m_uploadEventsAllowed variable (renamed by this commit to m_uploadListenerFlag) to become true if and only if there're one or more event handlers registered with the upload attribute. Here's the background of the bug. 1. The m_uploadEventsAllowed variable has been introduced to XMLHttpRequest.cpp in http://crrev.com/405043c1ec2ad3dbb9ed711adc698c7d865923b6 to issue a preflight when there're one or more event handlers registered with the upload attribute even when the request is simple. This commit included one bug that the variable is set to true even when m_async is not set for same origin requests, but was correct in terms of handling of same/cross origin and simpleness of a request. 2. http://crrev.com/2c580376f830a33f06f2dd980c532e9e12498571 has mistakenly refactored the logic to set m_uploadEventsAllowed to true only when the request is not a simple request. 3. http://crrev.com/a5c5e927f63f72d121b62ddf6c1d9f093555e516 has fixed the bug partially by setting m_uploadEventsAllowed to true when the request is same origin. 4. http://crrev.com/03fac94860bfc63750af994932d3d38bd9335b3c has fixed the bug to set m_uploadEventsAllowed to true when there're one or more event handlers registered with the upload attribute as the spec says. But there're still unwanted variables left in the formula calculating m_uploadEventsAllowed, i.e. m_sameOriginRequest and the FetchUtils::isSimpleRequest() call. m_uploadEventsAllowed and m_uploadComplete are renamed to make the correspondence with the spec term clearer. setReportUploadProgress() was called if and only if m_upload was not NULL. But didSendData() was no-op (except for m_uploadComplete updating but it's also used only for controlling handler invocation on m_upload) when m_uploadEventAllowed is false. So, change the condition to call setReportUnloadProgress() to be based on m_uploadListenerFlag. The only incompatibility this patch will introduce is that as long as xhr.upload was touched before xhr.send() and the request is either same origin or non-simple, we could set handlers to xhr.upload after xhr.send() call to receive upload progress events. I think this wouldn't have big impact. This CL also removed m_httpBody from the condition. But this doesn't fix the issue that the upload progress events are not dispatched when no payload is given to send() call since didSendData() is not invoked for zero length request body. BUG=none

Patch Set 1 : a #

Patch Set 2 : a #

Total comments: 6

Messages

Total messages: 18 (15 generated)
tyoshino (SeeGerritForStatus)
Found while checking dependency to SecurityOrigin in XMLHttpRequest.cpp.
4 years, 2 months ago (2016-10-19 09:01:41 UTC) #13
yhirano
description: "setReportUnloadProgress" should be "setReportUploadProgress". https://codereview.chromium.org/2427553002/diff/40001/third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp File third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp (right): https://codereview.chromium.org/2427553002/diff/40001/third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp#newcode943 third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp:943: m_uploadListenerFlag = false; In ...
4 years, 2 months ago (2016-10-20 11:27:54 UTC) #17
yhirano
4 years, 2 months ago (2016-10-20 12:17:02 UTC) #18
https://codereview.chromium.org/2427553002/diff/40001/third_party/WebKit/Sour...
File third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp (right):

https://codereview.chromium.org/2427553002/diff/40001/third_party/WebKit/Sour...
third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp:1639:
DCHECK(m_async);
You call setReportUploadProgress only when m_uploadListenerFlag is set. Can we
have DCHECK(m_uploadListenerFlag)?

https://codereview.chromium.org/2427553002/diff/40001/third_party/WebKit/Sour...
third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp:1648: 
Not related to this CL but we may need an early-return here for the case where
open and/or send are called in the progress handler.

Powered by Google App Engine
This is Rietveld 408576698