WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch for landing
bug-218516-20201103112746.patch (text/plain), 5.88 KB, created by
Wenson Hsieh
on 2020-11-03 11:27:47 PST
(
hide
)
Description:
Patch for landing
Filename:
MIME Type:
Creator:
Wenson Hsieh
Created:
2020-11-03 11:27:47 PST
Size:
5.88 KB
patch
obsolete
>Subversion Revision: 269315 >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 7390e294c7d11b7770f36f9c8a55755055d89f23..e8a6dd6fbe6538a1100a3996018d900cbb8154cd 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,31 @@ >+2020-11-03 Wenson Hsieh <wenson_hsieh@apple.com> >+ >+ Add helper methods to encode and decode IPC arguments as raw data >+ https://bugs.webkit.org/show_bug.cgi?id=218516 >+ >+ Reviewed by Geoff Garen. >+ >+ Add new helper methods to `IPC::Encoder` and `IPC::Decoder` that can be used to convert anything that can be >+ sent as an IPC argument into raw bytes (i.e. using `WebCore::SharedBuffer`), as long as there are no IPC >+ attachments in the encoded data. >+ >+ For more details, see <webkit.org/b/218406>. >+ >+ * Platform/IPC/Decoder.cpp: >+ (IPC::Decoder::Decoder): >+ >+ Add private versions of the Encoder and Decoder constructors that avoid IPC header data. These constructors are >+ called only from within `encodeSingleObject` and `decodeSingleObject`, respectively. >+ >+ (IPC::m_bufferDeallocator): >+ * Platform/IPC/Decoder.h: >+ (IPC::Decoder::decodeSingleObject): >+ * Platform/IPC/Encoder.cpp: >+ (IPC::Encoder::Encoder): >+ (IPC::Encoder::releaseAttachments): >+ (IPC::Encoder::hasAttachments const): >+ * Platform/IPC/Encoder.h: >+ > 2020-11-03 Wenson Hsieh <wenson_hsieh@apple.com> > > Replace DisplayList::itemCount with DisplayList::isEmpty >diff --git a/Source/WebKit/Platform/IPC/Decoder.cpp b/Source/WebKit/Platform/IPC/Decoder.cpp >index 5ca2127a346cd2a469ca297f4ab13902f6a06f8a..51b9ffd930340bdff2fb71d0e46cacf409346531 100644 >--- a/Source/WebKit/Platform/IPC/Decoder.cpp >+++ b/Source/WebKit/Platform/IPC/Decoder.cpp >@@ -74,6 +74,16 @@ Decoder::Decoder(const uint8_t* buffer, size_t bufferSize, void (*bufferDealloca > return; > } > >+Decoder::Decoder(const uint8_t* buffer, size_t bufferSize, ConstructWithoutHeaderTag) >+ : m_buffer { buffer } >+ , m_bufferPos { m_buffer } >+ , m_bufferEnd { m_buffer + bufferSize } >+ , m_bufferDeallocator([] (const uint8_t*, size_t) { }) >+{ >+ if (reinterpret_cast<uintptr_t>(m_buffer) % alignof(uint64_t)) >+ markInvalid(); >+} >+ > Decoder::~Decoder() > { > ASSERT(m_buffer); >diff --git a/Source/WebKit/Platform/IPC/Decoder.h b/Source/WebKit/Platform/IPC/Decoder.h >index 3dd24696ef6ca7dc97d013a0fe875d7bd47de30a..b0cabeebb86982db5fa3ca6079a8e233dfcd814e 100644 >--- a/Source/WebKit/Platform/IPC/Decoder.h >+++ b/Source/WebKit/Platform/IPC/Decoder.h >@@ -30,6 +30,7 @@ > #include "MessageNames.h" > #include "StringReference.h" > #include <WebCore/ContextMenuItem.h> >+#include <WebCore/SharedBuffer.h> > #include <wtf/OptionSet.h> > #include <wtf/Vector.h> > >@@ -173,7 +174,22 @@ public: > > static const bool isIPCDecoder = true; > >+ template <typename T> >+ static Optional<T> decodeSingleObject(const uint8_t* source, size_t numberOfBytes) >+ { >+ Optional<T> result; >+ Decoder decoder(source, numberOfBytes, ConstructWithoutHeader); >+ if (!decoder.isValid()) >+ return WTF::nullopt; >+ >+ decoder >> result; >+ return result; >+ } >+ > private: >+ enum ConstructWithoutHeaderTag { ConstructWithoutHeader }; >+ Decoder(const uint8_t* buffer, size_t bufferSize, ConstructWithoutHeaderTag); >+ > bool alignBufferPosition(size_t alignment, size_t); > bool bufferIsLargeEnoughToContain(size_t alignment, size_t) const; > >diff --git a/Source/WebKit/Platform/IPC/Encoder.cpp b/Source/WebKit/Platform/IPC/Encoder.cpp >index 87fe95552ac6052dbcd76e490d4ab6a662ec8ad4..fd4090774b2bc2a7629b9c02dc554c4cdc98f5cb 100644 >--- a/Source/WebKit/Platform/IPC/Encoder.cpp >+++ b/Source/WebKit/Platform/IPC/Encoder.cpp >@@ -72,6 +72,16 @@ Encoder::Encoder(MessageName messageName, uint64_t destinationID) > encodeHeader(); > } > >+Encoder::Encoder(ConstructWithoutHeaderTag) >+ : m_messageName() >+ , m_destinationID(0) >+ , m_buffer(m_inlineBuffer) >+ , m_bufferPointer(m_inlineBuffer) >+ , m_bufferSize(0) >+ , m_bufferCapacity(sizeof(m_inlineBuffer)) >+{ >+} >+ > Encoder::~Encoder() > { > if (m_buffer != m_inlineBuffer) >@@ -219,7 +229,12 @@ void Encoder::addAttachment(Attachment&& attachment) > > Vector<Attachment> Encoder::releaseAttachments() > { >- return WTFMove(m_attachments); >+ return std::exchange(m_attachments, { }); >+} >+ >+bool Encoder::hasAttachments() const >+{ >+ return !m_attachments.isEmpty(); > } > > } // namespace IPC >diff --git a/Source/WebKit/Platform/IPC/Encoder.h b/Source/WebKit/Platform/IPC/Encoder.h >index 3678d4fae29152d990f4d3a4f0b7e0af6cf7472b..0ecf541f77858536f1fcfa836b76f2482e4c9a11 100644 >--- a/Source/WebKit/Platform/IPC/Encoder.h >+++ b/Source/WebKit/Platform/IPC/Encoder.h >@@ -30,6 +30,7 @@ > #include "MessageNames.h" > #include "StringReference.h" > #include <WebCore/ContextMenuItem.h> >+#include <WebCore/SharedBuffer.h> > #include <wtf/OptionSet.h> > #include <wtf/Vector.h> > >@@ -99,7 +100,24 @@ public: > > static const bool isIPCEncoder = true; > >+ template<typename T> >+ static RefPtr<WebCore::SharedBuffer> encodeSingleObject(const T& object) >+ { >+ Encoder encoder(ConstructWithoutHeader); >+ encoder << object; >+ >+ if (encoder.hasAttachments()) { >+ ASSERT_NOT_REACHED(); >+ return nullptr; >+ } >+ >+ return WebCore::SharedBuffer::create(encoder.buffer(), encoder.bufferSize()); >+ } >+ > private: >+ enum ConstructWithoutHeaderTag { ConstructWithoutHeader }; >+ Encoder(ConstructWithoutHeaderTag); >+ > uint8_t* grow(size_t alignment, size_t); > > template<typename E, std::enable_if_t<std::is_enum<E>::value>* = nullptr> >@@ -109,6 +127,8 @@ private: > encode(WTF::enumToUnderlyingType<E>(enumValue)); > } > >+ bool hasAttachments() const; >+ > void encodeHeader(); > const OptionSet<MessageFlags>& messageFlags() const; > OptionSet<MessageFlags>& messageFlags();
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 218516
:
413061
|
413069
| 413081