Title: [156349] trunk/Source/WebKit2
Revision
156349
Author
[email protected]
Date
2013-09-24 12:23:13 -0700 (Tue, 24 Sep 2013)

Log Message

Remove create functions from MessageDecoder and ArgumentDecoder
https://bugs.webkit.org/show_bug.cgi?id=121850

Reviewed by Antti Koivisto.

* Platform/CoreIPC/ArgumentDecoder.cpp:
(CoreIPC::ArgumentDecoder::ArgumentDecoder):
* Platform/CoreIPC/ArgumentDecoder.h:
* Platform/CoreIPC/MessageDecoder.cpp:
(CoreIPC::MessageDecoder::MessageDecoder):
* Platform/CoreIPC/MessageDecoder.h:
* Platform/CoreIPC/mac/ConnectionMac.cpp:
(CoreIPC::createMessageDecoder):
* WebProcess/WebPage/DecoderAdapter.cpp:
(WebKit::DecoderAdapter::DecoderAdapter):
(WebKit::DecoderAdapter::decodeBytes):
(WebKit::DecoderAdapter::decodeBool):
(WebKit::DecoderAdapter::decodeUInt16):
(WebKit::DecoderAdapter::decodeUInt32):
(WebKit::DecoderAdapter::decodeUInt64):
(WebKit::DecoderAdapter::decodeInt32):
(WebKit::DecoderAdapter::decodeInt64):
(WebKit::DecoderAdapter::decodeFloat):
(WebKit::DecoderAdapter::decodeDouble):
(WebKit::DecoderAdapter::decodeString):
* WebProcess/WebPage/DecoderAdapter.h:
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::postInjectedBundleMessage):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (156348 => 156349)


--- trunk/Source/WebKit2/ChangeLog	2013-09-24 19:18:46 UTC (rev 156348)
+++ trunk/Source/WebKit2/ChangeLog	2013-09-24 19:23:13 UTC (rev 156349)
@@ -1,3 +1,34 @@
+2013-09-24  Anders Carlsson  <[email protected]>
+
+        Remove create functions from MessageDecoder and ArgumentDecoder
+        https://bugs.webkit.org/show_bug.cgi?id=121850
+
+        Reviewed by Antti Koivisto.
+
+        * Platform/CoreIPC/ArgumentDecoder.cpp:
+        (CoreIPC::ArgumentDecoder::ArgumentDecoder):
+        * Platform/CoreIPC/ArgumentDecoder.h:
+        * Platform/CoreIPC/MessageDecoder.cpp:
+        (CoreIPC::MessageDecoder::MessageDecoder):
+        * Platform/CoreIPC/MessageDecoder.h:
+        * Platform/CoreIPC/mac/ConnectionMac.cpp:
+        (CoreIPC::createMessageDecoder):
+        * WebProcess/WebPage/DecoderAdapter.cpp:
+        (WebKit::DecoderAdapter::DecoderAdapter):
+        (WebKit::DecoderAdapter::decodeBytes):
+        (WebKit::DecoderAdapter::decodeBool):
+        (WebKit::DecoderAdapter::decodeUInt16):
+        (WebKit::DecoderAdapter::decodeUInt32):
+        (WebKit::DecoderAdapter::decodeUInt64):
+        (WebKit::DecoderAdapter::decodeInt32):
+        (WebKit::DecoderAdapter::decodeInt64):
+        (WebKit::DecoderAdapter::decodeFloat):
+        (WebKit::DecoderAdapter::decodeDouble):
+        (WebKit::DecoderAdapter::decodeString):
+        * WebProcess/WebPage/DecoderAdapter.h:
+        * WebProcess/WebProcess.cpp:
+        (WebKit::WebProcess::postInjectedBundleMessage):
+
 2013-09-24  Mark Rowe  <[email protected]>
 
         <rdar://problem/14971518> WebKit should build against the Xcode default toolchain when targeting OS X 10.8

Modified: trunk/Source/WebKit2/Platform/CoreIPC/ArgumentDecoder.cpp (156348 => 156349)


--- trunk/Source/WebKit2/Platform/CoreIPC/ArgumentDecoder.cpp	2013-09-24 19:18:46 UTC (rev 156348)
+++ trunk/Source/WebKit2/Platform/CoreIPC/ArgumentDecoder.cpp	2013-09-24 19:23:13 UTC (rev 156349)
@@ -31,17 +31,16 @@
 
 namespace CoreIPC {
 
-PassOwnPtr<ArgumentDecoder> ArgumentDecoder::create(const uint8_t* buffer, size_t bufferSize)
+ArgumentDecoder::ArgumentDecoder(const uint8_t* buffer, size_t bufferSize)
 {
-    Vector<Attachment> attachments;
-    return adoptPtr(new ArgumentDecoder(buffer, bufferSize, attachments));
+    initialize(buffer, bufferSize);
 }
 
-ArgumentDecoder::ArgumentDecoder(const uint8_t* buffer, size_t bufferSize, Vector<Attachment>& attachments)
+ArgumentDecoder::ArgumentDecoder(const uint8_t* buffer, size_t bufferSize, Vector<Attachment> attachments)
 {
     initialize(buffer, bufferSize);
 
-    m_attachments.swap(attachments);
+    m_attachments = std::move(attachments);
 }
 
 ArgumentDecoder::~ArgumentDecoder()

Modified: trunk/Source/WebKit2/Platform/CoreIPC/ArgumentDecoder.h (156348 => 156349)


--- trunk/Source/WebKit2/Platform/CoreIPC/ArgumentDecoder.h	2013-09-24 19:18:46 UTC (rev 156348)
+++ trunk/Source/WebKit2/Platform/CoreIPC/ArgumentDecoder.h	2013-09-24 19:23:13 UTC (rev 156349)
@@ -37,7 +37,7 @@
     
 class ArgumentDecoder {
 public:
-    static PassOwnPtr<ArgumentDecoder> create(const uint8_t* buffer, size_t bufferSize);
+    ArgumentDecoder(const uint8_t* buffer, size_t bufferSize);
     virtual ~ArgumentDecoder();
 
     uint64_t destinationID() const { return m_destinationID; }
@@ -93,7 +93,7 @@
     bool removeAttachment(Attachment&);
 
 protected:
-    ArgumentDecoder(const uint8_t* buffer, size_t bufferSize, Vector<Attachment>&);
+    ArgumentDecoder(const uint8_t* buffer, size_t bufferSize, Vector<Attachment>);
 
     void initialize(const uint8_t* buffer, size_t bufferSize);
 

Modified: trunk/Source/WebKit2/Platform/CoreIPC/MessageDecoder.cpp (156348 => 156349)


--- trunk/Source/WebKit2/Platform/CoreIPC/MessageDecoder.cpp	2013-09-24 19:18:46 UTC (rev 156348)
+++ trunk/Source/WebKit2/Platform/CoreIPC/MessageDecoder.cpp	2013-09-24 19:23:13 UTC (rev 156349)
@@ -37,22 +37,11 @@
 
 namespace CoreIPC {
 
-PassOwnPtr<MessageDecoder> MessageDecoder::create(const DataReference& buffer)
-{
-    Vector<Attachment> attachments;
-    return adoptPtr(new MessageDecoder(buffer, attachments));
-}
-
-PassOwnPtr<MessageDecoder> MessageDecoder::create(const DataReference& buffer, Vector<Attachment>& attachments)
-{
-    return adoptPtr(new MessageDecoder(buffer, attachments));
-}
-
 MessageDecoder::~MessageDecoder()
 {
 }
 
-MessageDecoder::MessageDecoder(const DataReference& buffer, Vector<Attachment>& attachments)
+MessageDecoder::MessageDecoder(const DataReference& buffer, Vector<Attachment> attachments)
     : ArgumentDecoder(buffer.data(), buffer.size(), attachments)
 {
     if (!decode(m_messageFlags))

Modified: trunk/Source/WebKit2/Platform/CoreIPC/MessageDecoder.h (156348 => 156349)


--- trunk/Source/WebKit2/Platform/CoreIPC/MessageDecoder.h	2013-09-24 19:18:46 UTC (rev 156348)
+++ trunk/Source/WebKit2/Platform/CoreIPC/MessageDecoder.h	2013-09-24 19:23:13 UTC (rev 156349)
@@ -36,8 +36,7 @@
 
 class MessageDecoder : public ArgumentDecoder {
 public:
-    static PassOwnPtr<MessageDecoder> create(const DataReference& buffer);
-    static PassOwnPtr<MessageDecoder> create(const DataReference& buffer, Vector<Attachment>&);
+    MessageDecoder(const DataReference& buffer, Vector<Attachment>);
     virtual ~MessageDecoder();
 
     StringReference messageReceiverName() const { return m_messageReceiverName; }
@@ -51,8 +50,6 @@
 #endif
 
 private:
-    MessageDecoder(const DataReference& buffer, Vector<Attachment>&);
-
     uint8_t m_messageFlags;
     StringReference m_messageReceiverName;
     StringReference m_messageName;

Modified: trunk/Source/WebKit2/Platform/CoreIPC/mac/ConnectionMac.cpp (156348 => 156349)


--- trunk/Source/WebKit2/Platform/CoreIPC/mac/ConnectionMac.cpp	2013-09-24 19:18:46 UTC (rev 156348)
+++ trunk/Source/WebKit2/Platform/CoreIPC/mac/ConnectionMac.cpp	2013-09-24 19:23:13 UTC (rev 156349)
@@ -299,14 +299,14 @@
     });
 }
 
-static PassOwnPtr<MessageDecoder> createMessageDecoder(mach_msg_header_t* header)
+static OwnPtr<MessageDecoder> createMessageDecoder(mach_msg_header_t* header)
 {
     if (!(header->msgh_bits & MACH_MSGH_BITS_COMPLEX)) {
         // We have a simple message.
         uint8_t* body = reinterpret_cast<uint8_t*>(header + 1);
         size_t bodySize = header->msgh_size - sizeof(mach_msg_header_t);
 
-        return MessageDecoder::create(DataReference(body, bodySize));
+        return createOwned<MessageDecoder>(DataReference(body, bodySize), Vector<Attachment>());
     }
 
     bool messageBodyIsOOL = header->msgh_id & MessageBodyIsOutOfLine;
@@ -351,22 +351,17 @@
         uint8_t* messageBody = static_cast<uint8_t*>(messageBodyAttachment.address());
         size_t messageBodySize = messageBodyAttachment.size();
 
-        OwnPtr<MessageDecoder> decoder;
+        OwnPtr<MessageDecoder> decoder = createOwned<MessageDecoder>(DataReference(messageBody, messageBodySize), std::move(attachments));
 
-        if (attachments.isEmpty())
-            decoder = MessageDecoder::create(DataReference(messageBody, messageBodySize));
-        else
-            decoder = MessageDecoder::create(DataReference(messageBody, messageBodySize), attachments);
-
         vm_deallocate(mach_task_self(), reinterpret_cast<vm_address_t>(messageBodyAttachment.address()), messageBodyAttachment.size());
 
-        return decoder.release();
+        return decoder;
     }
 
     uint8_t* messageBody = descriptorData;
     size_t messageBodySize = header->msgh_size - (descriptorData - reinterpret_cast<uint8_t*>(header));
 
-    return MessageDecoder::create(DataReference(messageBody, messageBodySize), attachments);
+    return createOwned<MessageDecoder>(DataReference(messageBody, messageBodySize), attachments);
 }
 
 // The receive buffer size should always include the maximum trailer size.

Modified: trunk/Source/WebKit2/WebProcess/WebPage/DecoderAdapter.cpp (156348 => 156349)


--- trunk/Source/WebKit2/WebProcess/WebPage/DecoderAdapter.cpp	2013-09-24 19:18:46 UTC (rev 156348)
+++ trunk/Source/WebKit2/WebProcess/WebPage/DecoderAdapter.cpp	2013-09-24 19:23:13 UTC (rev 156349)
@@ -33,19 +33,19 @@
 namespace WebKit {
 
 DecoderAdapter::DecoderAdapter(const uint8_t* buffer, size_t bufferSize)
-    : m_decoder(CoreIPC::ArgumentDecoder::create(buffer, bufferSize))
+    : m_decoder(buffer, bufferSize)
 {
     // Keep format compatibility by decoding an unused uint64_t value
     // that used to be encoded by the argument encoder.
     uint64_t value;
-    m_decoder->decode(value);
+    m_decoder.decode(value);
     ASSERT(!value);
 }
 
 bool DecoderAdapter::decodeBytes(Vector<uint8_t>& bytes)
 {
     CoreIPC::DataReference dataReference;
-    if (!m_decoder->decode(dataReference))
+    if (!m_decoder.decode(dataReference))
         return false;
 
     bytes = dataReference.vector();
@@ -54,42 +54,42 @@
 
 bool DecoderAdapter::decodeBool(bool& value)
 {
-    return m_decoder->decode(value);
+    return m_decoder.decode(value);
 }
 
 bool DecoderAdapter::decodeUInt16(uint16_t& value)
 {
-    return m_decoder->decode(value);
+    return m_decoder.decode(value);
 }
 
 bool DecoderAdapter::decodeUInt32(uint32_t& value)
 {
-    return m_decoder->decode(value);
+    return m_decoder.decode(value);
 }
 
 bool DecoderAdapter::decodeUInt64(uint64_t& value)
 {
-    return m_decoder->decode(value);
+    return m_decoder.decode(value);
 }
 
 bool DecoderAdapter::decodeInt32(int32_t& value)
 {
-    return m_decoder->decode(value);
+    return m_decoder.decode(value);
 }
 
 bool DecoderAdapter::decodeInt64(int64_t& value)
 {
-    return m_decoder->decode(value);
+    return m_decoder.decode(value);
 }
 
 bool DecoderAdapter::decodeFloat(float& value)
 {
-    return m_decoder->decode(value);
+    return m_decoder.decode(value);
 }
 
 bool DecoderAdapter::decodeDouble(double& value)
 {
-    return m_decoder->decode(value);
+    return m_decoder.decode(value);
 }
 
 bool DecoderAdapter::decodeString(String& value)
@@ -101,7 +101,7 @@
     // without breaking encoding/decoding of the history tree.
 
     uint32_t length;
-    if (!m_decoder->decode(length))
+    if (!m_decoder.decode(length))
         return false;
 
     if (length == std::numeric_limits<uint32_t>::max()) {
@@ -111,26 +111,26 @@
     }
 
     uint64_t lengthInBytes;
-    if (!m_decoder->decode(lengthInBytes))
+    if (!m_decoder.decode(lengthInBytes))
         return false;
 
     if (lengthInBytes % sizeof(UChar) || lengthInBytes / sizeof(UChar) != length) {
-        m_decoder->markInvalid();
+        m_decoder.markInvalid();
         return false;
     }
 
-    if (!m_decoder->bufferIsLargeEnoughToContain<UChar>(length)) {
-        m_decoder->markInvalid();
+    if (!m_decoder.bufferIsLargeEnoughToContain<UChar>(length)) {
+        m_decoder.markInvalid();
         return false;
     }
 
     UChar* buffer;
     String string = String::createUninitialized(length, buffer);
-    if (!m_decoder->decodeFixedLengthData(reinterpret_cast<uint8_t*>(buffer), length * sizeof(UChar), __alignof(UChar)))
+    if (!m_decoder.decodeFixedLengthData(reinterpret_cast<uint8_t*>(buffer), length * sizeof(UChar), __alignof(UChar)))
         return false;
 
     value = string;
     return true;
 }
 
-}
+} // namespace WebKit

Modified: trunk/Source/WebKit2/WebProcess/WebPage/DecoderAdapter.h (156348 => 156349)


--- trunk/Source/WebKit2/WebProcess/WebPage/DecoderAdapter.h	2013-09-24 19:18:46 UTC (rev 156348)
+++ trunk/Source/WebKit2/WebProcess/WebPage/DecoderAdapter.h	2013-09-24 19:23:13 UTC (rev 156349)
@@ -48,7 +48,7 @@
     virtual bool decodeDouble(double&);
     virtual bool decodeString(String&);
 
-    OwnPtr<CoreIPC::ArgumentDecoder> m_decoder;
+    CoreIPC::ArgumentDecoder m_decoder;
 };
 
 } // namespace WebKit

Modified: trunk/Source/WebKit2/WebProcess/WebProcess.cpp (156348 => 156349)


--- trunk/Source/WebKit2/WebProcess/WebProcess.cpp	2013-09-24 19:18:46 UTC (rev 156348)
+++ trunk/Source/WebKit2/WebProcess/WebProcess.cpp	2013-09-24 19:23:13 UTC (rev 156349)
@@ -973,15 +973,15 @@
     if (!injectedBundle)
         return;
 
-    OwnPtr<CoreIPC::ArgumentDecoder> decoder = CoreIPC::ArgumentDecoder::create(messageData.data(), messageData.size());
+    CoreIPC::ArgumentDecoder decoder(messageData.data(), messageData.size());
 
     String messageName;
-    if (!decoder->decode(messageName))
+    if (!decoder.decode(messageName))
         return;
 
     RefPtr<APIObject> messageBody;
     InjectedBundleUserMessageDecoder messageBodyDecoder(messageBody);
-    if (!decoder->decode(messageBodyDecoder))
+    if (!decoder.decode(messageBodyDecoder))
         return;
 
     injectedBundle->didReceiveMessage(messageName, messageBody.get());
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to