BlobResourceHandle should keep a reference to itself when calling client...
authorap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 5 Mar 2012 21:16:30 +0000 (21:16 +0000)
committerap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 5 Mar 2012 21:16:30 +0000 (21:16 +0000)
        https://bugs.webkit.org/show_bug.cgi?id=80318

        Reviewed by Brady Eidson.

        * platform/network/BlobResourceHandle.cpp:
        (WebCore::BlobResourceHandle::doStart):
        (WebCore::BlobResourceHandle::getSizeForNext):
        (WebCore::BlobResourceHandle::readSync):
        (WebCore::BlobResourceHandle::readDataAsync):
        (WebCore::BlobResourceHandle::consumeData):
        (WebCore::BlobResourceHandle::failed):
        Added RefPtrs in functions that can result in calling client code, and use "this" object afterwards.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@109789 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/network/BlobResourceHandle.cpp

index f833031..b5d0248 100644 (file)
@@ -1,3 +1,19 @@
+2012-03-05  Alexey Proskuryakov  <ap@apple.com>
+
+        BlobResourceHandle should keep a reference to itself when calling client code.
+        https://bugs.webkit.org/show_bug.cgi?id=80318
+
+        Reviewed by Brady Eidson.
+
+        * platform/network/BlobResourceHandle.cpp:
+        (WebCore::BlobResourceHandle::doStart):
+        (WebCore::BlobResourceHandle::getSizeForNext):
+        (WebCore::BlobResourceHandle::readSync):
+        (WebCore::BlobResourceHandle::readDataAsync):
+        (WebCore::BlobResourceHandle::consumeData):
+        (WebCore::BlobResourceHandle::failed):
+        Added RefPtrs in functions that can result in calling client code, and use "this" object afterwards.
+
 2012-03-05  Anders Carlsson  <andersca@apple.com>
 
         Let RenderLayerCompositor set the tile cache visible rect
index 7da2353..e47b879 100644 (file)
@@ -230,6 +230,7 @@ void BlobResourceHandle::doStart()
     if (m_async)
         getSizeForNext();
     else {
+        RefPtr<BlobResourceHandle> protect(this); // getSizeForNext calls the client
         for (size_t i = 0; i < m_blobData->items().size() && !m_aborted && !m_errorCode; ++i)
             getSizeForNext();
         notifyResponse();
@@ -244,6 +245,7 @@ void BlobResourceHandle::getSizeForNext()
 
         // Start reading if in asynchronous mode.
         if (m_async) {
+            RefPtr<BlobResourceHandle> protect(this);
             notifyResponse();
             m_buffer.resize(bufferSize);
             readAsync();
@@ -328,6 +330,7 @@ void BlobResourceHandle::seek()
 int BlobResourceHandle::readSync(char* buf, int length)
 {
     ASSERT(!m_async);
+    RefPtr<BlobResourceHandle> protect(this);
 
     int offset = 0;
     int remaining = length;
@@ -447,6 +450,7 @@ void BlobResourceHandle::readAsync()
 void BlobResourceHandle::readDataAsync(const BlobDataItem& item)
 {
     ASSERT(m_async);
+    RefPtr<BlobResourceHandle> protect(this);
 
     long long bytesToRead = item.length - m_currentItemReadSize;
     if (bytesToRead > m_totalRemainingSize)
@@ -498,6 +502,7 @@ void BlobResourceHandle::didRead(int bytesRead)
 void BlobResourceHandle::consumeData(const char* data, int bytesRead)
 {
     ASSERT(m_async);
+    RefPtr<BlobResourceHandle> protect(this);
 
     m_totalRemainingSize -= bytesRead;
 
@@ -527,6 +532,7 @@ void BlobResourceHandle::consumeData(const char* data, int bytesRead)
 void BlobResourceHandle::failed(int errorCode)
 {
     ASSERT(m_async);
+    RefPtr<BlobResourceHandle> protect(this);
 
     // Notify the client.
     notifyFail(errorCode);