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

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

Issue 2610653002: Tidy up XMLHttpRequest::endLoading(). (Closed)
Patch Set: 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2005-2007 Alexey Proskuryakov <ap@webkit.org> 3 * Copyright (C) 2005-2007 Alexey Proskuryakov <ap@webkit.org>
4 * Copyright (C) 2007, 2008 Julien Chaffraix <jchaffraix@webkit.org> 4 * Copyright (C) 2007, 2008 Julien Chaffraix <jchaffraix@webkit.org>
5 * Copyright (C) 2008, 2011 Google Inc. All rights reserved. 5 * Copyright (C) 2008, 2011 Google Inc. All rights reserved.
6 * Copyright (C) 2012 Intel Corporation 6 * Copyright (C) 2012 Intel Corporation
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public 9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 #include "platform/network/HTTPParsers.h" 71 #include "platform/network/HTTPParsers.h"
72 #include "platform/network/NetworkLog.h" 72 #include "platform/network/NetworkLog.h"
73 #include "platform/network/ParsedContentType.h" 73 #include "platform/network/ParsedContentType.h"
74 #include "platform/network/ResourceError.h" 74 #include "platform/network/ResourceError.h"
75 #include "platform/network/ResourceRequest.h" 75 #include "platform/network/ResourceRequest.h"
76 #include "platform/weborigin/SecurityOrigin.h" 76 #include "platform/weborigin/SecurityOrigin.h"
77 #include "platform/weborigin/SecurityPolicy.h" 77 #include "platform/weborigin/SecurityPolicy.h"
78 #include "platform/weborigin/Suborigin.h" 78 #include "platform/weborigin/Suborigin.h"
79 #include "public/platform/WebURLRequest.h" 79 #include "public/platform/WebURLRequest.h"
80 #include "wtf/Assertions.h" 80 #include "wtf/Assertions.h"
81 #include "wtf/AutoReset.h"
81 #include "wtf/StdLibExtras.h" 82 #include "wtf/StdLibExtras.h"
82 #include "wtf/text/CString.h" 83 #include "wtf/text/CString.h"
83 #include <memory> 84 #include <memory>
84 85
85 namespace blink { 86 namespace blink {
86 87
87 namespace { 88 namespace {
88 89
89 // This class protects the wrapper of the associated XMLHttpRequest object 90 // This class protects the wrapper of the associated XMLHttpRequest object
90 // via hasPendingActivity method which returns true if 91 // via hasPendingActivity method which returns true if
(...skipping 1506 matching lines...) Expand 10 before | Expand all | Expand 10 after
1597 m_parsedResponse = true; 1598 m_parsedResponse = true;
1598 1599
1599 endLoading(); 1600 endLoading();
1600 } 1601 }
1601 1602
1602 void XMLHttpRequest::endLoading() { 1603 void XMLHttpRequest::endLoading() {
1603 InspectorInstrumentation::didFinishXHRLoading(getExecutionContext(), this, 1604 InspectorInstrumentation::didFinishXHRLoading(getExecutionContext(), this,
1604 this, m_method, m_url); 1605 this, m_method, m_url);
1605 1606
1606 if (m_loader) { 1607 if (m_loader) {
1607 const bool hasError = m_error;
1608 // Set |m_error| in order to suppress the cancel notification (see 1608 // Set |m_error| in order to suppress the cancel notification (see
1609 // XMLHttpRequest::didFail). 1609 // XMLHttpRequest::didFail).
1610 m_error = true; 1610 AutoReset<bool> scope(&m_error, true);
1611 m_loader->cancel(); 1611 m_loader.release()->cancel();
1612 m_error = hasError;
1613 m_loader = nullptr;
1614 } 1612 }
1615 1613
1616 m_sendFlag = false; 1614 m_sendFlag = false;
1617 changeState(kDone); 1615 changeState(kDone);
1618 1616
1619 if (!getExecutionContext() || !getExecutionContext()->isDocument() || 1617 if (!getExecutionContext() || !getExecutionContext()->isDocument())
1620 !document() || !document()->frame() || !document()->frame()->page())
1621 return; 1618 return;
1622 1619
1623 if (status() >= 200 && status() < 300) { 1620 if (document() && document()->frame() && document()->frame()->page() &&
1621 FetchUtils::isSuccessfulStatusCode(status()))
1624 document()->frame()->page()->chromeClient().ajaxSucceeded( 1622 document()->frame()->page()->chromeClient().ajaxSucceeded(
1625 document()->frame()); 1623 document()->frame());
1626 }
1627 } 1624 }
1628 1625
1629 void XMLHttpRequest::didSendData(unsigned long long bytesSent, 1626 void XMLHttpRequest::didSendData(unsigned long long bytesSent,
1630 unsigned long long totalBytesToBeSent) { 1627 unsigned long long totalBytesToBeSent) {
1631 NETWORK_DVLOG(1) << this << " didSendData(" << bytesSent << ", " 1628 NETWORK_DVLOG(1) << this << " didSendData(" << bytesSent << ", "
1632 << totalBytesToBeSent << ")"; 1629 << totalBytesToBeSent << ")";
1633 ScopedEventDispatchProtect protect(&m_eventDispatchRecursionLevel); 1630 ScopedEventDispatchProtect protect(&m_eventDispatchRecursionLevel);
1634 1631
1635 if (!m_upload) 1632 if (!m_upload)
1636 return; 1633 return;
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
1846 visitor->traceWrappers(m_responseDocument); 1843 visitor->traceWrappers(m_responseDocument);
1847 visitor->traceWrappers(m_responseArrayBuffer); 1844 visitor->traceWrappers(m_responseArrayBuffer);
1848 XMLHttpRequestEventTarget::traceWrappers(visitor); 1845 XMLHttpRequestEventTarget::traceWrappers(visitor);
1849 } 1846 }
1850 1847
1851 std::ostream& operator<<(std::ostream& ostream, const XMLHttpRequest* xhr) { 1848 std::ostream& operator<<(std::ostream& ostream, const XMLHttpRequest* xhr) {
1852 return ostream << "XMLHttpRequest " << static_cast<const void*>(xhr); 1849 return ostream << "XMLHttpRequest " << static_cast<const void*>(xhr);
1853 } 1850 }
1854 1851
1855 } // namespace blink 1852 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698