[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

jianli at chromium.org jianli at chromium.org
Wed Dec 22 12:18:18 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 9c59ae86ee1c3e0f15169bc66768bc1a2d596024
Author: jianli at chromium.org <jianli at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Aug 18 19:03:45 2010 +0000

    Change BlobStorageData to reuse BlobData.
    https://bugs.webkit.org/show_bug.cgi?id=44188
    
    Reviewed by Darin Fisher.
    
    Also addressed Darin's feedbacks for bug 44116.
    
    * html/ThreadableBlobRegistry.cpp:
    (WebCore::registerBlobURLTask):
    (WebCore::registerBlobURLFromTask):
    (WebCore::unregisterBlobURLTask):
    * platform/network/BlobData.cpp:
    (WebCore::BlobData::appendData):
    * platform/network/BlobData.h:
    (WebCore::BlobDataItem::BlobDataItem):
    * platform/network/BlobRegistry.h:
    * platform/network/BlobRegistryImpl.cpp:
    (WebCore::blobRegistry):
    (WebCore::BlobRegistryImpl::appendStorageItems):
    (WebCore::BlobRegistryImpl::registerBlobURL):
    * platform/network/BlobRegistryImpl.h:
    * platform/network/BlobStorageData.h:
    (WebCore::BlobStorageData::create):
    (WebCore::BlobStorageData::contentType):
    (WebCore::BlobStorageData::contentDisposition):
    (WebCore::BlobStorageData::items):
    (WebCore::BlobStorageData::BlobStorageData):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@65622 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 4fdab14..b990ac6 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,33 @@
+2010-08-18  Jian Li  <jianli at chromium.org>
+
+        Reviewed by Darin Fisher.
+
+        Change BlobStorageData to reuse BlobData.
+        https://bugs.webkit.org/show_bug.cgi?id=44188
+
+        Also addressed Darin's feedbacks for bug 44116.
+
+        * html/ThreadableBlobRegistry.cpp:
+        (WebCore::registerBlobURLTask):
+        (WebCore::registerBlobURLFromTask):
+        (WebCore::unregisterBlobURLTask):
+        * platform/network/BlobData.cpp:
+        (WebCore::BlobData::appendData):
+        * platform/network/BlobData.h:
+        (WebCore::BlobDataItem::BlobDataItem):
+        * platform/network/BlobRegistry.h:
+        * platform/network/BlobRegistryImpl.cpp:
+        (WebCore::blobRegistry):
+        (WebCore::BlobRegistryImpl::appendStorageItems):
+        (WebCore::BlobRegistryImpl::registerBlobURL):
+        * platform/network/BlobRegistryImpl.h:
+        * platform/network/BlobStorageData.h:
+        (WebCore::BlobStorageData::create):
+        (WebCore::BlobStorageData::contentType):
+        (WebCore::BlobStorageData::contentDisposition):
+        (WebCore::BlobStorageData::items):
+        (WebCore::BlobStorageData::BlobStorageData):
+
 2010-08-18  David Hyatt  <hyatt at apple.com>
 
         Reviewed by Martin Robinson.
diff --git a/WebCore/html/ThreadableBlobRegistry.cpp b/WebCore/html/ThreadableBlobRegistry.cpp
index 1df290d..d92d570 100644
--- a/WebCore/html/ThreadableBlobRegistry.cpp
+++ b/WebCore/html/ThreadableBlobRegistry.cpp
@@ -56,7 +56,7 @@ static void postTaskToMainThread(ScriptExecutionContext* scriptExecutionContext,
 
 static void registerBlobURLTask(ScriptExecutionContext*, const KURL& url, PassOwnPtr<BlobData> blobData)
 {
-    BlobRegistry::instance().registerBlobURL(url, blobData);
+    blobRegistry().registerBlobURL(url, blobData);
 }
 
 void ThreadableBlobRegistry::registerBlobURL(ScriptExecutionContext* scriptExecutionContext, const KURL& url, PassOwnPtr<BlobData> blobData)
@@ -69,7 +69,7 @@ void ThreadableBlobRegistry::registerBlobURL(ScriptExecutionContext* scriptExecu
 
 static void registerBlobURLFromTask(ScriptExecutionContext*, const KURL& url, const KURL& srcURL)
 {
-    BlobRegistry::instance().registerBlobURL(url, srcURL);
+    blobRegistry().registerBlobURL(url, srcURL);
 }
 
 void ThreadableBlobRegistry::registerBlobURL(ScriptExecutionContext* scriptExecutionContext, const KURL& url, const KURL& srcURL)
@@ -82,7 +82,7 @@ void ThreadableBlobRegistry::registerBlobURL(ScriptExecutionContext* scriptExecu
 
 static void unregisterBlobURLTask(ScriptExecutionContext*, const KURL& url)
 {
-    BlobRegistry::instance().unregisterBlobURL(url);
+    blobRegistry().unregisterBlobURL(url);
 }
 
 void ThreadableBlobRegistry::unregisterBlobURL(ScriptExecutionContext* scriptExecutionContext, const KURL& url)
diff --git a/WebCore/platform/network/BlobData.cpp b/WebCore/platform/network/BlobData.cpp
index bb256d0..21e8917 100644
--- a/WebCore/platform/network/BlobData.cpp
+++ b/WebCore/platform/network/BlobData.cpp
@@ -64,6 +64,11 @@ void BlobData::appendData(const CString& data)
     m_items.append(BlobDataItem(data));
 }
 
+void BlobData::appendData(const CString& data, long long offset, long long length)
+{
+    m_items.append(BlobDataItem(data, offset, length));
+}
+
 void BlobData::appendFile(const String& path)
 {
     m_items.append(BlobDataItem(path));
diff --git a/WebCore/platform/network/BlobData.h b/WebCore/platform/network/BlobData.h
index 17cdfdd..13e3b9c 100644
--- a/WebCore/platform/network/BlobData.h
+++ b/WebCore/platform/network/BlobData.h
@@ -45,14 +45,15 @@ struct BlobDataItem {
 
     // Default constructor.
     BlobDataItem()
-        : offset(0)
+        : type(Data)
+        , offset(0)
         , length(toEndOfFile)
         , expectedModificationTime(doNotCheckFileChange)
     {
     }
 
-    // Constructor for String type.
-    BlobDataItem(const CString& data)
+    // Constructor for String type (complete string).
+    explicit BlobDataItem(const CString& data)
         : type(Data)
         , data(data)
         , offset(0)
@@ -61,8 +62,18 @@ struct BlobDataItem {
     {
     }
 
+    // Constructor for String type (partial string).
+    BlobDataItem(const CString& data, long long offset, long long length)
+        : type(Data)
+        , data(data)
+        , offset(offset)
+        , length(length)
+        , expectedModificationTime(doNotCheckFileChange)
+    {
+    }
+
     // Constructor for File type (complete file).
-    BlobDataItem(const String& path)
+    explicit BlobDataItem(const String& path)
         : type(File)
         , path(path)
         , offset(0)
@@ -105,11 +116,8 @@ struct BlobDataItem {
     // For Blob type.
     KURL url;
 
-    // For File and Blob type.
     long long offset;
     long long length;
-
-    // For File type only.
     double expectedModificationTime;
 };
 
@@ -140,8 +148,14 @@ public:
     void appendBlob(const KURL&, long long offset, long long length);
 
 private:
+    friend class BlobRegistryImpl;
+    friend class BlobStorageData;
+
     BlobData() { }
 
+    // This is only exposed to BlobStorageData.
+    void appendData(const CString&, long long offset, long long length);
+
     String m_contentType;
     String m_contentDisposition;
     BlobDataItemList m_items;
diff --git a/WebCore/platform/network/BlobRegistry.h b/WebCore/platform/network/BlobRegistry.h
index fcd7b1c..7e64233 100644
--- a/WebCore/platform/network/BlobRegistry.h
+++ b/WebCore/platform/network/BlobRegistry.h
@@ -38,6 +38,7 @@
 namespace WebCore {
 
 class BlobData;
+class BlobRegistry;
 class KURL;
 class ResourceError;
 class ResourceHandle;
@@ -45,17 +46,23 @@ class ResourceHandleClient;
 class ResourceRequest;
 class ResourceResponse;
 
+// Returns a single instance of BlobRegistry.
+BlobRegistry& blobRegistry(); 
+
 // BlobRegistry is not thread-safe. It should only be called from main thread.
 class BlobRegistry {
 public:
-    static BlobRegistry& instance();
-
+    // Registers a blob URL referring to the specified blob data.
     virtual void registerBlobURL(const KURL&, PassOwnPtr<BlobData>) = 0;
+    
+    // Registers a blob URL referring to the blob data identified by the specified srcURL.
     virtual void registerBlobURL(const KURL&, const KURL& srcURL) = 0;
+
     virtual void unregisterBlobURL(const KURL&) = 0;
     virtual PassRefPtr<ResourceHandle> createResourceHandle(const ResourceRequest&, ResourceHandleClient*) = 0;
     virtual bool loadResourceSynchronously(const ResourceRequest&, ResourceError&, ResourceResponse&, Vector<char>& data) = 0;
 
+protected:
     virtual ~BlobRegistry() { }
 };
 
diff --git a/WebCore/platform/network/BlobRegistryImpl.cpp b/WebCore/platform/network/BlobRegistryImpl.cpp
index bbbb8f0..dac96ea 100644
--- a/WebCore/platform/network/BlobRegistryImpl.cpp
+++ b/WebCore/platform/network/BlobRegistryImpl.cpp
@@ -32,9 +32,6 @@
 
 #include "BlobRegistryImpl.h"
 
-#include "FileStream.h"
-#include "FileStreamProxy.h"
-#include "FileSystem.h"
 #include "ResourceError.h"
 #include "ResourceHandle.h"
 #include "ResourceLoader.h"
@@ -45,6 +42,13 @@
 
 namespace WebCore {
 
+BlobRegistry& blobRegistry()
+{
+    ASSERT(isMainThread());
+    DEFINE_STATIC_LOCAL(BlobRegistryImpl, instance, ());
+    return instance;
+}
+
 bool BlobRegistryImpl::shouldLoadResource(const ResourceRequest& request) const
 {
     // If the resource is not fetched using the GET method, bail out.
@@ -72,30 +76,23 @@ bool BlobRegistryImpl::loadResourceSynchronously(const ResourceRequest& request,
     return false;
 }
 
-BlobRegistry& BlobRegistry::instance()
-{
-    ASSERT(isMainThread());
-    DEFINE_STATIC_LOCAL(BlobRegistryImpl, instance, ());
-    return instance;
-}
-
-void BlobRegistryImpl::appendStorageItems(BlobStorageData* blobStorageData, const BlobStorageDataItemList& items)
+void BlobRegistryImpl::appendStorageItems(BlobStorageData* blobStorageData, const BlobDataItemList& items)
 {
-    for (BlobStorageDataItemList::const_iterator iter = items.begin(); iter != items.end(); ++iter) {
-        if (iter->type == BlobStorageDataItem::Data)
-            blobStorageData->appendData(iter->data, iter->offset, iter->length);
+    for (BlobDataItemList::const_iterator iter = items.begin(); iter != items.end(); ++iter) {
+        if (iter->type == BlobDataItem::Data)
+            blobStorageData->m_data.appendData(iter->data, iter->offset, iter->length);
         else {
-            ASSERT(iter->type == BlobStorageDataItem::File);
-            blobStorageData->appendFile(iter->path, iter->offset, iter->length, iter->expectedModificationTime);
+            ASSERT(iter->type == BlobDataItem::File);
+            blobStorageData->m_data.appendFile(iter->path, iter->offset, iter->length, iter->expectedModificationTime);
         }
     }
 }
 
-void BlobRegistryImpl::appendStorageItems(BlobStorageData* blobStorageData, const BlobStorageDataItemList& items, long long offset, long long length)
+void BlobRegistryImpl::appendStorageItems(BlobStorageData* blobStorageData, const BlobDataItemList& items, long long offset, long long length)
 {
     ASSERT(length != BlobDataItem::toEndOfFile);
 
-    BlobStorageDataItemList::const_iterator iter = items.begin();
+    BlobDataItemList::const_iterator iter = items.begin();
     if (offset) {
         for (; iter != items.end(); ++iter) {
             if (offset >= iter->length)
@@ -108,11 +105,11 @@ void BlobRegistryImpl::appendStorageItems(BlobStorageData* blobStorageData, cons
     for (; iter != items.end() && length > 0; ++iter) {
         long long currentLength = iter->length - offset;
         long long newLength = currentLength > length ? length : currentLength;
-        if (iter->type == BlobStorageDataItem::Data)
-            blobStorageData->appendData(iter->data, iter->offset + offset, newLength);
+        if (iter->type == BlobDataItem::Data)
+            blobStorageData->m_data.appendData(iter->data, iter->offset + offset, newLength);
         else {
-            ASSERT(iter->type == BlobStorageDataItem::File);
-            blobStorageData->appendFile(iter->path, iter->offset + offset, newLength, iter->expectedModificationTime);
+            ASSERT(iter->type == BlobDataItem::File);
+            blobStorageData->m_data.appendFile(iter->path, iter->offset + offset, newLength, iter->expectedModificationTime);
         }
         offset = 0;
     }
@@ -122,17 +119,20 @@ void BlobRegistryImpl::registerBlobURL(const KURL& url, PassOwnPtr<BlobData> blo
 {
     ASSERT(isMainThread());
 
-    RefPtr<BlobStorageData> blobStorageData = BlobStorageData::create();
-    blobStorageData->setContentType(blobData->contentType());
-    blobStorageData->setContentDisposition(blobData->contentDisposition());
+    RefPtr<BlobStorageData> blobStorageData = BlobStorageData::create(blobData->contentType(), blobData->contentDisposition());
+
+    // The blob data is stored in the "canonical" way. That is, it only contains a list of Data and File items.
+    // 1) The Data item is denoted by the raw data and the range.
+    // 2) The File item is denoted by the file path, the range and the expected modification time.
+    // All the Blob items in the passing blob data are resolved and expanded into a set of Data and File items.
 
     for (BlobDataItemList::const_iterator iter = blobData->items().begin(); iter != blobData->items().end(); ++iter) {
         switch (iter->type) {
         case BlobDataItem::Data:
-            blobStorageData->appendData(iter->data, 0, iter->data.length());
+            blobStorageData->m_data.appendData(iter->data, 0, iter->data.length());
             break;
         case BlobDataItem::File:
-            blobStorageData->appendFile(iter->path, iter->offset, iter->length, iter->expectedModificationTime);
+            blobStorageData->m_data.appendFile(iter->path, iter->offset, iter->length, iter->expectedModificationTime);
             break;
         case BlobDataItem::Blob:
             if (m_blobs.contains(iter->url.string()))
@@ -141,7 +141,6 @@ void BlobRegistryImpl::registerBlobURL(const KURL& url, PassOwnPtr<BlobData> blo
         }
     }
 
-
     m_blobs.set(url.string(), blobStorageData);
 }
 
@@ -154,9 +153,7 @@ void BlobRegistryImpl::registerBlobURL(const KURL& url, const KURL& srcURL)
     if (!src)
         return;
 
-    RefPtr<BlobStorageData> blobStorageData = BlobStorageData::create();
-    blobStorageData->setContentType(src->contentType());
-    blobStorageData->setContentDisposition(src->contentDisposition());
+    RefPtr<BlobStorageData> blobStorageData = BlobStorageData::create(src->contentType(), src->contentDisposition());
     appendStorageItems(blobStorageData.get(), src->items());
     
     m_blobs.set(url.string(), blobStorageData);
diff --git a/WebCore/platform/network/BlobRegistryImpl.h b/WebCore/platform/network/BlobRegistryImpl.h
index 42693bc..f616664 100644
--- a/WebCore/platform/network/BlobRegistryImpl.h
+++ b/WebCore/platform/network/BlobRegistryImpl.h
@@ -63,8 +63,8 @@ public:
 
 private:
     bool shouldLoadResource(const ResourceRequest& request) const;
-    void appendStorageItems(BlobStorageData*, const BlobStorageDataItemList&);
-    void appendStorageItems(BlobStorageData*, const BlobStorageDataItemList&, long long offset, long long length);
+    void appendStorageItems(BlobStorageData*, const BlobDataItemList&);
+    void appendStorageItems(BlobStorageData*, const BlobDataItemList&, long long offset, long long length);
 
     HashMap<String, RefPtr<BlobStorageData> > m_blobs;
 };
diff --git a/WebCore/platform/network/BlobStorageData.h b/WebCore/platform/network/BlobStorageData.h
index f4125a4..6535e62 100644
--- a/WebCore/platform/network/BlobStorageData.h
+++ b/WebCore/platform/network/BlobStorageData.h
@@ -31,76 +31,33 @@
 #ifndef BlobStorageData_h
 #define BlobStorageData_h
 
-#include "PlatformString.h"
+#include "BlobData.h"
 #include <wtf/PassRefPtr.h>
-#include <wtf/Vector.h>
-#include <wtf/text/CString.h>
+#include <wtf/RefCounted.h>
 
 namespace WebCore {
 
-struct BlobStorageDataItem {
-    enum BlobStoreDataItemType { Data, File };
-    BlobStoreDataItemType type;
-    long long offset;
-    long long length;
-
-    // For string data.
-    CString data;
-
-    // For file data.
-    String path;
-    double expectedModificationTime;
-
-    BlobStorageDataItem(const CString& data, long long offset, long long length)
-        : type(Data)
-        , offset(offset)
-        , length(length)
-        , data(data)
-        , expectedModificationTime(0)
-    {
-    }
-
-    BlobStorageDataItem(const String& path, long long offset, long long length, double expectedModificationTime)
-        : type(File)
-        , offset(offset)
-        , length(length)
-        , path(path)
-        , expectedModificationTime(expectedModificationTime)
-    {
-    }
-};
-
-typedef Vector<BlobStorageDataItem> BlobStorageDataItemList;
-
 class BlobStorageData : public RefCounted<BlobStorageData> {
 public:
-    static PassRefPtr<BlobStorageData> create()
+    static PassRefPtr<BlobStorageData> create(const String& contentType, const String& contentDisposition)
     {
-        return adoptRef(new BlobStorageData());
+        return adoptRef(new BlobStorageData(contentType, contentDisposition));
     }
 
-    const String& contentType() const { return m_contentType; }
-    void setContentType(const String& contentType) { m_contentType = contentType; }
-
-    const String& contentDisposition() const { return m_contentDisposition; }
-    void setContentDisposition(const String& contentDisposition) { m_contentDisposition = contentDisposition; }
-    
-    const BlobStorageDataItemList& items() const { return m_items; }
+    const String& contentType() const { return m_data.contentType(); }
+    const String& contentDisposition() const { return m_data.contentDisposition(); }    
+    const BlobDataItemList& items() const { return m_data.items(); }
 
-    void appendData(const CString& data, long long offset, long long length)
-    {
-        m_items.append(BlobStorageDataItem(data, offset, length));
-    }
+private:
+    friend class BlobRegistryImpl;
 
-    void appendFile(const String& path, long long offset, long long length, double expectedModificationTime)
+    BlobStorageData(const String& contentType, const String& contentDisposition)
     {
-        m_items.append(BlobStorageDataItem(path, offset, length, expectedModificationTime));
+        m_data.setContentType(contentType);
+        m_data.setContentDisposition(contentDisposition);
     }
 
-private:
-    String m_contentType;
-    String m_contentDisposition;
-    BlobStorageDataItemList m_items;
+    BlobData m_data;
 };
 
 } // namespace WebCore

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list