Changeset 80551 in webkit
- Timestamp:
- Mar 8, 2011 1:14:10 AM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r80548 r80551 1 2011-03-08 Markus Goetz <guruz@guruz.de> 2 3 Reviewed by Kenneth Rohde Christiansen. 4 5 [Qt] Use the QNetworkAccessManager zerocopy feature 6 https://bugs.webkit.org/show_bug.cgi?id=50082 7 8 The feature will be introduced in Qt 4.8. 9 This patch is backwards compatible with Qt 4.7. 10 11 * WebCore.pro: 12 * platform/SharedBuffer.cpp: 13 * platform/SharedBuffer.h: 14 * platform/network/qt/QNetworkReplyHandler.cpp: 15 (WebCore::QNetworkReplyHandler::QNetworkReplyHandler): 16 (WebCore::QNetworkReplyHandler::bufferedData): 17 (WebCore::QNetworkReplyHandler::sendResponseIfNeeded): 18 (WebCore::QNetworkReplyHandler::downloadProgress): 19 (WebCore::QNetworkReplyHandler::forwardData): 20 (WebCore::QNetworkReplyHandler::start): 21 * platform/network/qt/QNetworkReplyHandler.h: 22 * platform/network/qt/ResourceHandleQt.cpp: 23 (WebCore::ResourceHandle::supportsBufferedData): 24 (WebCore::ResourceHandle::bufferedData): 25 * platform/qt/SharedBufferQt.cpp: 26 (WebCore::SharedBuffer::wrapQtByteBlock): 27 (WebCore::SharedBuffer::hasPlatformData): 28 (WebCore::SharedBuffer::platformData): 29 (WebCore::SharedBuffer::platformDataSize): 30 (WebCore::SharedBuffer::maybeTransferPlatformData): 31 (WebCore::SharedBuffer::clearPlatformData): 32 1 33 2011-03-08 Alejandro G. Castro <alex@igalia.com> 2 34 -
trunk/Source/WebCore/WebCore.pro
r80536 r80551 1962 1962 platform/PopupMenu.h \ 1963 1963 platform/qt/ClipboardQt.h \ 1964 platform/qt/QtByteBlock.h \ 1964 1965 platform/qt/QWebPageClient.h \ 1965 1966 platform/qt/QtStyleOptionWebComboBox.h \ … … 2495 2496 platform/qt/PlatformTouchEventQt.cpp \ 2496 2497 platform/qt/PlatformTouchPointQt.cpp \ 2498 platform/qt/QtByteBlock.cpp \ 2497 2499 platform/qt/RenderThemeQt.cpp \ 2498 2500 platform/qt/ScrollbarQt.cpp \ -
trunk/Source/WebCore/platform/SharedBuffer.cpp
r79434 r80551 240 240 } 241 241 242 #if !USE(CF) ||PLATFORM(QT)242 #if !USE(CF) && !PLATFORM(QT) 243 243 244 244 inline void SharedBuffer::clearPlatformData() -
trunk/Source/WebCore/platform/SharedBuffer.h
r79434 r80551 46 46 #endif 47 47 48 #if PLATFORM(QT) 49 #include "QtByteBlock.h" 50 #endif 51 48 52 namespace WebCore { 49 53 … … 73 77 CFDataRef createCFData(); 74 78 static PassRefPtr<SharedBuffer> wrapCFData(CFDataRef); 79 #endif 80 #if PLATFORM(QT) 81 static PassRefPtr<SharedBuffer> wrapQtByteBlock(PassRefPtr<QtByteBlock>); 75 82 #endif 76 83 … … 135 142 RetainPtr<CFDataRef> m_cfData; 136 143 #endif 144 #if PLATFORM(QT) 145 RefPtr<QtByteBlock> m_qtByteBlock; 146 #endif 147 137 148 }; 138 149 -
trunk/Source/WebCore/platform/network/qt/QNetworkReplyHandler.cpp
r79795 r80551 32 32 #include <QFile> 33 33 #include <QFileInfo> 34 #include <QNetworkRequest> 34 35 #include <QNetworkReply> 35 36 #include <QNetworkCookie> 37 #include <QSharedPointer> 36 38 #include <qwebframe.h> 37 39 #include <qwebpage.h> … … 57 59 58 60 static const int gMaxRecursionLimit = 10; 61 62 Q_DECLARE_METATYPE(QSharedPointer<char>) 59 63 60 64 namespace WebCore { … … 196 200 , m_shouldForwardData(false) 197 201 , m_redirectionTries(gMaxRecursionLimit) 202 , m_usingZeroCopy(false) 198 203 { 199 204 const ResourceRequest &r = m_resourceHandle->firstRequest(); … … 223 228 m_request = r.toNetworkRequest(originatingObject); 224 229 230 // We allow the QNetworkAccessManager to allocate the whole buffer up to a certain size. 231 m_request.setAttribute(QNetworkRequest::MaximumDownloadBufferSizeAttribute, 1024 * 256); // 256 kB. 232 225 233 if (m_loadMode == LoadSynchronously) 226 234 m_request.setAttribute(gSynchronousNetworkRequestAttribute, true); … … 278 286 } 279 287 288 PassRefPtr<SharedBuffer> QNetworkReplyHandler::bufferedData() 289 { 290 return m_bufferedData; 291 } 292 280 293 static bool ignoreHttpError(QNetworkReply* reply, bool receivedData) 281 294 { … … 359 372 if (!client) 360 373 return; 374 375 // Check if there is a zerocopy buffer. 376 QVariant downloadBufferVariant = m_reply->attribute(QNetworkRequest::DownloadBufferAttribute); 377 QSharedPointer<char> downloadBuffer = downloadBufferVariant.value<QSharedPointer<char> >(); 378 if (!downloadBuffer.isNull()) { 379 m_byteBlock = QtByteBlock::create(downloadBuffer); 380 m_bufferedData = SharedBuffer::wrapQtByteBlock(m_byteBlock); 381 m_usingZeroCopy = true; 382 } else { 383 // Use the legacy way of using QNetworkReply as a QIODevice. 384 m_bufferedData = SharedBuffer::create(); 385 m_usingZeroCopy = false; 386 } 361 387 362 388 WTF::String contentType = m_reply->header(QNetworkRequest::ContentTypeHeader).toString(); … … 448 474 } 449 475 450 void QNetworkReplyHandler::forwardData() 476 477 void QNetworkReplyHandler::downloadProgress(qint64 bytesReceived, qint64 bytesTotal) 451 478 { 452 479 m_shouldForwardData = (m_loadMode != LoadNormal); … … 454 481 return; 455 482 483 if (!m_usingZeroCopy) 484 return; 485 486 sendResponseIfNeeded(); 487 488 // Don't emit the "Document has moved here" type of HTML. 489 if (m_redirected) 490 return; 491 492 if (!m_resourceHandle) 493 return; 494 495 ResourceHandleClient* client = m_resourceHandle->client(); 496 if (!client) 497 return; 498 499 // If the server just closes the connection we get a (0,0) progress but 500 // we did not receive a metaDataChanged() signal before so there is no m_byteBlock. 501 if (!m_byteBlock) 502 return; 503 504 qint64 oldSize = m_byteBlock->size(); 505 m_byteBlock->setSize(bytesReceived); 506 m_byteBlock->setCapacity(bytesTotal); 507 508 client->didReceiveData(m_resourceHandle, m_byteBlock->data() + oldSize, 509 bytesReceived - oldSize, bytesReceived - oldSize); 510 } 511 512 void QNetworkReplyHandler::forwardData() 513 { 514 m_shouldForwardData = (m_loadMode != LoadNormal); 515 if (m_shouldForwardData) 516 return; 517 456 518 if (m_reply->bytesAvailable()) 457 519 m_responseContainsData = true; 458 520 521 if (m_usingZeroCopy) 522 return; 523 459 524 sendResponseIfNeeded(); 460 525 … … 472 537 return; 473 538 474 if (!data.isEmpty()) 539 if (!data.isEmpty()) { 475 540 client->didReceiveData(m_resourceHandle, data.constData(), data.length(), data.length() /*FixMe*/); 541 m_bufferedData->append(data.constData(), data.length()); 542 } 476 543 } 477 544 … … 581 648 } 582 649 650 // For zero copy. 651 connect(m_reply, SIGNAL(downloadProgress(qint64, qint64)), 652 this, SLOT(downloadProgress(qint64, qint64)), SIGNAL_CONN); 653 583 654 // Make this a direct function call once we require 4.6.1+. 584 655 connect(this, SIGNAL(processQueuedItems()), -
trunk/Source/WebCore/platform/network/qt/QNetworkReplyHandler.h
r79795 r80551 24 24 #include <QNetworkRequest> 25 25 #include <QNetworkAccessManager> 26 27 #include <SharedBuffer.h> 26 28 27 29 #include "FormData.h" … … 56 58 QNetworkReply* release(); 57 59 60 PassRefPtr<SharedBuffer> bufferedData(); 61 58 62 signals: 59 63 void processQueuedItems(); … … 64 68 void forwardData(); 65 69 void sendQueuedItems(); 70 void downloadProgress(qint64 bytesReceived, qint64 bytesTotal); 66 71 void uploadProgress(qint64 bytesSent, qint64 bytesTotal); 67 72 … … 86 91 bool m_shouldForwardData; 87 92 int m_redirectionTries; 93 94 // Using the QNetworkAccessManager download buffer feature. 95 bool m_usingZeroCopy; 96 97 // For zerocopy. Holds the download data. 98 RefPtr<QtByteBlock> m_byteBlock; 99 100 // For zerocopy it wraps m_byteBlock, otherwise it holds data normally. 101 RefPtr<SharedBuffer> m_bufferedData; 88 102 }; 89 103 -
trunk/Source/WebCore/platform/network/qt/ResourceHandleQt.cpp
r79795 r80551 184 184 bool ResourceHandle::supportsBufferedData() 185 185 { 186 return false;186 return true; 187 187 } 188 188 189 189 PassRefPtr<SharedBuffer> ResourceHandle::bufferedData() 190 190 { 191 ASSERT_NOT_REACHED(); 191 if (d->m_job) 192 return d->m_job->bufferedData(); 193 192 194 return 0; 193 195 } -
trunk/Source/WebCore/platform/qt/SharedBufferQt.cpp
r60009 r80551 26 26 #include "config.h" 27 27 #include "SharedBuffer.h" 28 #include "QtByteBlock.h" 28 29 29 30 #include <QFile> … … 45 46 } 46 47 48 PassRefPtr<SharedBuffer> SharedBuffer::wrapQtByteBlock(PassRefPtr<QtByteBlock> byteBlock) 49 { 50 SharedBuffer* sharedBuffer = new SharedBuffer(); 51 sharedBuffer->m_qtByteBlock = byteBlock; 52 return adoptRef(sharedBuffer); 53 } 54 55 bool SharedBuffer::hasPlatformData() const 56 { 57 return m_qtByteBlock; 58 } 59 60 const char* SharedBuffer::platformData() const 61 { 62 return static_cast<const char*>(m_qtByteBlock->data()); 63 } 64 65 unsigned SharedBuffer::platformDataSize() const 66 { 67 return m_qtByteBlock->size(); 68 } 69 70 void SharedBuffer::maybeTransferPlatformData() 71 { 72 if (!m_qtByteBlock) 73 return; 74 75 RefPtr<QtByteBlock> byteBlock = m_qtByteBlock; 76 m_qtByteBlock = 0; 77 append(static_cast<const char*>(byteBlock->data()), byteBlock->size()); 78 } 79 80 void SharedBuffer::clearPlatformData() 81 { 82 m_qtByteBlock = 0; 83 } 84 85 47 86 } // namespace WebCore
Note: See TracChangeset
for help on using the changeset viewer.