Diff
Modified: trunk/Source/WebKit2/ChangeLog (88852 => 88853)
--- trunk/Source/WebKit2/ChangeLog 2011-06-14 21:24:02 UTC (rev 88852)
+++ trunk/Source/WebKit2/ChangeLog 2011-06-14 21:39:32 UTC (rev 88853)
@@ -1,5 +1,20 @@
2011-06-14 Anders Carlsson <[email protected]>
+ Reviewed by Darin Adler.
+
+ Add functions for encoding/decoding data with a known size and alignment
+ https://bugs.webkit.org/show_bug.cgi?id=62663
+
+ * Platform/CoreIPC/ArgumentDecoder.cpp:
+ (CoreIPC::ArgumentDecoder::decodeFixedLengthData):
+ * Platform/CoreIPC/ArgumentDecoder.h:
+ * Platform/CoreIPC/ArgumentEncoder.cpp:
+ (CoreIPC::ArgumentEncoder::encodeFixedLengthData):
+ (CoreIPC::ArgumentEncoder::encodeVariableLengthData):
+ * Platform/CoreIPC/ArgumentEncoder.h:
+
+2011-06-14 Anders Carlsson <[email protected]>
+
Reviewed by Sam Weinig.
Move string ArgumentCoder template specializations out into a .cpp file
Modified: trunk/Source/WebKit2/Platform/CoreIPC/ArgumentDecoder.cpp (88852 => 88853)
--- trunk/Source/WebKit2/Platform/CoreIPC/ArgumentDecoder.cpp 2011-06-14 21:24:02 UTC (rev 88852)
+++ trunk/Source/WebKit2/Platform/CoreIPC/ArgumentDecoder.cpp 2011-06-14 21:39:32 UTC (rev 88853)
@@ -102,6 +102,17 @@
return alignedBufferIsLargeEnoughToContain(roundUpToAlignment(m_bufferPos, alignment), m_bufferEnd, size);
}
+bool ArgumentDecoder::decodeFixedLengthData(uint8_t* data, size_t size, unsigned alignment)
+{
+ if (!alignBufferPosition(size, alignment))
+ return false;
+
+ memcpy(data, m_bufferPos, size);
+ m_bufferPos += size;
+
+ return true;
+}
+
bool ArgumentDecoder::decodeBytes(Vector<uint8_t>& buffer)
{
uint64_t size;
Modified: trunk/Source/WebKit2/Platform/CoreIPC/ArgumentDecoder.h (88852 => 88853)
--- trunk/Source/WebKit2/Platform/CoreIPC/ArgumentDecoder.h 2011-06-14 21:24:02 UTC (rev 88852)
+++ trunk/Source/WebKit2/Platform/CoreIPC/ArgumentDecoder.h 2011-06-14 21:39:32 UTC (rev 88853)
@@ -47,6 +47,8 @@
bool isInvalid() const { return m_bufferPos > m_bufferEnd; }
void markInvalid() { m_bufferPos = m_bufferEnd + 1; }
+ bool decodeFixedLengthData(uint8_t*, size_t, unsigned alignment);
+
bool decodeBytes(Vector<uint8_t>&);
bool decodeBytes(uint8_t*, size_t);
Modified: trunk/Source/WebKit2/Platform/CoreIPC/ArgumentEncoder.cpp (88852 => 88853)
--- trunk/Source/WebKit2/Platform/CoreIPC/ArgumentEncoder.cpp 2011-06-14 21:24:02 UTC (rev 88852)
+++ trunk/Source/WebKit2/Platform/CoreIPC/ArgumentEncoder.cpp 2011-06-14 21:39:32 UTC (rev 88853)
@@ -85,6 +85,21 @@
return m_buffer + alignedSize;
}
+void ArgumentEncoder::encodeFixedLengthData(const uint8_t* data, size_t size, unsigned alignment)
+{
+ uint8_t* buffer = grow(alignment, size);
+ memcpy(buffer, data, size);
+}
+
+void ArgumentEncoder::encodeVariableLengthData(const uint8_t* data, size_t size, unsigned alignment)
+{
+ // Encode the size.
+ encodeUInt64(static_cast<uint64_t>(size));
+
+ // Encode the data.
+ encodeFixedLengthData(data, size, alignment);
+}
+
void ArgumentEncoder::encodeBytes(const uint8_t* bytes, size_t size)
{
// Encode the size.
Modified: trunk/Source/WebKit2/Platform/CoreIPC/ArgumentEncoder.h (88852 => 88853)
--- trunk/Source/WebKit2/Platform/CoreIPC/ArgumentEncoder.h 2011-06-14 21:24:02 UTC (rev 88852)
+++ trunk/Source/WebKit2/Platform/CoreIPC/ArgumentEncoder.h 2011-06-14 21:39:32 UTC (rev 88853)
@@ -41,6 +41,9 @@
static PassOwnPtr<ArgumentEncoder> create(uint64_t destinationID);
~ArgumentEncoder();
+ void encodeFixedLengthData(const uint8_t*, size_t, unsigned alignment);
+ void encodeVariableLengthData(const uint8_t*, size_t, unsigned alignment);
+
void encodeBytes(const uint8_t*, size_t);
void encodeBool(bool);