Title: [109789] trunk/Source/WebCore
Revision
109789
Author
a...@apple.com
Date
2012-03-05 13:16:30 -0800 (Mon, 05 Mar 2012)

Log Message

        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.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (109788 => 109789)


--- trunk/Source/WebCore/ChangeLog	2012-03-05 21:10:23 UTC (rev 109788)
+++ trunk/Source/WebCore/ChangeLog	2012-03-05 21:16:30 UTC (rev 109789)
@@ -1,3 +1,19 @@
+2012-03-05  Alexey Proskuryakov  <a...@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  <ander...@apple.com>
 
         Let RenderLayerCompositor set the tile cache visible rect

Modified: trunk/Source/WebCore/platform/network/BlobResourceHandle.cpp (109788 => 109789)


--- trunk/Source/WebCore/platform/network/BlobResourceHandle.cpp	2012-03-05 21:10:23 UTC (rev 109788)
+++ trunk/Source/WebCore/platform/network/BlobResourceHandle.cpp	2012-03-05 21:16:30 UTC (rev 109789)
@@ -230,6 +230,7 @@
     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 @@
 
         // Start reading if in asynchronous mode.
         if (m_async) {
+            RefPtr<BlobResourceHandle> protect(this);
             notifyResponse();
             m_buffer.resize(bufferSize);
             readAsync();
@@ -328,6 +330,7 @@
 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::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::consumeData(const char* data, int bytesRead)
 {
     ASSERT(m_async);
+    RefPtr<BlobResourceHandle> protect(this);
 
     m_totalRemainingSize -= bytesRead;
 
@@ -527,6 +532,7 @@
 void BlobResourceHandle::failed(int errorCode)
 {
     ASSERT(m_async);
+    RefPtr<BlobResourceHandle> protect(this);
 
     // Notify the client.
     notifyFail(errorCode);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to