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

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

Issue 1980893002: Remove OwnPtr::release() calls in core/ (part 4). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
« no previous file with comments | « third_party/WebKit/Source/core/workers/WorkerThreadTestHelper.h ('k') | no next file » | 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 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 m_responseBlob = Blob::create(createBlobDataHandleFromResponse()); 333 m_responseBlob = Blob::create(createBlobDataHandleFromResponse());
334 } else { 334 } else {
335 OwnPtr<BlobData> blobData = BlobData::create(); 335 OwnPtr<BlobData> blobData = BlobData::create();
336 size_t size = 0; 336 size_t size = 0;
337 if (m_binaryResponseBuilder && m_binaryResponseBuilder->size()) { 337 if (m_binaryResponseBuilder && m_binaryResponseBuilder->size()) {
338 size = m_binaryResponseBuilder->size(); 338 size = m_binaryResponseBuilder->size();
339 blobData->appendBytes(m_binaryResponseBuilder->data(), size); 339 blobData->appendBytes(m_binaryResponseBuilder->data(), size);
340 blobData->setContentType(finalResponseMIMETypeWithFallback().low er()); 340 blobData->setContentType(finalResponseMIMETypeWithFallback().low er());
341 m_binaryResponseBuilder.clear(); 341 m_binaryResponseBuilder.clear();
342 } 342 }
343 m_responseBlob = Blob::create(BlobDataHandle::create(blobData.releas e(), size)); 343 m_responseBlob = Blob::create(BlobDataHandle::create(std::move(blobD ata), size));
344 } 344 }
345 } 345 }
346 346
347 return m_responseBlob; 347 return m_responseBlob;
348 } 348 }
349 349
350 DOMArrayBuffer* XMLHttpRequest::responseArrayBuffer() 350 DOMArrayBuffer* XMLHttpRequest::responseArrayBuffer()
351 { 351 {
352 ASSERT(m_responseTypeCode == ResponseTypeArrayBuffer); 352 ASSERT(m_responseTypeCode == ResponseTypeArrayBuffer);
353 353
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after
1019 if (!m_loader) 1019 if (!m_loader)
1020 return true; 1020 return true;
1021 1021
1022 // Cancelling the ThreadableLoader m_loader may result in calling 1022 // Cancelling the ThreadableLoader m_loader may result in calling
1023 // window.onload synchronously. If such an onload handler contains open() 1023 // window.onload synchronously. If such an onload handler contains open()
1024 // call on the same XMLHttpRequest object, reentry happens. 1024 // call on the same XMLHttpRequest object, reentry happens.
1025 // 1025 //
1026 // If, window.onload contains open() and send(), m_loader will be set to 1026 // If, window.onload contains open() and send(), m_loader will be set to
1027 // non 0 value. So, we cannot continue the outer open(). In such case, 1027 // non 0 value. So, we cannot continue the outer open(). In such case,
1028 // just abort the outer open() by returning false. 1028 // just abort the outer open() by returning false.
1029 OwnPtr<ThreadableLoader> loader = m_loader.release(); 1029 OwnPtr<ThreadableLoader> loader = std::move(m_loader);
1030 loader->cancel(); 1030 loader->cancel();
1031 1031
1032 // If abort() called internalAbort() and a nested open() ended up 1032 // If abort() called internalAbort() and a nested open() ended up
1033 // clearing the error flag, but didn't send(), make sure the error 1033 // clearing the error flag, but didn't send(), make sure the error
1034 // flag is still set. 1034 // flag is still set.
1035 bool newLoadStarted = m_loader.get(); 1035 bool newLoadStarted = m_loader.get();
1036 if (!newLoadStarted) 1036 if (!newLoadStarted)
1037 m_error = true; 1037 m_error = true;
1038 1038
1039 return !newLoadStarted; 1039 return !newLoadStarted;
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
1441 OwnPtr<BlobData> blobData = BlobData::create(); 1441 OwnPtr<BlobData> blobData = BlobData::create();
1442 String filePath = m_response.downloadedFilePath(); 1442 String filePath = m_response.downloadedFilePath();
1443 // If we errored out or got no data, we return an empty handle. 1443 // If we errored out or got no data, we return an empty handle.
1444 if (!filePath.isEmpty() && m_lengthDownloadedToFile) { 1444 if (!filePath.isEmpty() && m_lengthDownloadedToFile) {
1445 blobData->appendFile(filePath, 0, m_lengthDownloadedToFile, invalidFileT ime()); 1445 blobData->appendFile(filePath, 0, m_lengthDownloadedToFile, invalidFileT ime());
1446 // FIXME: finalResponseMIMETypeWithFallback() defaults to 1446 // FIXME: finalResponseMIMETypeWithFallback() defaults to
1447 // text/xml which may be incorrect. Replace it with 1447 // text/xml which may be incorrect. Replace it with
1448 // finalResponseMIMEType() after compatibility investigation. 1448 // finalResponseMIMEType() after compatibility investigation.
1449 blobData->setContentType(finalResponseMIMETypeWithFallback().lower()); 1449 blobData->setContentType(finalResponseMIMETypeWithFallback().lower());
1450 } 1450 }
1451 return BlobDataHandle::create(blobData.release(), m_lengthDownloadedToFile); 1451 return BlobDataHandle::create(std::move(blobData), m_lengthDownloadedToFile) ;
1452 } 1452 }
1453 1453
1454 void XMLHttpRequest::notifyParserStopped() 1454 void XMLHttpRequest::notifyParserStopped()
1455 { 1455 {
1456 ScopedEventDispatchProtect protect(&m_eventDispatchRecursionLevel); 1456 ScopedEventDispatchProtect protect(&m_eventDispatchRecursionLevel);
1457 1457
1458 // This should only be called when response document is parsed asynchronousl y. 1458 // This should only be called when response document is parsed asynchronousl y.
1459 ASSERT(m_responseDocumentParser); 1459 ASSERT(m_responseDocumentParser);
1460 ASSERT(!m_responseDocumentParser->isParsing()); 1460 ASSERT(!m_responseDocumentParser->isParsing());
1461 ASSERT(!m_responseLegacyStream); 1461 ASSERT(!m_responseLegacyStream);
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
1547 } 1547 }
1548 1548
1549 PassOwnPtr<TextResourceDecoder> XMLHttpRequest::createDecoder() const 1549 PassOwnPtr<TextResourceDecoder> XMLHttpRequest::createDecoder() const
1550 { 1550 {
1551 if (m_responseTypeCode == ResponseTypeJSON) 1551 if (m_responseTypeCode == ResponseTypeJSON)
1552 return TextResourceDecoder::create("application/json", "UTF-8"); 1552 return TextResourceDecoder::create("application/json", "UTF-8");
1553 1553
1554 if (!m_finalResponseCharset.isEmpty()) { 1554 if (!m_finalResponseCharset.isEmpty()) {
1555 OwnPtr<TextResourceDecoder> decoder(TextResourceDecoder::create("text/pl ain")); 1555 OwnPtr<TextResourceDecoder> decoder(TextResourceDecoder::create("text/pl ain"));
1556 decoder->setEncoding(WTF::TextEncoding(m_finalResponseCharset), TextReso urceDecoder::EncodingFromHTTPHeader); 1556 decoder->setEncoding(WTF::TextEncoding(m_finalResponseCharset), TextReso urceDecoder::EncodingFromHTTPHeader);
1557 return decoder.release(); 1557 return decoder;
1558 } 1558 }
1559 1559
1560 // allow TextResourceDecoder to look inside the m_response if it's XML or HT ML 1560 // allow TextResourceDecoder to look inside the m_response if it's XML or HT ML
1561 if (responseIsXML()) { 1561 if (responseIsXML()) {
1562 OwnPtr<TextResourceDecoder> decoder = TextResourceDecoder::create("appli cation/xml"); 1562 OwnPtr<TextResourceDecoder> decoder = TextResourceDecoder::create("appli cation/xml");
1563 // Don't stop on encoding errors, unlike it is done for other kinds 1563 // Don't stop on encoding errors, unlike it is done for other kinds
1564 // of XML resources. This matches the behavior of previous WebKit 1564 // of XML resources. This matches the behavior of previous WebKit
1565 // versions, Firefox and Opera. 1565 // versions, Firefox and Opera.
1566 decoder->useLenientXMLDecoding(); 1566 decoder->useLenientXMLDecoding();
1567 1567
1568 return decoder.release(); 1568 return decoder;
1569 } 1569 }
1570 1570
1571 if (responseIsHTML()) 1571 if (responseIsHTML())
1572 return TextResourceDecoder::create("text/html", "UTF-8"); 1572 return TextResourceDecoder::create("text/html", "UTF-8");
1573 1573
1574 return TextResourceDecoder::create("text/plain", "UTF-8"); 1574 return TextResourceDecoder::create("text/plain", "UTF-8");
1575 } 1575 }
1576 1576
1577 void XMLHttpRequest::didReceiveData(const char* data, unsigned len) 1577 void XMLHttpRequest::didReceiveData(const char* data, unsigned len)
1578 { 1578 {
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
1714 visitor->trace(m_responseArrayBuffer); 1714 visitor->trace(m_responseArrayBuffer);
1715 visitor->trace(m_progressEventThrottle); 1715 visitor->trace(m_progressEventThrottle);
1716 visitor->trace(m_upload); 1716 visitor->trace(m_upload);
1717 visitor->trace(m_blobLoader); 1717 visitor->trace(m_blobLoader);
1718 XMLHttpRequestEventTarget::trace(visitor); 1718 XMLHttpRequestEventTarget::trace(visitor);
1719 DocumentParserClient::trace(visitor); 1719 DocumentParserClient::trace(visitor);
1720 ActiveDOMObject::trace(visitor); 1720 ActiveDOMObject::trace(visitor);
1721 } 1721 }
1722 1722
1723 } // namespace blink 1723 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/workers/WorkerThreadTestHelper.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698