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

Side by Side Diff: Source/core/xml/XMLHttpRequest.cpp

Issue 14200030: Remove XMLHttpRequestException in favor of DOMException (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix tests after rebasing... Created 7 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/workers/WorkerContext.cpp ('k') | Source/core/xml/XMLHttpRequestException.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 #include "core/page/ContentSecurityPolicy.h" 48 #include "core/page/ContentSecurityPolicy.h"
49 #include "core/page/SecurityOrigin.h" 49 #include "core/page/SecurityOrigin.h"
50 #include "core/page/Settings.h" 50 #include "core/page/Settings.h"
51 #include "core/platform/HistogramSupport.h" 51 #include "core/platform/HistogramSupport.h"
52 #include "core/platform/SharedBuffer.h" 52 #include "core/platform/SharedBuffer.h"
53 #include "core/platform/network/BlobData.h" 53 #include "core/platform/network/BlobData.h"
54 #include "core/platform/network/HTTPParsers.h" 54 #include "core/platform/network/HTTPParsers.h"
55 #include "core/platform/network/ParsedContentType.h" 55 #include "core/platform/network/ParsedContentType.h"
56 #include "core/platform/network/ResourceError.h" 56 #include "core/platform/network/ResourceError.h"
57 #include "core/platform/network/ResourceRequest.h" 57 #include "core/platform/network/ResourceRequest.h"
58 #include "core/xml/XMLHttpRequestException.h"
59 #include "core/xml/XMLHttpRequestProgressEvent.h" 58 #include "core/xml/XMLHttpRequestProgressEvent.h"
60 #include "core/xml/XMLHttpRequestUpload.h" 59 #include "core/xml/XMLHttpRequestUpload.h"
61 #include <wtf/ArrayBuffer.h> 60 #include <wtf/ArrayBuffer.h>
62 #include <wtf/ArrayBufferView.h> 61 #include <wtf/ArrayBufferView.h>
63 #include <wtf/RefCountedLeakCounter.h> 62 #include <wtf/RefCountedLeakCounter.h>
64 #include <wtf/StdLibExtras.h> 63 #include <wtf/StdLibExtras.h>
65 #include <wtf/text/CString.h> 64 #include <wtf/text/CString.h>
66 #include <wtf/UnusedParam.h> 65 #include <wtf/UnusedParam.h>
67 66
68 namespace WebCore { 67 namespace WebCore {
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 { 704 {
706 m_requestEntityBody = formData ? formData->deepCopy() : 0; 705 m_requestEntityBody = formData ? formData->deepCopy() : 0;
707 createRequest(ec); 706 createRequest(ec);
708 m_exceptionCode = ec; 707 m_exceptionCode = ec;
709 } 708 }
710 709
711 void XMLHttpRequest::createRequest(ExceptionCode& ec) 710 void XMLHttpRequest::createRequest(ExceptionCode& ec)
712 { 711 {
713 // Only GET request is supported for blob URL. 712 // Only GET request is supported for blob URL.
714 if (m_url.protocolIs("blob") && m_method != "GET") { 713 if (m_url.protocolIs("blob") && m_method != "GET") {
715 ec = XMLHttpRequestException::NETWORK_ERR; 714 ec = NETWORK_ERR;
716 return; 715 return;
717 } 716 }
718 717
719 // The presence of upload event listeners forces us to use preflighting beca use POSTing to an URL that does not 718 // The presence of upload event listeners forces us to use preflighting beca use POSTing to an URL that does not
720 // permit cross origin requests should look exactly like POSTing to an URL t hat does not respond at all. 719 // permit cross origin requests should look exactly like POSTing to an URL t hat does not respond at all.
721 // Also, only async requests support upload progress events. 720 // Also, only async requests support upload progress events.
722 bool uploadEvents = false; 721 bool uploadEvents = false;
723 if (m_async) { 722 if (m_async) {
724 m_progressEventThrottle.dispatchEvent(XMLHttpRequestProgressEvent::creat e(eventNames().loadstartEvent)); 723 m_progressEventThrottle.dispatchEvent(XMLHttpRequestProgressEvent::creat e(eventNames().loadstartEvent));
725 if (m_requestEntityBody && m_upload) { 724 if (m_requestEntityBody && m_upload) {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 // and they are referenced by the JavaScript wrapper. 780 // and they are referenced by the JavaScript wrapper.
782 setPendingActivity(this); 781 setPendingActivity(this);
783 } 782 }
784 } else { 783 } else {
785 InspectorInstrumentation::willLoadXHRSynchronously(scriptExecutionContex t()); 784 InspectorInstrumentation::willLoadXHRSynchronously(scriptExecutionContex t());
786 ThreadableLoader::loadResourceSynchronously(scriptExecutionContext(), re quest, *this, options); 785 ThreadableLoader::loadResourceSynchronously(scriptExecutionContext(), re quest, *this, options);
787 InspectorInstrumentation::didLoadXHRSynchronously(scriptExecutionContext ()); 786 InspectorInstrumentation::didLoadXHRSynchronously(scriptExecutionContext ());
788 } 787 }
789 788
790 if (!m_exceptionCode && m_error) 789 if (!m_exceptionCode && m_error)
791 m_exceptionCode = XMLHttpRequestException::NETWORK_ERR; 790 m_exceptionCode = NETWORK_ERR;
792 ec = m_exceptionCode; 791 ec = m_exceptionCode;
793 } 792 }
794 793
795 void XMLHttpRequest::abort() 794 void XMLHttpRequest::abort()
796 { 795 {
797 // internalAbort() calls dropProtection(), which may release the last refere nce. 796 // internalAbort() calls dropProtection(), which may release the last refere nce.
798 RefPtr<XMLHttpRequest> protect(this); 797 RefPtr<XMLHttpRequest> protect(this);
799 798
800 bool sendFlag = m_loader; 799 bool sendFlag = m_loader;
801 800
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
1051 } 1050 }
1052 1051
1053 void XMLHttpRequest::didFail(const ResourceError& error) 1052 void XMLHttpRequest::didFail(const ResourceError& error)
1054 { 1053 {
1055 1054
1056 // If we are already in an error state, for instance we called abort(), bail out early. 1055 // If we are already in an error state, for instance we called abort(), bail out early.
1057 if (m_error) 1056 if (m_error)
1058 return; 1057 return;
1059 1058
1060 if (error.isCancellation()) { 1059 if (error.isCancellation()) {
1061 m_exceptionCode = XMLHttpRequestException::ABORT_ERR; 1060 m_exceptionCode = ABORT_ERR;
1062 abortError(); 1061 abortError();
1063 return; 1062 return;
1064 } 1063 }
1065 1064
1066 #if ENABLE(XHR_TIMEOUT) 1065 #if ENABLE(XHR_TIMEOUT)
1067 if (error.isTimeout()) { 1066 if (error.isTimeout()) {
1068 didTimeout(); 1067 didTimeout();
1069 return; 1068 return;
1070 } 1069 }
1071 #endif 1070 #endif
1072 1071
1073 // Network failures are already reported to Web Inspector by ResourceLoader. 1072 // Network failures are already reported to Web Inspector by ResourceLoader.
1074 if (error.domain() == errorDomainWebKitInternal) 1073 if (error.domain() == errorDomainWebKitInternal)
1075 logConsoleError(scriptExecutionContext(), "XMLHttpRequest cannot load " + error.failingURL() + ". " + error.localizedDescription()); 1074 logConsoleError(scriptExecutionContext(), "XMLHttpRequest cannot load " + error.failingURL() + ". " + error.localizedDescription());
1076 1075
1077 m_exceptionCode = XMLHttpRequestException::NETWORK_ERR; 1076 m_exceptionCode = NETWORK_ERR;
1078 networkError(); 1077 networkError();
1079 } 1078 }
1080 1079
1081 void XMLHttpRequest::didFailRedirectCheck() 1080 void XMLHttpRequest::didFailRedirectCheck()
1082 { 1081 {
1083 networkError(); 1082 networkError();
1084 } 1083 }
1085 1084
1086 void XMLHttpRequest::didFinishLoading(unsigned long identifier, double) 1085 void XMLHttpRequest::didFinishLoading(unsigned long identifier, double)
1087 { 1086 {
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
1198 void XMLHttpRequest::didTimeout() 1197 void XMLHttpRequest::didTimeout()
1199 { 1198 {
1200 // internalAbort() calls dropProtection(), which may release the last refere nce. 1199 // internalAbort() calls dropProtection(), which may release the last refere nce.
1201 RefPtr<XMLHttpRequest> protect(this); 1200 RefPtr<XMLHttpRequest> protect(this);
1202 internalAbort(); 1201 internalAbort();
1203 1202
1204 clearResponse(); 1203 clearResponse();
1205 clearRequest(); 1204 clearRequest();
1206 1205
1207 m_error = true; 1206 m_error = true;
1208 m_exceptionCode = XMLHttpRequestException::TIMEOUT_ERR; 1207 m_exceptionCode = TIMEOUT_ERR;
1209 1208
1210 if (!m_async) { 1209 if (!m_async) {
1211 m_state = DONE; 1210 m_state = DONE;
1212 m_exceptionCode = TIMEOUT_ERR; 1211 m_exceptionCode = TIMEOUT_ERR;
1213 return; 1212 return;
1214 } 1213 }
1215 1214
1216 changeState(DONE); 1215 changeState(DONE);
1217 1216
1218 if (!m_uploadComplete) { 1217 if (!m_uploadComplete) {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1290 info.addMember(m_responseDocument, "responseDocument"); 1289 info.addMember(m_responseDocument, "responseDocument");
1291 info.addMember(m_binaryResponseBuilder, "binaryResponseBuilder"); 1290 info.addMember(m_binaryResponseBuilder, "binaryResponseBuilder");
1292 info.addMember(m_responseArrayBuffer, "responseArrayBuffer"); 1291 info.addMember(m_responseArrayBuffer, "responseArrayBuffer");
1293 info.addMember(m_lastSendURL, "lastSendURL"); 1292 info.addMember(m_lastSendURL, "lastSendURL");
1294 info.addMember(m_eventTargetData, "eventTargetData"); 1293 info.addMember(m_eventTargetData, "eventTargetData");
1295 info.addMember(m_progressEventThrottle, "progressEventThrottle"); 1294 info.addMember(m_progressEventThrottle, "progressEventThrottle");
1296 info.addMember(m_securityOrigin, "securityOrigin"); 1295 info.addMember(m_securityOrigin, "securityOrigin");
1297 } 1296 }
1298 1297
1299 } // namespace WebCore 1298 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/workers/WorkerContext.cpp ('k') | Source/core/xml/XMLHttpRequestException.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698