Title: [183531] trunk/Source/WebKit2
Revision
183531
Author
carlo...@webkit.org
Date
2015-04-28 23:14:51 -0700 (Tue, 28 Apr 2015)

Log Message

Network Cache: Do not create a SharedBuffer for mapped resources unless explicitly requested
https://bugs.webkit.org/show_bug.cgi?id=144337

Reviewed by Antti Koivisto.

We send a buffer or a memory mapped handler to the web process
depending on whether the resource body is mapped or not, but we
are always creating a shared buffer even for mapped resources.
Split initializeBufferFromStorageRecord() moving the mapped memory
handler initialization to its own method.

* NetworkProcess/cache/NetworkCacheEntry.cpp:
(WebKit::NetworkCache::Entry::initializeShareableResourceHandleFromStorageRecord):
Initialize the mapped memory handler if the body data is mapped.
(WebKit::NetworkCache::Entry::initializeBufferFromStorageRecord):
Initialize the buffer by wrapping the mapped memory if the body
data is mapped, or using the body data directly otherwise.
(WebKit::NetworkCache::Entry::shareableResourceHandle): Call
initializeShareableResourceHandleFromStorageRecord() if the
handler is null.
* NetworkProcess/cache/NetworkCacheEntry.h:

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (183530 => 183531)


--- trunk/Source/WebKit2/ChangeLog	2015-04-29 05:51:30 UTC (rev 183530)
+++ trunk/Source/WebKit2/ChangeLog	2015-04-29 06:14:51 UTC (rev 183531)
@@ -1,3 +1,27 @@
+2015-04-28  Carlos Garcia Campos  <cgar...@igalia.com>
+
+        Network Cache: Do not create a SharedBuffer for mapped resources unless explicitly requested
+        https://bugs.webkit.org/show_bug.cgi?id=144337
+
+        Reviewed by Antti Koivisto.
+
+        We send a buffer or a memory mapped handler to the web process
+        depending on whether the resource body is mapped or not, but we
+        are always creating a shared buffer even for mapped resources.
+        Split initializeBufferFromStorageRecord() moving the mapped memory
+        handler initialization to its own method.
+
+        * NetworkProcess/cache/NetworkCacheEntry.cpp:
+        (WebKit::NetworkCache::Entry::initializeShareableResourceHandleFromStorageRecord):
+        Initialize the mapped memory handler if the body data is mapped.
+        (WebKit::NetworkCache::Entry::initializeBufferFromStorageRecord):
+        Initialize the buffer by wrapping the mapped memory if the body
+        data is mapped, or using the body data directly otherwise.
+        (WebKit::NetworkCache::Entry::shareableResourceHandle): Call
+        initializeShareableResourceHandleFromStorageRecord() if the
+        handler is null.
+        * NetworkProcess/cache/NetworkCacheEntry.h:
+
 2015-04-28  Simon Fraser  <simon.fra...@apple.com>
 
         Make a non-static version of FrameView::yPositionForRootContentLayer()

Modified: trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheEntry.cpp (183530 => 183531)


--- trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheEntry.cpp	2015-04-29 05:51:30 UTC (rev 183530)
+++ trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheEntry.cpp	2015-04-29 06:14:51 UTC (rev 183531)
@@ -102,19 +102,28 @@
     return entry;
 }
 
-void Entry::initializeBufferFromStorageRecord() const
+#if ENABLE(SHAREABLE_RESOURCE)
+void Entry::initializeShareableResourceHandleFromStorageRecord() const
 {
     auto* data = ""
     size_t size = m_sourceStorageRecord.body.size();
-#if ENABLE(SHAREABLE_RESOURCE)
     RefPtr<SharedMemory> sharedMemory = m_sourceStorageRecord.body.isMap() ? SharedMemory::create(const_cast<uint8_t*>(data), size, SharedMemory::Protection::ReadOnly) : nullptr;
-    RefPtr<ShareableResource> shareableResource = sharedMemory ? ShareableResource::create(sharedMemory.release(), 0, m_sourceStorageRecord.body.size()) : nullptr;
+    RefPtr<ShareableResource> shareableResource = sharedMemory ? ShareableResource::create(sharedMemory.release(), 0, size) : nullptr;
+    if (shareableResource)
+        shareableResource->createHandle(m_shareableResourceHandle);
+}
+#endif
 
-    if (shareableResource && shareableResource->createHandle(m_shareableResourceHandle))
+void Entry::initializeBufferFromStorageRecord() const
+{
+#if ENABLE(SHAREABLE_RESOURCE)
+    if (!shareableResourceHandle().isNull()) {
         m_buffer = m_shareableResourceHandle.tryWrapInSharedBuffer();
+        if (m_buffer)
+            return;
+    }
 #endif
-    if (!m_buffer)
-        m_buffer = WebCore::SharedBuffer::create(data, size);
+    m_buffer = WebCore::SharedBuffer::create(m_sourceStorageRecord.body.data(), m_sourceStorageRecord.body.size());
 }
 
 WebCore::SharedBuffer* Entry::buffer() const
@@ -128,8 +137,8 @@
 #if ENABLE(SHAREABLE_RESOURCE)
 ShareableResource::Handle& Entry::shareableResourceHandle() const
 {
-    if (!m_buffer)
-        initializeBufferFromStorageRecord();
+    if (m_shareableResourceHandle.isNull())
+        initializeShareableResourceHandleFromStorageRecord();
 
     return m_shareableResourceHandle;
 }

Modified: trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheEntry.h (183530 => 183531)


--- trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheEntry.h	2015-04-29 05:51:30 UTC (rev 183530)
+++ trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheEntry.h	2015-04-29 06:14:51 UTC (rev 183531)
@@ -70,6 +70,9 @@
 private:
     Entry(const Storage::Record&);
     void initializeBufferFromStorageRecord() const;
+#if ENABLE(SHAREABLE_RESOURCE)
+    void initializeShareableResourceHandleFromStorageRecord() const;
+#endif
 
     Key m_key;
     std::chrono::system_clock::time_point m_timeStamp;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to