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

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

Issue 1167563002: Sync the XHR-related interfaces with the spec (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: compile fix Created 5 years, 6 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
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 683 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 } 694 }
695 695
696 // FIXME: According to XMLHttpRequest Level 2 we should throw InvalidAccessE rror exception here. 696 // FIXME: According to XMLHttpRequest Level 2 we should throw InvalidAccessE rror exception here.
697 // However for time being only print warning message to warn web developers. 697 // However for time being only print warning message to warn web developers.
698 if (!m_async) 698 if (!m_async)
699 UseCounter::countDeprecation(executionContext(), UseCounter::SyncXHRWith Credentials); 699 UseCounter::countDeprecation(executionContext(), UseCounter::SyncXHRWith Credentials);
700 700
701 m_includeCredentials = value; 701 m_includeCredentials = value;
702 } 702 }
703 703
704 void XMLHttpRequest::open(const AtomicString& method, const String& url, Excepti onState& exceptionState) 704 void XMLHttpRequest::open(const AtomicString& method, const String& urlString, E xceptionState& exceptionState)
705 { 705 {
706 open(method, url, true, exceptionState); 706 open(method, executionContext()->completeURL(urlString), true, exceptionStat e);
707 } 707 }
708 708
709 void XMLHttpRequest::open(const AtomicString& method, const String& urlString, b ool async, ExceptionState& exceptionState) 709 void XMLHttpRequest::open(const AtomicString& method, const String& urlString, b ool async, const String& username, const String& password, ExceptionState& excep tionState)
710 { 710 {
711 open(method, executionContext()->completeURL(urlString), async, exceptionSta te); 711 KURL url(executionContext()->completeURL(urlString));
712 if (!username.isNull())
713 url.setUser(username);
714 if (!password.isNull())
715 url.setPass(password);
716
717 open(method, url, async, exceptionState);
712 } 718 }
713 719
714 void XMLHttpRequest::open(const AtomicString& method, const KURL& url, bool asyn c, ExceptionState& exceptionState) 720 void XMLHttpRequest::open(const AtomicString& method, const KURL& url, bool asyn c, ExceptionState& exceptionState)
715 { 721 {
716 WTF_LOG(Network, "XMLHttpRequest %p open('%s', '%s', %d)", this, method.utf8 ().data(), url.elidedString().utf8().data(), async); 722 WTF_LOG(Network, "XMLHttpRequest %p open('%s', '%s', %d)", this, method.utf8 ().data(), url.elidedString().utf8().data(), async);
717 723
718 if (!internalAbort()) 724 if (!internalAbort())
719 return; 725 return;
720 726
721 State previousState = m_state; 727 State previousState = m_state;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 ASSERT(!m_loader); 781 ASSERT(!m_loader);
776 782
777 // Check previous state to avoid dispatching readyState event 783 // Check previous state to avoid dispatching readyState event
778 // when calling open several times in a row. 784 // when calling open several times in a row.
779 if (previousState != OPENED) 785 if (previousState != OPENED)
780 changeState(OPENED); 786 changeState(OPENED);
781 else 787 else
782 m_state = OPENED; 788 m_state = OPENED;
783 } 789 }
784 790
785 void XMLHttpRequest::open(const AtomicString& method, const String& urlString, b ool async, const String& user, ExceptionState& exceptionState)
786 {
787 KURL urlWithCredentials(executionContext()->completeURL(urlString));
788 if (!user.isNull())
789 urlWithCredentials.setUser(user);
790
791 open(method, urlWithCredentials, async, exceptionState);
792 }
793
794 void XMLHttpRequest::open(const AtomicString& method, const String& urlString, b ool async, const String& user, const String& password, ExceptionState& exception State)
795 {
796 KURL urlWithCredentials(executionContext()->completeURL(urlString));
797 if (!user.isNull())
798 urlWithCredentials.setUser(user);
799 if (!password.isNull())
800 urlWithCredentials.setPass(password);
801
802 open(method, urlWithCredentials, async, exceptionState);
803 }
804
805 bool XMLHttpRequest::initSend(ExceptionState& exceptionState) 791 bool XMLHttpRequest::initSend(ExceptionState& exceptionState)
806 { 792 {
807 if (!executionContext()) 793 if (!executionContext())
808 return false; 794 return false;
809 795
810 if (m_state != OPENED || m_loader) { 796 if (m_state != OPENED || m_loader) {
811 exceptionState.throwDOMException(InvalidStateError, "The object's state must be OPENED."); 797 exceptionState.throwDOMException(InvalidStateError, "The object's state must be OPENED.");
812 return false; 798 return false;
813 } 799 }
814 800
815 m_error = false; 801 m_error = false;
816 return true; 802 return true;
817 } 803 }
818 804
819 void XMLHttpRequest::send(const ArrayBufferOrArrayBufferViewOrBlobOrDocumentOrSt ringOrFormData& data, ExceptionState& exceptionState) 805 void XMLHttpRequest::send(const ArrayBufferOrArrayBufferViewOrBlobOrDocumentOrSt ringOrFormData& data, ExceptionState& exceptionState)
820 { 806 {
807 InspectorInstrumentation::willSendXMLHttpRequest(executionContext(), url());
808
821 if (data.isNull()) { 809 if (data.isNull()) {
822 send(exceptionState); 810 send(String(), exceptionState);
823 return; 811 return;
824 } 812 }
825 813
826 InspectorInstrumentation::willSendXMLHttpRequest(executionContext(), url());
827 if (data.isArrayBuffer()) { 814 if (data.isArrayBuffer()) {
828 send(data.getAsArrayBuffer().get(), exceptionState); 815 send(data.getAsArrayBuffer().get(), exceptionState);
829 return; 816 return;
830 } 817 }
831 818
832 if (data.isArrayBufferView()) { 819 if (data.isArrayBufferView()) {
833 send(data.getAsArrayBufferView().get(), exceptionState); 820 send(data.getAsArrayBufferView().get(), exceptionState);
834 return; 821 return;
835 } 822 }
836 823
837 if (data.isBlob()) { 824 if (data.isBlob()) {
838 send(data.getAsBlob(), exceptionState); 825 send(data.getAsBlob(), exceptionState);
839 return; 826 return;
840 } 827 }
841 828
842 if (data.isDocument()) { 829 if (data.isDocument()) {
843 send(data.getAsDocument().get(), exceptionState); 830 send(data.getAsDocument().get(), exceptionState);
844 return; 831 return;
845 } 832 }
846 833
847 if (data.isFormData()) { 834 if (data.isFormData()) {
848 send(data.getAsFormData(), exceptionState); 835 send(data.getAsFormData(), exceptionState);
849 return; 836 return;
850 } 837 }
851 838
852 ASSERT(data.isString()); 839 ASSERT(data.isString());
853 send(data.getAsString(), exceptionState); 840 send(data.getAsString(), exceptionState);
854 } 841 }
855 842
856 void XMLHttpRequest::send(ExceptionState& exceptionState)
857 {
858 InspectorInstrumentation::willSendXMLHttpRequest(executionContext(), url());
859 send(String(), exceptionState);
860 }
861
862 bool XMLHttpRequest::areMethodAndURLValidForSend() 843 bool XMLHttpRequest::areMethodAndURLValidForSend()
863 { 844 {
864 return m_method != "GET" && m_method != "HEAD" && m_url.protocolIsInHTTPFami ly(); 845 return m_method != "GET" && m_method != "HEAD" && m_url.protocolIsInHTTPFami ly();
865 } 846 }
866 847
867 void XMLHttpRequest::send(Document* document, ExceptionState& exceptionState) 848 void XMLHttpRequest::send(Document* document, ExceptionState& exceptionState)
868 { 849 {
869 WTF_LOG(Network, "XMLHttpRequest %p send() Document %p", this, document); 850 WTF_LOG(Network, "XMLHttpRequest %p send() Document %p", this, document);
870 851
871 ASSERT(document); 852 ASSERT(document);
(...skipping 1012 matching lines...) Expand 10 before | Expand all | Expand 10 after
1884 visitor->trace(m_responseDocumentParser); 1865 visitor->trace(m_responseDocumentParser);
1885 visitor->trace(m_progressEventThrottle); 1866 visitor->trace(m_progressEventThrottle);
1886 visitor->trace(m_upload); 1867 visitor->trace(m_upload);
1887 visitor->trace(m_blobLoader); 1868 visitor->trace(m_blobLoader);
1888 XMLHttpRequestEventTarget::trace(visitor); 1869 XMLHttpRequestEventTarget::trace(visitor);
1889 DocumentParserClient::trace(visitor); 1870 DocumentParserClient::trace(visitor);
1890 ActiveDOMObject::trace(visitor); 1871 ActiveDOMObject::trace(visitor);
1891 } 1872 }
1892 1873
1893 } // namespace blink 1874 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698