Make IPC::SharedBufferDataReference a type that decodes into but does not inherit...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 12 Sep 2018 21:22:16 +0000 (21:22 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 12 Sep 2018 21:22:16 +0000 (21:22 +0000)
https://bugs.webkit.org/show_bug.cgi?id=189519

Patch by Alex Christensen <achristensen@webkit.org> on 2018-09-12
Reviewed by Chris Dumez.

* NetworkProcess/NetworkConnectionToWebProcess.messages.in:
* NetworkProcess/NetworkResourceLoader.cpp:
(WebKit::NetworkResourceLoader::bufferingTimerFired):
(WebKit::NetworkResourceLoader::sendBuffer):
* Platform/IPC/DataReference.cpp:
(IPC::SharedBufferDataReference::encode const): Deleted.
* Platform/IPC/DataReference.h:
(IPC::SharedBufferDataReference::SharedBufferDataReference): Deleted.
* Platform/IPC/HandleMessage.h:
* Platform/IPC/SharedBufferDataReference.h: Added.
(IPC::SharedBufferDataReference::SharedBufferDataReference):
(IPC::SharedBufferDataReference::encode const):
* Scripts/webkit/messages.py:
* Shared/API/APIData.h:
* StorageProcess/StorageProcess.messages.in:
* UIProcess/WebPageProxy.messages.in:
* UIProcess/WebURLSchemeTask.cpp:
(WebKit::WebURLSchemeTask::didReceiveData):
* WebKit.xcodeproj/project.pbxproj:
* WebProcess/Network/WebLoaderStrategy.cpp:
(WebKit::WebLoaderStrategy::storeDerivedDataToCache):
* WebProcess/Network/WebResourceLoader.messages.in:
* WebProcess/Storage/WebServiceWorkerFetchTaskClient.cpp:
(WebKit::WebServiceWorkerFetchTaskClient::didReceiveData):
(WebKit::WebServiceWorkerFetchTaskClient::didReceiveBlobChunk):
* WebProcess/WebCoreSupport/WebEditorClient.cpp:
(WebKit::WebEditorClient::registerAttachmentIdentifier):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::getContentsAsMHTMLData):
(WebKit::WebPage::getSelectionAsWebArchiveData):
(WebKit::WebPage::getMainResourceDataOfFrame):
(WebKit::WebPage::getResourceDataFromFrame):
(WebKit::WebPage::getWebArchiveOfFrame):
(WebKit::WebPage::drawPagesToPDF):
* WebProcess/WebPage/WebPage.messages.in:

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

21 files changed:
Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.messages.in
Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp
Source/WebKit/Platform/IPC/DataReference.cpp
Source/WebKit/Platform/IPC/DataReference.h
Source/WebKit/Platform/IPC/HandleMessage.h
Source/WebKit/Platform/IPC/SharedBufferDataReference.h [new file with mode: 0644]
Source/WebKit/Scripts/webkit/messages.py
Source/WebKit/Shared/API/APIData.h
Source/WebKit/StorageProcess/StorageProcess.messages.in
Source/WebKit/UIProcess/API/glib/WebKitFaviconDatabase.cpp
Source/WebKit/UIProcess/WebPageProxy.messages.in
Source/WebKit/UIProcess/WebURLSchemeTask.cpp
Source/WebKit/WebKit.xcodeproj/project.pbxproj
Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp
Source/WebKit/WebProcess/Network/WebResourceLoader.messages.in
Source/WebKit/WebProcess/Storage/ServiceWorkerClientFetch.cpp
Source/WebKit/WebProcess/Storage/WebServiceWorkerFetchTaskClient.cpp
Source/WebKit/WebProcess/WebCoreSupport/WebEditorClient.cpp
Source/WebKit/WebProcess/WebPage/WebPage.cpp
Source/WebKit/WebProcess/WebPage/WebPage.messages.in

index e57fdef..19cacd8 100644 (file)
@@ -1,3 +1,46 @@
+2018-09-12  Alex Christensen  <achristensen@webkit.org>
+
+        Make IPC::SharedBufferDataReference a type that decodes into but does not inherit from IPC::DataReference
+        https://bugs.webkit.org/show_bug.cgi?id=189519
+
+        Reviewed by Chris Dumez.
+
+        * NetworkProcess/NetworkConnectionToWebProcess.messages.in:
+        * NetworkProcess/NetworkResourceLoader.cpp:
+        (WebKit::NetworkResourceLoader::bufferingTimerFired):
+        (WebKit::NetworkResourceLoader::sendBuffer):
+        * Platform/IPC/DataReference.cpp:
+        (IPC::SharedBufferDataReference::encode const): Deleted.
+        * Platform/IPC/DataReference.h:
+        (IPC::SharedBufferDataReference::SharedBufferDataReference): Deleted.
+        * Platform/IPC/HandleMessage.h:
+        * Platform/IPC/SharedBufferDataReference.h: Added.
+        (IPC::SharedBufferDataReference::SharedBufferDataReference):
+        (IPC::SharedBufferDataReference::encode const):
+        * Scripts/webkit/messages.py:
+        * Shared/API/APIData.h:
+        * StorageProcess/StorageProcess.messages.in:
+        * UIProcess/WebPageProxy.messages.in:
+        * UIProcess/WebURLSchemeTask.cpp:
+        (WebKit::WebURLSchemeTask::didReceiveData):
+        * WebKit.xcodeproj/project.pbxproj:
+        * WebProcess/Network/WebLoaderStrategy.cpp:
+        (WebKit::WebLoaderStrategy::storeDerivedDataToCache):
+        * WebProcess/Network/WebResourceLoader.messages.in:
+        * WebProcess/Storage/WebServiceWorkerFetchTaskClient.cpp:
+        (WebKit::WebServiceWorkerFetchTaskClient::didReceiveData):
+        (WebKit::WebServiceWorkerFetchTaskClient::didReceiveBlobChunk):
+        * WebProcess/WebCoreSupport/WebEditorClient.cpp:
+        (WebKit::WebEditorClient::registerAttachmentIdentifier):
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::getContentsAsMHTMLData):
+        (WebKit::WebPage::getSelectionAsWebArchiveData):
+        (WebKit::WebPage::getMainResourceDataOfFrame):
+        (WebKit::WebPage::getResourceDataFromFrame):
+        (WebKit::WebPage::getWebArchiveOfFrame):
+        (WebKit::WebPage::drawPagesToPDF):
+        * WebProcess/WebPage/WebPage.messages.in:
+
 2018-09-11  Dean Jackson  <dino@apple.com>
 
         Header parsing for experimental and internal debug features
index cac8a2f..aa8cbdb 100644 (file)
@@ -51,7 +51,7 @@ messages -> NetworkConnectionToWebProcess LegacyReceiver {
     BlobSize(WebCore::URL url) -> (uint64_t resultSize)
     WriteBlobsToTemporaryFiles(Vector<String> blobURLs, uint64_t requestIdentifier)
 
-    StoreDerivedDataToCache(WebKit::NetworkCache::DataKey key, IPC::DataReference data)
+    StoreDerivedDataToCache(WebKit::NetworkCache::DataKey key, IPC::SharedBufferDataReference data)
 
     SetCaptureExtraNetworkLoadMetricsEnabled(bool enabled)
 
index 909acc4..5c11bab 100644 (file)
@@ -37,6 +37,7 @@
 #include "NetworkProcess.h"
 #include "NetworkProcessConnectionMessages.h"
 #include "SessionTracker.h"
+#include "SharedBufferDataReference.h"
 #include "WebCoreArgumentCoders.h"
 #include "WebErrors.h"
 #include "WebPageMessages.h"
@@ -739,21 +740,17 @@ void NetworkResourceLoader::bufferingTimerFired()
     if (m_bufferedData->isEmpty())
         return;
 
-    IPC::SharedBufferDataReference dataReference(m_bufferedData.get());
-    size_t encodedLength = m_bufferedDataEncodedDataLength;
+    send(Messages::WebResourceLoader::DidReceiveData({ *m_bufferedData }, m_bufferedDataEncodedDataLength));
 
     m_bufferedData = SharedBuffer::create();
     m_bufferedDataEncodedDataLength = 0;
-
-    send(Messages::WebResourceLoader::DidReceiveData(dataReference, encodedLength));
 }
 
 void NetworkResourceLoader::sendBuffer(SharedBuffer& buffer, size_t encodedDataLength)
 {
     ASSERT(!isSynchronous());
 
-    IPC::SharedBufferDataReference dataReference(&buffer);
-    send(Messages::WebResourceLoader::DidReceiveData(dataReference, encodedDataLength));
+    send(Messages::WebResourceLoader::DidReceiveData({ buffer }, encodedDataLength));
 }
 
 void NetworkResourceLoader::tryStoreAsCacheEntry()
index 977e9d2..225fda7 100644 (file)
@@ -41,14 +41,4 @@ bool DataReference::decode(Decoder& decoder, DataReference& dataReference)
     return decoder.decodeVariableLengthByteArray(dataReference);
 }
 
-void SharedBufferDataReference::encode(Encoder& encoder) const
-{
-    uint64_t bufferSize = static_cast<uint64_t>(m_buffer->size());
-    encoder.reserve(bufferSize + sizeof(uint64_t));
-    encoder << bufferSize;
-
-    for (const auto& element : *m_buffer)
-        encoder.encodeFixedLengthData(reinterpret_cast<const uint8_t*>(element.segment->data()), element.segment->size(), 1);
-}
-
 } // namespace IPC
index fb57591..96dca38 100644 (file)
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef DataReference_h
-#define DataReference_h
+#pragma once
 
-#include <WebCore/SharedBuffer.h>
 #include <wtf/Vector.h>
 
 namespace IPC {
@@ -36,11 +34,7 @@ class Encoder;
     
 class DataReference {
 public:
-    DataReference()
-        : m_data(0)
-        , m_size(0)
-    {
-    }
+    DataReference() = default;
 
     DataReference(const uint8_t* data, size_t size)
         : m_data(data)
@@ -55,13 +49,13 @@ public:
     {
     }
 
-    bool isEmpty() const { return size() == 0; }
+    bool isEmpty() const { return !m_size; }
 
     size_t size() const { return m_size; }
     const uint8_t* data() const 
     { 
         if (isEmpty())
-            return 0;
+            return nullptr;
         return m_data; 
     }
 
@@ -73,40 +67,12 @@ public:
         return result;
     }
 
-    virtual void encode(Encoder&) const;
+    void encode(Encoder&) const;
     static bool decode(Decoder&, DataReference&);
 
-    virtual ~DataReference() { }
-
 private:
-    const uint8_t* m_data;
-    size_t m_size;
-};
-
-class SharedBufferDataReference : public DataReference {
-public:
-    // FIXME: This class doesn't handle null, so the argument should be a reference or PassRef.
-    SharedBufferDataReference(WebCore::SharedBuffer* buffer)
-        : m_buffer(buffer)
-    {
-    }
-
-private:
-    // FIXME: It is a bad idea to violate the Liskov Substitution Principle as we do here.
-    // Since we are using DataReference as a polymoprhic base class in this fashion,
-    // then we need it to be a base class that does not have functions such as isEmpty,
-    // size, data, and vector, all of which will do the wrong thing if they are called.
-    // Deleting these functions here does not prevent them from being called.
-    bool isEmpty() const = delete;
-    size_t size() const = delete;
-    const uint8_t* data() const = delete;
-    Vector<uint8_t> vector() const = delete;
-
-    void encode(Encoder&) const override;
-
-    RefPtr<WebCore::SharedBuffer> m_buffer;
+    const uint8_t* m_data { nullptr };
+    size_t m_size { 0 };
 };
 
 } // namespace IPC
-
-#endif // DataReference_h
index a836dc9..6247426 100644 (file)
@@ -110,6 +110,12 @@ struct CodingType {
     typedef std::remove_const_t<std::remove_reference_t<T>> Type;
 };
 
+class DataReference;
+class SharedBufferDataReference;
+template<> struct CodingType<const SharedBufferDataReference&> {
+    typedef DataReference Type;
+};
+
 template<typename... Ts>
 struct CodingType<std::tuple<Ts...>> {
     typedef std::tuple<typename CodingType<Ts>::Type...> Type;
diff --git a/Source/WebKit/Platform/IPC/SharedBufferDataReference.h b/Source/WebKit/Platform/IPC/SharedBufferDataReference.h
new file mode 100644 (file)
index 0000000..127f562
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "Encoder.h"
+#include <WebCore/SharedBuffer.h>
+#include <wtf/Variant.h>
+
+namespace IPC {
+
+class SharedBufferDataReference {
+public:
+    SharedBufferDataReference() = default;
+    SharedBufferDataReference(const WebCore::SharedBuffer& buffer)
+        : m_data(buffer) { }
+    SharedBufferDataReference(const uint8_t* data, size_t size)
+        : m_data(std::make_pair(data, size)) { }
+
+    void encode(Encoder& encoder) const
+    {
+        WTF::visit(WTF::makeVisitor(
+            [encoder = &encoder] (const Ref<const WebCore::SharedBuffer>& buffer) mutable {
+                uint64_t bufferSize = buffer->size();
+                encoder->reserve(bufferSize + sizeof(uint64_t));
+                *encoder << bufferSize;
+                for (const auto& element : buffer.get())
+                    encoder->encodeFixedLengthData(reinterpret_cast<const uint8_t*>(element.segment->data()), element.segment->size(), 1);
+            }, [encoder = &encoder] (const std::pair<const uint8_t*, size_t>& pair) mutable {
+                uint64_t bufferSize = pair.second;
+                encoder->reserve(bufferSize + sizeof(uint64_t));
+                *encoder << bufferSize;
+                encoder->encodeFixedLengthData(pair.first, pair.second, 1);
+            }), m_data);
+    }
+
+private:
+    Variant<std::pair<const uint8_t*, size_t>, Ref<const WebCore::SharedBuffer>> m_data;
+};
+
+}
index fc58469..22113bb 100644 (file)
@@ -369,6 +369,7 @@ def headers_for_type(type):
     header_infos_and_types = class_template_headers(type)
 
     special_cases = {
+        'IPC::SharedBufferDataReference': ['"SharedBufferDataReference.h"', '"DataReference.h"'],
         'MachSendRight': ['<wtf/MachSendRight.h>'],
         'MessageLevel': ['<JavaScriptCore/ConsoleTypes.h>'],
         'MessageSource': ['<JavaScriptCore/ConsoleTypes.h>'],
index 16600cb..144e53e 100644 (file)
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef APIData_h
-#define APIData_h
+#pragma once
 
 #include "APIObject.h"
 #include "DataReference.h"
 #include <wtf/Forward.h>
 
+#if PLATFORM(COCOA)
+#include <wtf/RetainPtr.h>
+#endif
+
 namespace IPC {
 class Decoder;
 class Encoder;
@@ -105,5 +108,3 @@ private:
 };
 
 } // namespace API
-
-#endif // APIData_h
index 8190be3..5ed344d 100644 (file)
@@ -41,7 +41,7 @@ messages -> StorageProcess LegacyReceiver {
     DidNotHandleFetch(WebCore::SWServerConnectionIdentifier serverConnectionIdentifier, WebCore::FetchIdentifier fetchIdentifier)
     DidFailFetch(WebCore::SWServerConnectionIdentifier serverConnectionIdentifier, WebCore::FetchIdentifier fetchIdentifier, WebCore::ResourceError error)
     DidReceiveFetchResponse(WebCore::SWServerConnectionIdentifier serverConnectionIdentifier, WebCore::FetchIdentifier fetchIdentifier, WebCore::ResourceResponse response)
-    DidReceiveFetchData(WebCore::SWServerConnectionIdentifier serverConnectionIdentifier, WebCore::FetchIdentifier fetchIdentifier, IPC::DataReference data, int64_t encodedDataLength)
+    DidReceiveFetchData(WebCore::SWServerConnectionIdentifier serverConnectionIdentifier, WebCore::FetchIdentifier fetchIdentifier, IPC::SharedBufferDataReference data, int64_t encodedDataLength)
     DidReceiveFetchFormData(WebCore::SWServerConnectionIdentifier serverConnectionIdentifier, WebCore::FetchIdentifier fetchIdentifier, IPC::FormDataReference data)
     DidFinishFetch(WebCore::SWServerConnectionIdentifier serverConnectionIdentifier, WebCore::FetchIdentifier fetchIdentifier)
     PostMessageToServiceWorkerClient(struct WebCore::ServiceWorkerClientIdentifier destinationIdentifier, struct WebCore::MessageWithMessagePorts message, WebCore::ServiceWorkerIdentifier sourceIdentifier, String sourceOrigin)
index adb3900..9be7253 100644 (file)
@@ -27,6 +27,7 @@
 #include <WebCore/Image.h>
 #include <WebCore/IntSize.h>
 #include <WebCore/RefPtrCairo.h>
+#include <WebCore/SharedBuffer.h>
 #include <glib/gi18n-lib.h>
 #include <wtf/RunLoop.h>
 #include <wtf/SetForScope.h>
index 0f9277b..5c48092 100644 (file)
@@ -167,7 +167,7 @@ messages -> WebPageProxy {
 
     # Callback messages
     VoidCallback(WebKit::CallbackID callbackID)
-    DataCallback(IPC::DataReference resultData, WebKit::CallbackID callbackID)
+    DataCallback(IPC::SharedBufferDataReference resultData, WebKit::CallbackID callbackID)
     ImageCallback(WebKit::ShareableBitmap::Handle bitmapHandle, WebKit::CallbackID callbackID)
     StringCallback(String resultString, WebKit::CallbackID callbackID)
     InvalidateStringCallback(WebKit::CallbackID callbackID)
@@ -530,7 +530,7 @@ messages -> WebPageProxy {
 #endif
 
 #if ENABLE(ATTACHMENT_ELEMENT)
-    RegisterAttachmentIdentifierFromData(String identifier, String contentType, String preferredFileName, IPC::DataReference data)
+    RegisterAttachmentIdentifierFromData(String identifier, String contentType, String preferredFileName, IPC::SharedBufferDataReference data)
     RegisterAttachmentIdentifierFromFilePath(String identifier, String contentType, String filePath)
     CloneAttachmentData(String fromIdentifier, String toIdentifier)
     DidInsertAttachmentWithIdentifier(String identifier, String source)
index 7773899..e1cde8d 100644 (file)
@@ -27,6 +27,7 @@
 #include "WebURLSchemeTask.h"
 
 #include "DataReference.h"
+#include "SharedBufferDataReference.h"
 #include "WebErrors.h"
 #include "WebPageMessages.h"
 #include "WebPageProxy.h"
@@ -116,7 +117,7 @@ auto WebURLSchemeTask::didReceiveData(Ref<SharedBuffer>&& buffer) -> ExceptionTy
         return ExceptionType::None;
     }
 
-    m_page->send(Messages::WebPage::URLSchemeTaskDidReceiveData(m_urlSchemeHandler->identifier(), m_identifier, IPC::SharedBufferDataReference(buffer.ptr())));
+    m_page->send(Messages::WebPage::URLSchemeTaskDidReceiveData(m_urlSchemeHandler->identifier(), m_identifier, { buffer }));
     return ExceptionType::None;
 }
 
index b1fed18..a96baf5 100644 (file)
                5CB2378D1DF0E0C200117AA3 /* _WKWebsitePoliciesInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKWebsitePoliciesInternal.h; sourceTree = "<group>"; };
                5CBC9B891C6524A500A8FDCF /* NetworkDataTask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkDataTask.h; sourceTree = "<group>"; };
                5CBC9B8B1C65257300A8FDCF /* NetworkDataTaskCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = NetworkDataTaskCocoa.mm; sourceTree = "<group>"; };
+               5CC5DB9121488E16006CB8A8 /* SharedBufferDataReference.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SharedBufferDataReference.h; sourceTree = "<group>"; };
                5CD286491E722F440094FDC8 /* _WKUserContentFilterPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _WKUserContentFilterPrivate.h; sourceTree = "<group>"; };
                5CD2864A1E722F440094FDC8 /* WKContentRuleList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKContentRuleList.h; sourceTree = "<group>"; };
                5CD2864B1E722F440094FDC8 /* WKContentRuleList.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKContentRuleList.mm; sourceTree = "<group>"; };
                                1A3EED0D161A535300AEB4F5 /* MessageReceiverMap.h */,
                                1AAB0377185A7C6A00EDF501 /* MessageSender.cpp */,
                                1AAB0378185A7C6A00EDF501 /* MessageSender.h */,
+                               5CC5DB9121488E16006CB8A8 /* SharedBufferDataReference.h */,
                                1AE00D6918327C1200087DD7 /* StringReference.cpp */,
                                1AE00D6A18327C1200087DD7 /* StringReference.h */,
                        );
index 5b7f30d..925fb12 100644 (file)
@@ -33,6 +33,7 @@
 #include "NetworkProcessConnection.h"
 #include "NetworkResourceLoadParameters.h"
 #include "SessionTracker.h"
+#include "SharedBufferDataReference.h"
 #include "WebCompiledContentRuleList.h"
 #include "WebCoreArgumentCoders.h"
 #include "WebErrors.h"
@@ -649,8 +650,7 @@ void WebLoaderStrategy::didFinishPreconnection(uint64_t preconnectionIdentifier,
 void WebLoaderStrategy::storeDerivedDataToCache(const SHA1::Digest& bodyHash, const String& type, const String& partition, WebCore::SharedBuffer& data)
 {
     NetworkCache::DataKey key { partition, type, bodyHash };
-    IPC::SharedBufferDataReference dataReference { &data };
-    WebProcess::singleton().ensureNetworkProcessConnection().connection().send(Messages::NetworkConnectionToWebProcess::StoreDerivedDataToCache(key, dataReference), 0);
+    WebProcess::singleton().ensureNetworkProcessConnection().connection().send(Messages::NetworkConnectionToWebProcess::StoreDerivedDataToCache(key, { data }), 0);
 }
 
 bool WebLoaderStrategy::isOnLine() const
index 4658458..8456fc1 100644 (file)
@@ -24,7 +24,7 @@ messages -> WebResourceLoader LegacyReceiver {
     WillSendRequest(WebCore::ResourceRequest request, WebCore::ResourceResponse redirectResponse)
     DidSendData(uint64_t bytesSent, uint64_t totalBytesToBeSent)
     DidReceiveResponse(WebCore::ResourceResponse response, bool needsContinueDidReceiveResponseMessage)
-    DidReceiveData(IPC::DataReference data, int64_t encodedDataLength)
+    DidReceiveData(IPC::SharedBufferDataReference data, int64_t encodedDataLength)
     DidFinishResourceLoad(WebCore::NetworkLoadMetrics networkLoadMetrics)
     DidRetrieveDerivedData(String type, IPC::DataReference data)
     DidFailResourceLoad(WebCore::ResourceError error)
index 6bf3ed1..ada1102 100644 (file)
@@ -37,6 +37,7 @@
 #include <WebCore/MIMETypeRegistry.h>
 #include <WebCore/NotImplemented.h>
 #include <WebCore/ResourceError.h>
+#include <WebCore/SharedBuffer.h>
 
 namespace WebKit {
 using namespace WebCore;
index 904e4b3..a528706 100644 (file)
@@ -30,6 +30,7 @@
 
 #include "DataReference.h"
 #include "FormDataReference.h"
+#include "SharedBufferDataReference.h"
 #include "StorageProcessMessages.h"
 #include "WebCoreArgumentCoders.h"
 #include "WebErrors.h"
@@ -66,8 +67,7 @@ void WebServiceWorkerFetchTaskClient::didReceiveData(Ref<SharedBuffer>&& buffer)
 {
     if (!m_connection)
         return;
-    IPC::SharedBufferDataReference dataReference { buffer.ptr() };
-    m_connection->send(Messages::StorageProcess::DidReceiveFetchData { m_serverConnectionIdentifier, m_fetchIdentifier, dataReference, static_cast<int64_t>(buffer->size()) }, 0);
+    m_connection->send(Messages::StorageProcess::DidReceiveFetchData { m_serverConnectionIdentifier, m_fetchIdentifier, { buffer }, static_cast<int64_t>(buffer->size()) }, 0);
 }
 
 void WebServiceWorkerFetchTaskClient::didReceiveFormDataAndFinish(Ref<FormData>&& formData)
@@ -107,8 +107,7 @@ void WebServiceWorkerFetchTaskClient::didReceiveBlobChunk(const char* data, size
     if (!m_connection)
         return;
 
-    IPC::DataReference dataReference { reinterpret_cast<const uint8_t*>(data), size };
-    m_connection->send(Messages::StorageProcess::DidReceiveFetchData { m_serverConnectionIdentifier, m_fetchIdentifier, dataReference, static_cast<int64_t>(size) }, 0);
+    m_connection->send(Messages::StorageProcess::DidReceiveFetchData { m_serverConnectionIdentifier, m_fetchIdentifier, { reinterpret_cast<const uint8_t*>(data), size }, static_cast<int64_t>(size) }, 0);
 }
 
 void WebServiceWorkerFetchTaskClient::didFinishBlobLoading()
index 10bc14b..91deb2a 100644 (file)
@@ -27,6 +27,7 @@
 #include "WebEditorClient.h"
 
 #include "EditorState.h"
+#include "SharedBufferDataReference.h"
 #include "UndoOrRedo.h"
 #include "WKBundlePageEditorClient.h"
 #include "WebCoreArgumentCoders.h"
@@ -161,7 +162,7 @@ bool WebEditorClient::shouldApplyStyle(StyleProperties* style, Range* range)
 
 void WebEditorClient::registerAttachmentIdentifier(const String& identifier, const String& contentType, const String& preferredFileName, Ref<SharedBuffer>&& data)
 {
-    m_page->send(Messages::WebPageProxy::RegisterAttachmentIdentifierFromData(identifier, contentType, preferredFileName, IPC::SharedBufferDataReference { data.ptr() }));
+    m_page->send(Messages::WebPageProxy::RegisterAttachmentIdentifierFromData(identifier, contentType, preferredFileName, { data }));
 }
 
 void WebEditorClient::registerAttachmentIdentifier(const String& identifier, const String& contentType, const String& filePath)
index dfcb7d9..0559674 100644 (file)
@@ -63,6 +63,7 @@
 #include "SessionTracker.h"
 #include "ShareSheetCallbackID.h"
 #include "ShareableBitmap.h"
+#include "SharedBufferDataReference.h"
 #include "UserMediaPermissionRequestManager.h"
 #include "ViewGestureGeometryCollector.h"
 #include "VisitedLinkTableController.h"
@@ -2996,12 +2997,7 @@ void WebPage::getContentsAsString(CallbackID callbackID)
 #if ENABLE(MHTML)
 void WebPage::getContentsAsMHTMLData(CallbackID callbackID)
 {
-    auto buffer = MHTMLArchive::generateMHTMLData(m_page.get());
-
-    // FIXME: Use SharedBufferDataReference.
-    IPC::DataReference dataReference;
-    dataReference = IPC::DataReference(reinterpret_cast<const uint8_t*>(buffer->data()), buffer->size());
-    send(Messages::WebPageProxy::DataCallback(dataReference, callbackID));
+    send(Messages::WebPageProxy::DataCallback({ MHTMLArchive::generateMHTMLData(m_page.get()) }, callbackID));
 }
 #endif
 
@@ -3029,10 +3025,10 @@ void WebPage::getSelectionAsWebArchiveData(CallbackID callbackID)
         data = LegacyWebArchive::createFromSelection(frame)->rawDataRepresentation();
 #endif
 
-    IPC::DataReference dataReference;
+    IPC::SharedBufferDataReference dataReference;
 #if PLATFORM(COCOA)
     if (data)
-        dataReference = IPC::DataReference(CFDataGetBytePtr(data.get()), CFDataGetLength(data.get()));
+        dataReference = { CFDataGetBytePtr(data.get()), static_cast<size_t>(CFDataGetLength(data.get())) };
 #endif
     send(Messages::WebPageProxy::DataCallback(dataReference, callbackID));
 }
@@ -3067,10 +3063,9 @@ void WebPage::getMainResourceDataOfFrame(uint64_t frameID, CallbackID callbackID
         }
     }
 
-    // FIXME: Use SharedBufferDataReference.
-    IPC::DataReference dataReference;
+    IPC::SharedBufferDataReference dataReference;
     if (buffer)
-        dataReference = IPC::DataReference(reinterpret_cast<const uint8_t*>(buffer->data()), buffer->size());
+        dataReference = { *buffer };
     send(Messages::WebPageProxy::DataCallback(dataReference, callbackID));
 }
 
@@ -3095,10 +3090,9 @@ void WebPage::getResourceDataFromFrame(uint64_t frameID, const String& resourceU
         buffer = resourceDataForFrame(frame->coreFrame(), resourceURL);
     }
 
-    // FIXME: Use SharedBufferDataReference.
-    IPC::DataReference dataReference;
+    IPC::SharedBufferDataReference dataReference;
     if (buffer)
-        dataReference = IPC::DataReference(reinterpret_cast<const uint8_t*>(buffer->data()), buffer->size());
+        dataReference = { *buffer };
     send(Messages::WebPageProxy::DataCallback(dataReference, callbackID));
 }
 
@@ -3112,10 +3106,10 @@ void WebPage::getWebArchiveOfFrame(uint64_t frameID, CallbackID callbackID)
     UNUSED_PARAM(frameID);
 #endif
 
-    IPC::DataReference dataReference;
+    IPC::SharedBufferDataReference dataReference;
 #if PLATFORM(COCOA)
     if (data)
-        dataReference = IPC::DataReference(CFDataGetBytePtr(data.get()), CFDataGetLength(data.get()));
+        dataReference = { CFDataGetBytePtr(data.get()), static_cast<size_t>(CFDataGetLength(data.get())) };
 #endif
     send(Messages::WebPageProxy::DataCallback(dataReference, callbackID));
 }
@@ -4352,7 +4346,7 @@ void WebPage::drawPagesToPDF(uint64_t frameID, const PrintInfo& printInfo, uint3
 {
     RetainPtr<CFMutableDataRef> pdfPageData;
     drawPagesToPDFImpl(frameID, printInfo, first, count, pdfPageData);
-    send(Messages::WebPageProxy::DataCallback(IPC::DataReference(CFDataGetBytePtr(pdfPageData.get()), CFDataGetLength(pdfPageData.get())), callbackID));
+    send(Messages::WebPageProxy::DataCallback({ CFDataGetBytePtr(pdfPageData.get()), static_cast<size_t>(CFDataGetLength(pdfPageData.get())) }, callbackID));
 }
 
 void WebPage::drawPagesToPDFImpl(uint64_t frameID, const PrintInfo& printInfo, uint32_t first, uint32_t count, RetainPtr<CFMutableDataRef>& pdfPageData)
index c34afeb..6b278f4 100644 (file)
@@ -502,7 +502,7 @@ messages -> WebPage LegacyReceiver {
 
     URLSchemeTaskDidPerformRedirection(uint64_t handlerIdentifier, uint64_t taskIdentifier, WebCore::ResourceResponse response, WebCore::ResourceRequest request)
     URLSchemeTaskDidReceiveResponse(uint64_t handlerIdentifier, uint64_t taskIdentifier, WebCore::ResourceResponse response)
-    URLSchemeTaskDidReceiveData(uint64_t handlerIdentifier, uint64_t taskIdentifier, IPC::DataReference data)
+    URLSchemeTaskDidReceiveData(uint64_t handlerIdentifier, uint64_t taskIdentifier, IPC::SharedBufferDataReference data)
     URLSchemeTaskDidComplete(uint64_t handlerIdentifier, uint64_t taskIdentifier, WebCore::ResourceError error)
 
     SetIsSuspended(bool suspended)