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

Unified Diff: third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp

Issue 2610653002: Tidy up XMLHttpRequest::endLoading(). (Closed)
Patch Set: alpha conversion + use it at two more call sites Created 3 years, 11 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
Index: third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp
diff --git a/third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp b/third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp
index 21df5410f6d061dd15ce66f08bea2ea2a21066a6..e2c7f10d550bfc39a052aebbc8bbab786af2a00f 100644
--- a/third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp
+++ b/third_party/WebKit/Source/core/xmlhttprequest/XMLHttpRequest.cpp
@@ -78,6 +78,7 @@
#include "platform/weborigin/Suborigin.h"
#include "public/platform/WebURLRequest.h"
#include "wtf/Assertions.h"
+#include "wtf/AutoReset.h"
#include "wtf/StdLibExtras.h"
#include "wtf/text/CString.h"
#include <memory>
@@ -1604,26 +1605,22 @@ void XMLHttpRequest::endLoading() {
this, m_method, m_url);
if (m_loader) {
- const bool hasError = m_error;
// Set |m_error| in order to suppress the cancel notification (see
// XMLHttpRequest::didFail).
- m_error = true;
- m_loader->cancel();
- m_error = hasError;
- m_loader = nullptr;
+ AutoReset<bool> scope(&m_error, true);
+ m_loader.release()->cancel();
}
m_sendFlag = false;
changeState(kDone);
- if (!getExecutionContext() || !getExecutionContext()->isDocument() ||
- !document() || !document()->frame() || !document()->frame()->page())
+ if (!getExecutionContext() || !getExecutionContext()->isDocument())
return;
- if (status() >= 200 && status() < 300) {
+ if (document() && document()->frame() && document()->frame()->page() &&
+ FetchUtils::isOkStatus(status()))
document()->frame()->page()->chromeClient().ajaxSucceeded(
document()->frame());
- }
}
void XMLHttpRequest::didSendData(unsigned long long bytesSent,
« no previous file with comments | « third_party/WebKit/Source/core/loader/DocumentLoader.cpp ('k') | third_party/WebKit/Source/modules/fetch/FetchManager.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698