Diff
Modified: trunk/Source/WebKit2/ChangeLog (88868 => 88869)
--- trunk/Source/WebKit2/ChangeLog 2011-06-14 23:09:17 UTC (rev 88868)
+++ trunk/Source/WebKit2/ChangeLog 2011-06-14 23:13:03 UTC (rev 88869)
@@ -2,6 +2,28 @@
Reviewed by Sam Weinig.
+ Add encodeVariableLengthByteArray and decodeVariableLengthByteArray
+ https://bugs.webkit.org/show_bug.cgi?id=62674
+
+ Rename the ArgumentDecoder::decodeBytes overload that takes a DataReference to
+ decodeVariableLengthByteArray, to match the added encodeVariableLengthByteArray.
+
+ * Platform/CoreIPC/ArgumentDecoder.cpp:
+ (CoreIPC::ArgumentDecoder::decodeVariableLengthByteArray):
+ * Platform/CoreIPC/ArgumentDecoder.h:
+ * Platform/CoreIPC/ArgumentEncoder.cpp:
+ (CoreIPC::ArgumentEncoder::encodeFixedLengthData):
+ (CoreIPC::ArgumentEncoder::encodeVariableLengthByteArray):
+ * Platform/CoreIPC/ArgumentEncoder.h:
+ * Platform/CoreIPC/DataReference.cpp:
+ (CoreIPC::DataReference::decode):
+ * Shared/mac/SandboxExtensionMac.mm:
+ (WebKit::SandboxExtension::Handle::decode):
+
+2011-06-14 Anders Carlsson <ander...@apple.com>
+
+ Reviewed by Sam Weinig.
+
Add functions for converting between DataReferences and vectors
https://bugs.webkit.org/show_bug.cgi?id=62671
Modified: trunk/Source/WebKit2/Platform/CoreIPC/ArgumentDecoder.cpp (88868 => 88869)
--- trunk/Source/WebKit2/Platform/CoreIPC/ArgumentDecoder.cpp 2011-06-14 23:09:17 UTC (rev 88868)
+++ trunk/Source/WebKit2/Platform/CoreIPC/ArgumentDecoder.cpp 2011-06-14 23:13:03 UTC (rev 88869)
@@ -129,7 +129,7 @@
return true;
}
-bool ArgumentDecoder::decodeBytes(DataReference& dataReference)
+bool ArgumentDecoder::decodeVariableLengthByteArray(DataReference& dataReference)
{
uint64_t size;
if (!decodeUInt64(size))
Modified: trunk/Source/WebKit2/Platform/CoreIPC/ArgumentDecoder.h (88868 => 88869)
--- trunk/Source/WebKit2/Platform/CoreIPC/ArgumentDecoder.h 2011-06-14 23:09:17 UTC (rev 88868)
+++ trunk/Source/WebKit2/Platform/CoreIPC/ArgumentDecoder.h 2011-06-14 23:13:03 UTC (rev 88869)
@@ -49,12 +49,12 @@
bool decodeFixedLengthData(uint8_t*, size_t, unsigned alignment);
+ // The data in the data reference here will only be valid for the lifetime of the ArgumentDecoder object.
+ bool decodeVariableLengthByteArray(DataReference&);
+
bool decodeBytes(Vector<uint8_t>&);
bool decodeBytes(uint8_t*, size_t);
- // The data in the data reference here will only be valid for the lifetime of the ArgumentDecoder object.
- bool decodeBytes(DataReference&);
-
bool decodeBool(bool&);
bool decodeUInt32(uint32_t&);
bool decodeUInt64(uint64_t&);
Modified: trunk/Source/WebKit2/Platform/CoreIPC/ArgumentEncoder.cpp (88868 => 88869)
--- trunk/Source/WebKit2/Platform/CoreIPC/ArgumentEncoder.cpp 2011-06-14 23:09:17 UTC (rev 88868)
+++ trunk/Source/WebKit2/Platform/CoreIPC/ArgumentEncoder.cpp 2011-06-14 23:13:03 UTC (rev 88869)
@@ -26,6 +26,7 @@
#include "config.h"
#include "ArgumentEncoder.h"
+#include "DataReference.h"
#include <algorithm>
#include <stdio.h>
@@ -87,17 +88,18 @@
void ArgumentEncoder::encodeFixedLengthData(const uint8_t* data, size_t size, unsigned alignment)
{
+ ASSERT(!(reinterpret_cast<uintptr_t>(data) % alignment));
+
uint8_t* buffer = grow(alignment, size);
memcpy(buffer, data, size);
}
-void ArgumentEncoder::encodeVariableLengthData(const uint8_t* data, size_t size, unsigned alignment)
+void ArgumentEncoder::encodeVariableLengthByteArray(const DataReference& dataReference)
{
// Encode the size.
- encodeUInt64(static_cast<uint64_t>(size));
+ encodeUInt64(static_cast<uint64_t>(dataReference.size()));
- // Encode the data.
- encodeFixedLengthData(data, size, alignment);
+ encodeFixedLengthData(dataReference.data(), dataReference.size(), 1);
}
void ArgumentEncoder::encodeBytes(const uint8_t* bytes, size_t size)
Modified: trunk/Source/WebKit2/Platform/CoreIPC/ArgumentEncoder.h (88868 => 88869)
--- trunk/Source/WebKit2/Platform/CoreIPC/ArgumentEncoder.h 2011-06-14 23:09:17 UTC (rev 88868)
+++ trunk/Source/WebKit2/Platform/CoreIPC/ArgumentEncoder.h 2011-06-14 23:13:03 UTC (rev 88869)
@@ -35,6 +35,7 @@
namespace CoreIPC {
class ArgumentEncoder;
+class DataReference;
class ArgumentEncoder {
public:
@@ -42,7 +43,7 @@
~ArgumentEncoder();
void encodeFixedLengthData(const uint8_t*, size_t, unsigned alignment);
- void encodeVariableLengthData(const uint8_t*, size_t, unsigned alignment);
+ void encodeVariableLengthByteArray(const DataReference&);
void encodeBytes(const uint8_t*, size_t);
Modified: trunk/Source/WebKit2/Platform/CoreIPC/DataReference.cpp (88868 => 88869)
--- trunk/Source/WebKit2/Platform/CoreIPC/DataReference.cpp 2011-06-14 23:09:17 UTC (rev 88868)
+++ trunk/Source/WebKit2/Platform/CoreIPC/DataReference.cpp 2011-06-14 23:13:03 UTC (rev 88869)
@@ -38,7 +38,7 @@
bool DataReference::decode(ArgumentDecoder* decoder, DataReference& dataReference)
{
- return decoder->decodeBytes(dataReference);
+ return decoder->decodeVariableLengthByteArray(dataReference);
}
} // namespace CoreIPC
Modified: trunk/Source/WebKit2/Shared/mac/SandboxExtensionMac.mm (88868 => 88869)
--- trunk/Source/WebKit2/Shared/mac/SandboxExtensionMac.mm 2011-06-14 23:09:17 UTC (rev 88868)
+++ trunk/Source/WebKit2/Shared/mac/SandboxExtensionMac.mm 2011-06-14 23:13:03 UTC (rev 88869)
@@ -76,7 +76,7 @@
ASSERT(!result.m_sandboxExtension);
CoreIPC::DataReference dataReference;
- if (!decoder->decodeBytes(dataReference))
+ if (!decoder->decodeVariableLengthByteArray(dataReference))
return false;
if (dataReference.isEmpty())