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

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

Issue 1030613002: [bindings] Make XMLHttpRequest.send() use the generated binding code over the custom one. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Patch for landing Created 5 years, 9 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
11 * version 2 of the License, or (at your option) any later version. 11 * version 2 of the License, or (at your option) any later version.
12 * 12 *
13 * This library is distributed in the hope that it will be useful, 13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details. 16 * Lesser General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU Lesser General Public 18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software 19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 U SA 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 U SA
21 */ 21 */
22 22
23 #include "config.h" 23 #include "config.h"
24 #include "core/xmlhttprequest/XMLHttpRequest.h" 24 #include "core/xmlhttprequest/XMLHttpRequest.h"
25 25
26 #include "bindings/core/v8/ExceptionState.h" 26 #include "bindings/core/v8/ExceptionState.h"
27 #include "bindings/core/v8/UnionTypesCore.h"
27 #include "core/dom/ContextFeatures.h" 28 #include "core/dom/ContextFeatures.h"
28 #include "core/dom/DOMArrayBuffer.h" 29 #include "core/dom/DOMArrayBuffer.h"
29 #include "core/dom/DOMArrayBufferView.h" 30 #include "core/dom/DOMArrayBufferView.h"
30 #include "core/dom/DOMException.h" 31 #include "core/dom/DOMException.h"
31 #include "core/dom/DOMImplementation.h" 32 #include "core/dom/DOMImplementation.h"
32 #include "core/dom/DOMTypedArray.h" 33 #include "core/dom/DOMTypedArray.h"
33 #include "core/dom/DocumentParser.h" 34 #include "core/dom/DocumentParser.h"
34 #include "core/dom/ExceptionCode.h" 35 #include "core/dom/ExceptionCode.h"
35 #include "core/dom/XMLDocument.h" 36 #include "core/dom/XMLDocument.h"
36 #include "core/editing/markup.h" 37 #include "core/editing/markup.h"
(...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 787
787 if (m_state != OPENED || m_loader) { 788 if (m_state != OPENED || m_loader) {
788 exceptionState.throwDOMException(InvalidStateError, "The object's state must be OPENED."); 789 exceptionState.throwDOMException(InvalidStateError, "The object's state must be OPENED.");
789 return false; 790 return false;
790 } 791 }
791 792
792 m_error = false; 793 m_error = false;
793 return true; 794 return true;
794 } 795 }
795 796
797 void XMLHttpRequest::send(const ArrayBufferOrArrayBufferViewOrBlobOrDocumentOrSt ringOrFormData& data, ExceptionState& exceptionState)
798 {
799 if (data.isNull()) {
800 send(exceptionState);
801 return;
802 }
803
804 InspectorInstrumentation::willSendXMLHttpRequest(executionContext(), url());
805 if (data.isArrayBuffer()) {
806 send(data.getAsArrayBuffer().get(), exceptionState);
807 return;
808 }
809
810 if (data.isArrayBufferView()) {
811 send(data.getAsArrayBufferView().get(), exceptionState);
812 return;
813 }
814
815 if (data.isBlob()) {
816 send(data.getAsBlob(), exceptionState);
817 return;
818 }
819
820 if (data.isDocument()) {
821 send(data.getAsDocument().get(), exceptionState);
822 return;
823 }
824
825 if (data.isFormData()) {
826 send(data.getAsFormData().get(), exceptionState);
827 return;
828 }
829
830 ASSERT(data.isString());
831 send(data.getAsString(), exceptionState);
832 }
833
796 void XMLHttpRequest::send(ExceptionState& exceptionState) 834 void XMLHttpRequest::send(ExceptionState& exceptionState)
797 { 835 {
836 InspectorInstrumentation::willSendXMLHttpRequest(executionContext(), url());
798 send(String(), exceptionState); 837 send(String(), exceptionState);
799 } 838 }
800 839
801 bool XMLHttpRequest::areMethodAndURLValidForSend() 840 bool XMLHttpRequest::areMethodAndURLValidForSend()
802 { 841 {
803 return m_method != "GET" && m_method != "HEAD" && m_url.protocolIsInHTTPFami ly(); 842 return m_method != "GET" && m_method != "HEAD" && m_url.protocolIsInHTTPFami ly();
804 } 843 }
805 844
806 void XMLHttpRequest::send(Document* document, ExceptionState& exceptionState) 845 void XMLHttpRequest::send(Document* document, ExceptionState& exceptionState)
807 { 846 {
(...skipping 1019 matching lines...) Expand 10 before | Expand all | Expand 10 after
1827 visitor->trace(m_responseDocumentParser); 1866 visitor->trace(m_responseDocumentParser);
1828 visitor->trace(m_progressEventThrottle); 1867 visitor->trace(m_progressEventThrottle);
1829 visitor->trace(m_upload); 1868 visitor->trace(m_upload);
1830 visitor->trace(m_blobLoader); 1869 visitor->trace(m_blobLoader);
1831 XMLHttpRequestEventTarget::trace(visitor); 1870 XMLHttpRequestEventTarget::trace(visitor);
1832 DocumentParserClient::trace(visitor); 1871 DocumentParserClient::trace(visitor);
1833 ActiveDOMObject::trace(visitor); 1872 ActiveDOMObject::trace(visitor);
1834 } 1873 }
1835 1874
1836 } // namespace blink 1875 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/xmlhttprequest/XMLHttpRequest.h ('k') | Source/core/xmlhttprequest/XMLHttpRequest.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698