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

Unified Diff: Source/core/xml/XMLHttpRequest.cpp

Issue 585873002: Show a warning when using sync xhr. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Document lifecycle enums used for beforeunload event tracking. Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
« Source/core/frame/UseCounter.cpp ('K') | « Source/core/frame/UseCounter.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/xml/XMLHttpRequest.cpp
diff --git a/Source/core/xml/XMLHttpRequest.cpp b/Source/core/xml/XMLHttpRequest.cpp
index 69986e041d2e82d180eab8f692b98c05f61ad237..dbfc7f853e3cbcfe29bf5ecbacc74b5e30494878 100644
--- a/Source/core/xml/XMLHttpRequest.cpp
+++ b/Source/core/xml/XMLHttpRequest.cpp
@@ -590,6 +590,13 @@ void XMLHttpRequest::open(const AtomicString& method, const KURL& url, bool asyn
exceptionState.throwDOMException(InvalidAccessError, "Synchronous requests must not set a timeout.");
return;
}
+
+ // Here we just warn that firing sync XHR's may affect responsiveness.
+ // Eventually sync xhr will be deprecated and an "InvalidAccessError" exception thrown.
+ // Refer : https://xhr.spec.whatwg.org/#sync-warning
+ // Use count for XHR synchronous requests on main thread only.
+ if (!document()->processingBeforeUnload())
kouhei (in TOK) 2014/10/07 23:21:18 Ditto: !unloadStarted() ?
+ UseCounter::countDeprecation(executionContext(), UseCounter::XMLHttpRequestSynchronous);
kouhei (in TOK) 2014/10/07 23:21:18 I don't think we should move callsite of existing
Mayur Kankanwadi 2014/10/08 10:14:25 If we use UseCounter::countDeprecation here, then
}
m_method = uppercaseKnownHTTPMethod(method);
@@ -879,11 +886,8 @@ void XMLHttpRequest::createRequest(PassRefPtr<FormData> httpBody, ExceptionState
// FIXME: Maybe create() can return null for other reasons too?
ASSERT(!m_loader);
m_loader = ThreadableLoader::create(executionContext, this, request, options, resourceLoaderOptions);
- } else {
- // Use count for XHR synchronous requests.
- UseCounter::count(&executionContext, UseCounter::XMLHttpRequestSynchronous);
+ } else
kouhei (in TOK) 2014/10/07 23:21:18 Ditto
ThreadableLoader::loadResourceSynchronously(executionContext, request, *this, options, resourceLoaderOptions);
- }
if (!m_exceptionCode && m_error)
m_exceptionCode = NetworkError;
« Source/core/frame/UseCounter.cpp ('K') | « Source/core/frame/UseCounter.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698