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

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

Issue 2240053002: Replace WTF_LOG() with NETWORK_DVLOG() or RESOURCE_LOADING_DVLOG(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sstream, EXPECT_STREQ Created 4 years, 4 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 #include "core/inspector/InspectorInstrumentation.h" 58 #include "core/inspector/InspectorInstrumentation.h"
59 #include "core/inspector/InspectorTraceEvents.h" 59 #include "core/inspector/InspectorTraceEvents.h"
60 #include "core/loader/ThreadableLoader.h" 60 #include "core/loader/ThreadableLoader.h"
61 #include "core/page/ChromeClient.h" 61 #include "core/page/ChromeClient.h"
62 #include "core/page/Page.h" 62 #include "core/page/Page.h"
63 #include "core/streams/Stream.h" 63 #include "core/streams/Stream.h"
64 #include "core/xmlhttprequest/XMLHttpRequestUpload.h" 64 #include "core/xmlhttprequest/XMLHttpRequestUpload.h"
65 #include "platform/FileMetadata.h" 65 #include "platform/FileMetadata.h"
66 #include "platform/HTTPNames.h" 66 #include "platform/HTTPNames.h"
67 #include "platform/Histogram.h" 67 #include "platform/Histogram.h"
68 #include "platform/Logging.h"
69 #include "platform/RuntimeEnabledFeatures.h" 68 #include "platform/RuntimeEnabledFeatures.h"
70 #include "platform/SharedBuffer.h" 69 #include "platform/SharedBuffer.h"
71 #include "platform/blob/BlobData.h" 70 #include "platform/blob/BlobData.h"
72 #include "platform/network/HTTPParsers.h" 71 #include "platform/network/HTTPParsers.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 "public/platform/WebURLRequest.h" 76 #include "public/platform/WebURLRequest.h"
77 #include "wtf/Assertions.h" 77 #include "wtf/Assertions.h"
78 #include "wtf/StdLibExtras.h" 78 #include "wtf/StdLibExtras.h"
79 #include "wtf/text/CString.h" 79 #include "wtf/text/CString.h"
80 #include <memory> 80 #include <memory>
81 81
82 namespace blink { 82 namespace blink {
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 if (!username.isNull()) 545 if (!username.isNull())
546 url.setUser(username); 546 url.setUser(username);
547 if (!password.isNull()) 547 if (!password.isNull())
548 url.setPass(password); 548 url.setPass(password);
549 549
550 open(method, url, async, exceptionState); 550 open(method, url, async, exceptionState);
551 } 551 }
552 552
553 void XMLHttpRequest::open(const AtomicString& method, const KURL& url, bool asyn c, ExceptionState& exceptionState) 553 void XMLHttpRequest::open(const AtomicString& method, const KURL& url, bool asyn c, ExceptionState& exceptionState)
554 { 554 {
555 WTF_LOG(Network, "XMLHttpRequest %p open('%s', '%s', %d)", this, method.utf8 ().data(), url.elidedString().utf8().data(), async); 555 NETWORK_DVLOG(1) << this << " open(" << method << ", " << url.elidedString() << ", " << async << ")";
tyoshino (SeeGerritForStatus) 2016/08/12 07:32:19 ditto
556 556
557 if (!internalAbort()) 557 if (!internalAbort())
558 return; 558 return;
559 559
560 State previousState = m_state; 560 State previousState = m_state;
561 m_state = kUnsent; 561 m_state = kUnsent;
562 m_error = false; 562 m_error = false;
563 m_uploadComplete = false; 563 m_uploadComplete = false;
564 564
565 if (!isValidHTTPToken(method)) { 565 if (!isValidHTTPToken(method)) {
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 send(body.getAsString(), exceptionState); 678 send(body.getAsString(), exceptionState);
679 } 679 }
680 680
681 bool XMLHttpRequest::areMethodAndURLValidForSend() 681 bool XMLHttpRequest::areMethodAndURLValidForSend()
682 { 682 {
683 return m_method != HTTPNames::GET && m_method != HTTPNames::HEAD && m_url.pr otocolIsInHTTPFamily(); 683 return m_method != HTTPNames::GET && m_method != HTTPNames::HEAD && m_url.pr otocolIsInHTTPFamily();
684 } 684 }
685 685
686 void XMLHttpRequest::send(Document* document, ExceptionState& exceptionState) 686 void XMLHttpRequest::send(Document* document, ExceptionState& exceptionState)
687 { 687 {
688 WTF_LOG(Network, "XMLHttpRequest %p send() Document %p", this, document); 688 NETWORK_DVLOG(1) << this << " send() Document " << static_cast<void*>(docume nt);
689 689
690 ASSERT(document); 690 ASSERT(document);
691 691
692 if (!initSend(exceptionState)) 692 if (!initSend(exceptionState))
693 return; 693 return;
694 694
695 RefPtr<EncodedFormData> httpBody; 695 RefPtr<EncodedFormData> httpBody;
696 696
697 if (areMethodAndURLValidForSend()) { 697 if (areMethodAndURLValidForSend()) {
698 // FIXME: Per https://xhr.spec.whatwg.org/#dom-xmlhttprequest-send the 698 // FIXME: Per https://xhr.spec.whatwg.org/#dom-xmlhttprequest-send the
699 // Content-Type header and whether to serialize as HTML or XML should 699 // Content-Type header and whether to serialize as HTML or XML should
700 // depend on |document->isHTMLDocument()|. 700 // depend on |document->isHTMLDocument()|.
701 if (getRequestHeader(HTTPNames::Content_Type).isEmpty()) 701 if (getRequestHeader(HTTPNames::Content_Type).isEmpty())
702 setRequestHeaderInternal(HTTPNames::Content_Type, "application/xml;c harset=UTF-8"); 702 setRequestHeaderInternal(HTTPNames::Content_Type, "application/xml;c harset=UTF-8");
703 703
704 String body = createMarkup(document); 704 String body = createMarkup(document);
705 705
706 httpBody = EncodedFormData::create(UTF8Encoding().encode(body, WTF::Enti tiesForUnencodables)); 706 httpBody = EncodedFormData::create(UTF8Encoding().encode(body, WTF::Enti tiesForUnencodables));
707 } 707 }
708 708
709 createRequest(httpBody.release(), exceptionState); 709 createRequest(httpBody.release(), exceptionState);
710 } 710 }
711 711
712 void XMLHttpRequest::send(const String& body, ExceptionState& exceptionState) 712 void XMLHttpRequest::send(const String& body, ExceptionState& exceptionState)
713 { 713 {
714 WTF_LOG(Network, "XMLHttpRequest %p send() String '%s'", this, body.utf8().d ata()); 714 NETWORK_DVLOG(1) << this << " send() String " << body;
715 715
716 if (!initSend(exceptionState)) 716 if (!initSend(exceptionState))
717 return; 717 return;
718 718
719 RefPtr<EncodedFormData> httpBody; 719 RefPtr<EncodedFormData> httpBody;
720 720
721 if (!body.isNull() && areMethodAndURLValidForSend()) { 721 if (!body.isNull() && areMethodAndURLValidForSend()) {
722 String contentType = getRequestHeader(HTTPNames::Content_Type); 722 String contentType = getRequestHeader(HTTPNames::Content_Type);
723 if (contentType.isEmpty()) { 723 if (contentType.isEmpty()) {
724 setRequestHeaderInternal(HTTPNames::Content_Type, "text/plain;charse t=UTF-8"); 724 setRequestHeaderInternal(HTTPNames::Content_Type, "text/plain;charse t=UTF-8");
725 } else { 725 } else {
726 replaceCharsetInMediaType(contentType, "UTF-8"); 726 replaceCharsetInMediaType(contentType, "UTF-8");
727 m_requestHeaders.set(HTTPNames::Content_Type, AtomicString(contentTy pe)); 727 m_requestHeaders.set(HTTPNames::Content_Type, AtomicString(contentTy pe));
728 } 728 }
729 729
730 httpBody = EncodedFormData::create(UTF8Encoding().encode(body, WTF::Enti tiesForUnencodables)); 730 httpBody = EncodedFormData::create(UTF8Encoding().encode(body, WTF::Enti tiesForUnencodables));
731 } 731 }
732 732
733 createRequest(httpBody.release(), exceptionState); 733 createRequest(httpBody.release(), exceptionState);
734 } 734 }
735 735
736 void XMLHttpRequest::send(Blob* body, ExceptionState& exceptionState) 736 void XMLHttpRequest::send(Blob* body, ExceptionState& exceptionState)
737 { 737 {
738 WTF_LOG(Network, "XMLHttpRequest %p send() Blob '%s'", this, body->uuid().ut f8().data()); 738 NETWORK_DVLOG(1) << this << " send() Blob " << body->uuid();
739 739
740 if (!initSend(exceptionState)) 740 if (!initSend(exceptionState))
741 return; 741 return;
742 742
743 RefPtr<EncodedFormData> httpBody; 743 RefPtr<EncodedFormData> httpBody;
744 744
745 if (areMethodAndURLValidForSend()) { 745 if (areMethodAndURLValidForSend()) {
746 if (getRequestHeader(HTTPNames::Content_Type).isEmpty()) { 746 if (getRequestHeader(HTTPNames::Content_Type).isEmpty()) {
747 const String& blobType = body->type(); 747 const String& blobType = body->type();
748 if (!blobType.isEmpty() && isValidContentType(blobType)) { 748 if (!blobType.isEmpty() && isValidContentType(blobType)) {
(...skipping 14 matching lines...) Expand all
763 } else { 763 } else {
764 httpBody->appendBlob(body->uuid(), body->blobDataHandle()); 764 httpBody->appendBlob(body->uuid(), body->blobDataHandle());
765 } 765 }
766 } 766 }
767 767
768 createRequest(httpBody.release(), exceptionState); 768 createRequest(httpBody.release(), exceptionState);
769 } 769 }
770 770
771 void XMLHttpRequest::send(FormData* body, ExceptionState& exceptionState) 771 void XMLHttpRequest::send(FormData* body, ExceptionState& exceptionState)
772 { 772 {
773 WTF_LOG(Network, "XMLHttpRequest %p send() FormData %p", this, body); 773 NETWORK_DVLOG(1) << this << " send() FormData " << body;
774 774
775 if (!initSend(exceptionState)) 775 if (!initSend(exceptionState))
776 return; 776 return;
777 777
778 RefPtr<EncodedFormData> httpBody; 778 RefPtr<EncodedFormData> httpBody;
779 779
780 if (areMethodAndURLValidForSend()) { 780 if (areMethodAndURLValidForSend()) {
781 httpBody = body->encodeMultiPartFormData(); 781 httpBody = body->encodeMultiPartFormData();
782 782
783 if (getRequestHeader(HTTPNames::Content_Type).isEmpty()) { 783 if (getRequestHeader(HTTPNames::Content_Type).isEmpty()) {
784 AtomicString contentType = AtomicString("multipart/form-data; bounda ry=") + httpBody->boundary().data(); 784 AtomicString contentType = AtomicString("multipart/form-data; bounda ry=") + httpBody->boundary().data();
785 setRequestHeaderInternal(HTTPNames::Content_Type, contentType); 785 setRequestHeaderInternal(HTTPNames::Content_Type, contentType);
786 } 786 }
787 } 787 }
788 788
789 createRequest(httpBody.release(), exceptionState); 789 createRequest(httpBody.release(), exceptionState);
790 } 790 }
791 791
792 void XMLHttpRequest::send(DOMArrayBuffer* body, ExceptionState& exceptionState) 792 void XMLHttpRequest::send(DOMArrayBuffer* body, ExceptionState& exceptionState)
793 { 793 {
794 WTF_LOG(Network, "XMLHttpRequest %p send() ArrayBuffer %p", this, body); 794 NETWORK_DVLOG(1) << this << " send() ArrayBuffer " << body;
795 795
796 sendBytesData(body->data(), body->byteLength(), exceptionState); 796 sendBytesData(body->data(), body->byteLength(), exceptionState);
797 } 797 }
798 798
799 void XMLHttpRequest::send(DOMArrayBufferView* body, ExceptionState& exceptionSta te) 799 void XMLHttpRequest::send(DOMArrayBufferView* body, ExceptionState& exceptionSta te)
800 { 800 {
801 WTF_LOG(Network, "XMLHttpRequest %p send() ArrayBufferView %p", this, body); 801 NETWORK_DVLOG(1) << this << " send() ArrayBufferView " << body;
802 802
803 sendBytesData(body->baseAddress(), body->byteLength(), exceptionState); 803 sendBytesData(body->baseAddress(), body->byteLength(), exceptionState);
804 } 804 }
805 805
806 void XMLHttpRequest::sendBytesData(const void* data, size_t length, ExceptionSta te& exceptionState) 806 void XMLHttpRequest::sendBytesData(const void* data, size_t length, ExceptionSta te& exceptionState)
807 { 807 {
808 if (!initSend(exceptionState)) 808 if (!initSend(exceptionState))
809 return; 809 return;
810 810
811 RefPtr<EncodedFormData> httpBody; 811 RefPtr<EncodedFormData> httpBody;
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
934 934
935 // Use count for XHR synchronous requests. 935 // Use count for XHR synchronous requests.
936 UseCounter::count(&executionContext, UseCounter::XMLHttpRequestSynchronous); 936 UseCounter::count(&executionContext, UseCounter::XMLHttpRequestSynchronous);
937 ThreadableLoader::loadResourceSynchronously(executionContext, request, *this , options, resourceLoaderOptions); 937 ThreadableLoader::loadResourceSynchronously(executionContext, request, *this , options, resourceLoaderOptions);
938 938
939 throwForLoadFailureIfNeeded(exceptionState, String()); 939 throwForLoadFailureIfNeeded(exceptionState, String());
940 } 940 }
941 941
942 void XMLHttpRequest::abort() 942 void XMLHttpRequest::abort()
943 { 943 {
944 WTF_LOG(Network, "XMLHttpRequest %p abort()", this); 944 NETWORK_DVLOG(1) << this << " abort()";
945 945
946 // internalAbort() clears |m_loader|. Compute |sendFlag| now. 946 // internalAbort() clears |m_loader|. Compute |sendFlag| now.
947 // 947 //
948 // |sendFlag| corresponds to "the send() flag" defined in the XHR spec. 948 // |sendFlag| corresponds to "the send() flag" defined in the XHR spec.
949 // 949 //
950 // |sendFlag| is only set when we have an active, asynchronous loader. 950 // |sendFlag| is only set when we have an active, asynchronous loader.
951 // Don't use it as "the send() flag" when the XHR is in sync mode. 951 // Don't use it as "the send() flag" when the XHR is in sync mode.
952 bool sendFlag = m_loader.get(); 952 bool sendFlag = m_loader.get();
953 953
954 // internalAbort() clears the response. Save the data needed for 954 // internalAbort() clears the response. Save the data needed for
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
1077 InspectorInstrumentation::asyncTaskCanceled(context, this); 1077 InspectorInstrumentation::asyncTaskCanceled(context, this);
1078 } 1078 }
1079 1079
1080 void XMLHttpRequest::dispatchProgressEventFromSnapshot(const AtomicString& type) 1080 void XMLHttpRequest::dispatchProgressEventFromSnapshot(const AtomicString& type)
1081 { 1081 {
1082 dispatchProgressEvent(type, m_receivedLength, m_response.expectedContentLeng th()); 1082 dispatchProgressEvent(type, m_receivedLength, m_response.expectedContentLeng th());
1083 } 1083 }
1084 1084
1085 void XMLHttpRequest::handleNetworkError() 1085 void XMLHttpRequest::handleNetworkError()
1086 { 1086 {
1087 WTF_LOG(Network, "XMLHttpRequest %p handleNetworkError()", this); 1087 NETWORK_DVLOG(1) << this << " handleNetworkError()";
1088 1088
1089 // Response is cleared next, save needed progress event data. 1089 // Response is cleared next, save needed progress event data.
1090 long long expectedLength = m_response.expectedContentLength(); 1090 long long expectedLength = m_response.expectedContentLength();
1091 long long receivedLength = m_receivedLength; 1091 long long receivedLength = m_receivedLength;
1092 1092
1093 if (!internalAbort()) 1093 if (!internalAbort())
1094 return; 1094 return;
1095 1095
1096 handleRequestError(NetworkError, EventTypeNames::error, receivedLength, expe ctedLength); 1096 handleRequestError(NetworkError, EventTypeNames::error, receivedLength, expe ctedLength);
1097 } 1097 }
1098 1098
1099 void XMLHttpRequest::handleDidCancel() 1099 void XMLHttpRequest::handleDidCancel()
1100 { 1100 {
1101 WTF_LOG(Network, "XMLHttpRequest %p handleDidCancel()", this); 1101 NETWORK_DVLOG(1) << this << " handleDidCancel()";
1102 1102
1103 // Response is cleared next, save needed progress event data. 1103 // Response is cleared next, save needed progress event data.
1104 long long expectedLength = m_response.expectedContentLength(); 1104 long long expectedLength = m_response.expectedContentLength();
1105 long long receivedLength = m_receivedLength; 1105 long long receivedLength = m_receivedLength;
1106 1106
1107 if (!internalAbort()) 1107 if (!internalAbort())
1108 return; 1108 return;
1109 1109
1110 handleRequestError(AbortError, EventTypeNames::abort, receivedLength, expect edLength); 1110 handleRequestError(AbortError, EventTypeNames::abort, receivedLength, expect edLength);
1111 } 1111 }
1112 1112
1113 void XMLHttpRequest::handleRequestError(ExceptionCode exceptionCode, const Atomi cString& type, long long receivedLength, long long expectedLength) 1113 void XMLHttpRequest::handleRequestError(ExceptionCode exceptionCode, const Atomi cString& type, long long receivedLength, long long expectedLength)
1114 { 1114 {
1115 WTF_LOG(Network, "XMLHttpRequest %p handleRequestError()", this); 1115 NETWORK_DVLOG(1) << this << " handleRequestError()";
1116 1116
1117 InspectorInstrumentation::didFailXHRLoading(getExecutionContext(), this, thi s, m_method, m_url); 1117 InspectorInstrumentation::didFailXHRLoading(getExecutionContext(), this, thi s, m_method, m_url);
1118 1118
1119 if (!m_async) { 1119 if (!m_async) {
1120 ASSERT(exceptionCode); 1120 ASSERT(exceptionCode);
1121 m_state = kDone; 1121 m_state = kDone;
1122 m_exceptionCode = exceptionCode; 1122 m_exceptionCode = exceptionCode;
1123 return; 1123 return;
1124 } 1124 }
1125 1125
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
1320 return String(); 1320 return String();
1321 1321
1322 if (!m_response.httpStatusText().isNull()) 1322 if (!m_response.httpStatusText().isNull())
1323 return m_response.httpStatusText(); 1323 return m_response.httpStatusText();
1324 1324
1325 return String(); 1325 return String();
1326 } 1326 }
1327 1327
1328 void XMLHttpRequest::didFail(const ResourceError& error) 1328 void XMLHttpRequest::didFail(const ResourceError& error)
1329 { 1329 {
1330 WTF_LOG(Network, "XMLHttpRequest %p didFail()", this); 1330 NETWORK_DVLOG(1) << this << " didFail()";
1331 ScopedEventDispatchProtect protect(&m_eventDispatchRecursionLevel); 1331 ScopedEventDispatchProtect protect(&m_eventDispatchRecursionLevel);
1332 1332
1333 // If we are already in an error state, for instance we called abort(), bail out early. 1333 // If we are already in an error state, for instance we called abort(), bail out early.
1334 if (m_error) 1334 if (m_error)
1335 return; 1335 return;
1336 1336
1337 if (error.isCancellation()) { 1337 if (error.isCancellation()) {
1338 handleDidCancel(); 1338 handleDidCancel();
1339 // Now the XMLHttpRequest instance may be dead. 1339 // Now the XMLHttpRequest instance may be dead.
1340 return; 1340 return;
1341 } 1341 }
1342 1342
1343 if (error.isTimeout()) { 1343 if (error.isTimeout()) {
1344 handleDidTimeout(); 1344 handleDidTimeout();
1345 // Now the XMLHttpRequest instance may be dead. 1345 // Now the XMLHttpRequest instance may be dead.
1346 return; 1346 return;
1347 } 1347 }
1348 1348
1349 // Network failures are already reported to Web Inspector by ResourceLoader. 1349 // Network failures are already reported to Web Inspector by ResourceLoader.
1350 if (error.domain() == errorDomainBlinkInternal) 1350 if (error.domain() == errorDomainBlinkInternal)
1351 logConsoleError(getExecutionContext(), "XMLHttpRequest cannot load " + e rror.failingURL() + ". " + error.localizedDescription()); 1351 logConsoleError(getExecutionContext(), "XMLHttpRequest cannot load " + e rror.failingURL() + ". " + error.localizedDescription());
1352 1352
1353 handleNetworkError(); 1353 handleNetworkError();
1354 // Now the XMLHttpRequest instance may be dead. 1354 // Now the XMLHttpRequest instance may be dead.
1355 } 1355 }
1356 1356
1357 void XMLHttpRequest::didFailRedirectCheck() 1357 void XMLHttpRequest::didFailRedirectCheck()
1358 { 1358 {
1359 WTF_LOG(Network, "XMLHttpRequest %p didFailRedirectCheck()", this); 1359 NETWORK_DVLOG(1) << this << " didFailRedirectCheck()";
1360 ScopedEventDispatchProtect protect(&m_eventDispatchRecursionLevel); 1360 ScopedEventDispatchProtect protect(&m_eventDispatchRecursionLevel);
1361 1361
1362 handleNetworkError(); 1362 handleNetworkError();
1363 // Now the XMLHttpRequest instance may be dead. 1363 // Now the XMLHttpRequest instance may be dead.
1364 } 1364 }
1365 1365
1366 void XMLHttpRequest::didFinishLoading(unsigned long identifier, double) 1366 void XMLHttpRequest::didFinishLoading(unsigned long identifier, double)
1367 { 1367 {
1368 WTF_LOG(Network, "XMLHttpRequest %p didFinishLoading(%lu)", this, identifier ); 1368 NETWORK_DVLOG(1) << this << " didFinishLoading(" << identifier << ")";
1369 ScopedEventDispatchProtect protect(&m_eventDispatchRecursionLevel); 1369 ScopedEventDispatchProtect protect(&m_eventDispatchRecursionLevel);
1370 1370
1371 if (m_error) 1371 if (m_error)
1372 return; 1372 return;
1373 1373
1374 if (m_state < kHeadersReceived) 1374 if (m_state < kHeadersReceived)
1375 changeState(kHeadersReceived); 1375 changeState(kHeadersReceived);
1376 1376
1377 if (m_downloadingToFile && m_responseTypeCode != ResponseTypeBlob && m_lengt hDownloadedToFile) { 1377 if (m_downloadingToFile && m_responseTypeCode != ResponseTypeBlob && m_lengt hDownloadedToFile) {
1378 DCHECK_EQ(kLoading, m_state); 1378 DCHECK_EQ(kLoading, m_state);
(...skipping 28 matching lines...) Expand all
1407 1407
1408 if (m_responseLegacyStream) 1408 if (m_responseLegacyStream)
1409 m_responseLegacyStream->finalize(); 1409 m_responseLegacyStream->finalize();
1410 1410
1411 clearVariablesForLoading(); 1411 clearVariablesForLoading();
1412 endLoading(); 1412 endLoading();
1413 } 1413 }
1414 1414
1415 void XMLHttpRequest::didFinishLoadingFromBlob() 1415 void XMLHttpRequest::didFinishLoadingFromBlob()
1416 { 1416 {
1417 WTF_LOG(Network, "XMLHttpRequest %p didFinishLoadingFromBlob", this); 1417 NETWORK_DVLOG(1) << this << " didFinishLoadingFromBlob";
1418 ScopedEventDispatchProtect protect(&m_eventDispatchRecursionLevel); 1418 ScopedEventDispatchProtect protect(&m_eventDispatchRecursionLevel);
1419 1419
1420 didFinishLoadingInternal(); 1420 didFinishLoadingInternal();
1421 } 1421 }
1422 1422
1423 void XMLHttpRequest::didFailLoadingFromBlob() 1423 void XMLHttpRequest::didFailLoadingFromBlob()
1424 { 1424 {
1425 WTF_LOG(Network, "XMLHttpRequest %p didFailLoadingFromBlob()", this); 1425 NETWORK_DVLOG(1) << this << " didFailLoadingFromBlob()";
1426 ScopedEventDispatchProtect protect(&m_eventDispatchRecursionLevel); 1426 ScopedEventDispatchProtect protect(&m_eventDispatchRecursionLevel);
1427 1427
1428 if (m_error) 1428 if (m_error)
1429 return; 1429 return;
1430 handleNetworkError(); 1430 handleNetworkError();
1431 } 1431 }
1432 1432
1433 PassRefPtr<BlobDataHandle> XMLHttpRequest::createBlobDataHandleFromResponse() 1433 PassRefPtr<BlobDataHandle> XMLHttpRequest::createBlobDataHandleFromResponse()
1434 { 1434 {
1435 ASSERT(m_downloadingToFile); 1435 ASSERT(m_downloadingToFile);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1485 if (!getExecutionContext()->isDocument() || !document() || !document()->fram e() || !document()->frame()->page()) 1485 if (!getExecutionContext()->isDocument() || !document() || !document()->fram e() || !document()->frame()->page())
1486 return; 1486 return;
1487 1487
1488 if (status() >= 200 && status() < 300) { 1488 if (status() >= 200 && status() < 300) {
1489 document()->frame()->page()->chromeClient().ajaxSucceeded(document()->fr ame()); 1489 document()->frame()->page()->chromeClient().ajaxSucceeded(document()->fr ame());
1490 } 1490 }
1491 } 1491 }
1492 1492
1493 void XMLHttpRequest::didSendData(unsigned long long bytesSent, unsigned long lon g totalBytesToBeSent) 1493 void XMLHttpRequest::didSendData(unsigned long long bytesSent, unsigned long lon g totalBytesToBeSent)
1494 { 1494 {
1495 WTF_LOG(Network, "XMLHttpRequest %p didSendData(%llu, %llu)", this, bytesSen t, totalBytesToBeSent); 1495 NETWORK_DVLOG(1) << this << " didSendData(" << bytesSent << ", " << totalByt esToBeSent << ")";
1496 ScopedEventDispatchProtect protect(&m_eventDispatchRecursionLevel); 1496 ScopedEventDispatchProtect protect(&m_eventDispatchRecursionLevel);
1497 1497
1498 if (!m_upload) 1498 if (!m_upload)
1499 return; 1499 return;
1500 1500
1501 if (m_uploadEventsAllowed) 1501 if (m_uploadEventsAllowed)
1502 m_upload->dispatchProgressEvent(bytesSent, totalBytesToBeSent); 1502 m_upload->dispatchProgressEvent(bytesSent, totalBytesToBeSent);
1503 1503
1504 if (bytesSent == totalBytesToBeSent && !m_uploadComplete) { 1504 if (bytesSent == totalBytesToBeSent && !m_uploadComplete) {
1505 m_uploadComplete = true; 1505 m_uploadComplete = true;
1506 if (m_uploadEventsAllowed) 1506 if (m_uploadEventsAllowed)
1507 m_upload->dispatchEventAndLoadEnd(EventTypeNames::load, true, bytesS ent, totalBytesToBeSent); 1507 m_upload->dispatchEventAndLoadEnd(EventTypeNames::load, true, bytesS ent, totalBytesToBeSent);
1508 } 1508 }
1509 } 1509 }
1510 1510
1511 void XMLHttpRequest::didReceiveResponse(unsigned long identifier, const Resource Response& response, std::unique_ptr<WebDataConsumerHandle> handle) 1511 void XMLHttpRequest::didReceiveResponse(unsigned long identifier, const Resource Response& response, std::unique_ptr<WebDataConsumerHandle> handle)
1512 { 1512 {
1513 ASSERT_UNUSED(handle, !handle); 1513 ASSERT_UNUSED(handle, !handle);
1514 WTF_LOG(Network, "XMLHttpRequest %p didReceiveResponse(%lu)", this, identifi er); 1514 NETWORK_DVLOG(1) << this << " didReceiveResponse(" << identifier << ")";
1515 ScopedEventDispatchProtect protect(&m_eventDispatchRecursionLevel); 1515 ScopedEventDispatchProtect protect(&m_eventDispatchRecursionLevel);
1516 1516
1517 m_response = response; 1517 m_response = response;
1518 if (!m_mimeTypeOverride.isEmpty()) { 1518 if (!m_mimeTypeOverride.isEmpty()) {
1519 m_response.setHTTPHeaderField(HTTPNames::Content_Type, m_mimeTypeOverrid e); 1519 m_response.setHTTPHeaderField(HTTPNames::Content_Type, m_mimeTypeOverrid e);
1520 m_finalResponseCharset = extractCharsetFromMediaType(m_mimeTypeOverride) ; 1520 m_finalResponseCharset = extractCharsetFromMediaType(m_mimeTypeOverride) ;
1521 } 1521 }
1522 1522
1523 if (m_finalResponseCharset.isEmpty()) 1523 if (m_finalResponseCharset.isEmpty())
1524 m_finalResponseCharset = response.textEncodingName(); 1524 m_finalResponseCharset = response.textEncodingName();
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
1634 if (m_error) 1634 if (m_error)
1635 return; 1635 return;
1636 1636
1637 m_lengthDownloadedToFile += dataLength; 1637 m_lengthDownloadedToFile += dataLength;
1638 1638
1639 trackProgress(dataLength); 1639 trackProgress(dataLength);
1640 } 1640 }
1641 1641
1642 void XMLHttpRequest::handleDidTimeout() 1642 void XMLHttpRequest::handleDidTimeout()
1643 { 1643 {
1644 WTF_LOG(Network, "XMLHttpRequest %p handleDidTimeout()", this); 1644 NETWORK_DVLOG(1) << this << " handleDidTimeout()";
1645 1645
1646 // Response is cleared next, save needed progress event data. 1646 // Response is cleared next, save needed progress event data.
1647 long long expectedLength = m_response.expectedContentLength(); 1647 long long expectedLength = m_response.expectedContentLength();
1648 long long receivedLength = m_receivedLength; 1648 long long receivedLength = m_receivedLength;
1649 1649
1650 if (!internalAbort()) 1650 if (!internalAbort())
1651 return; 1651 return;
1652 1652
1653 handleRequestError(TimeoutError, EventTypeNames::timeout, receivedLength, ex pectedLength); 1653 handleRequestError(TimeoutError, EventTypeNames::timeout, receivedLength, ex pectedLength);
1654 } 1654 }
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1715 } 1715 }
1716 1716
1717 DEFINE_TRACE_WRAPPERS(XMLHttpRequest) 1717 DEFINE_TRACE_WRAPPERS(XMLHttpRequest)
1718 { 1718 {
1719 visitor->traceWrappers(m_responseBlob); 1719 visitor->traceWrappers(m_responseBlob);
1720 visitor->traceWrappers(m_responseLegacyStream); 1720 visitor->traceWrappers(m_responseLegacyStream);
1721 visitor->traceWrappers(m_responseDocument); 1721 visitor->traceWrappers(m_responseDocument);
1722 visitor->traceWrappers(m_responseArrayBuffer); 1722 visitor->traceWrappers(m_responseArrayBuffer);
1723 } 1723 }
1724 1724
1725 std::ostream& operator<<(std::ostream& ostream, const XMLHttpRequest* xhr)
1726 {
1727 return ostream << "XMLHttpRequest " << static_cast<const void*>(xhr);
1728 }
1729
1725 } // namespace blink 1730 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698