WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
218516
Add helper methods to encode and decode IPC arguments as raw data
https://bugs.webkit.org/show_bug.cgi?id=218516
Summary
Add helper methods to encode and decode IPC arguments as raw data
Wenson Hsieh
Reported
2020-11-03 08:09:51 PST
SSIA
Attachments
Patch
(5.88 KB, patch)
2020-11-03 08:16 PST
,
Wenson Hsieh
no flags
Details
Formatted Diff
Diff
For landing
(5.85 KB, patch)
2020-11-03 10:02 PST
,
Wenson Hsieh
no flags
Details
Formatted Diff
Diff
Patch for landing
(5.88 KB, patch)
2020-11-03 11:27 PST
,
Wenson Hsieh
no flags
Details
Formatted Diff
Diff
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
Wenson Hsieh
Comment 1
2020-11-03 08:16:40 PST
Created
attachment 413061
[details]
Patch
Geoffrey Garen
Comment 2
2020-11-03 09:35:15 PST
Comment on
attachment 413061
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=413061&action=review
r=me
> Source/WebKit/Platform/IPC/Encoder.cpp:76 > + : m_messageName(static_cast<MessageName>(0))
If you just want some initialization, and you don't have a specific use for 0, "m_messageName()" is probably better here.
> Source/WebKit/Platform/IPC/Encoder.h:104 > + static RefPtr<WebCore::SharedBuffer> encodeObject(const T& object)
Not sure what distinction "encodeObject" intends to make here, in comparison to Encoder's "encode" functions. Maybe this should just be called "encode"?
Wenson Hsieh
Comment 3
2020-11-03 09:50:44 PST
Thanks for the review! (In reply to Geoffrey Garen from
comment #2
)
> Comment on
attachment 413061
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=413061&action=review
> > r=me > > > Source/WebKit/Platform/IPC/Encoder.cpp:76 > > + : m_messageName(static_cast<MessageName>(0)) > > If you just want some initialization, and you don't have a specific use for > 0, "m_messageName()" is probably better here.
Sounds good — changed to m_messageName().
> > > Source/WebKit/Platform/IPC/Encoder.h:104 > > + static RefPtr<WebCore::SharedBuffer> encodeObject(const T& object) > > Not sure what distinction "encodeObject" intends to make here, in comparison > to Encoder's "encode" functions. Maybe this should just be called "encode"?
Hm...so I originally just wanted to call this `encode` as well, but I ran into compilation errors due to ambiguous calls to `encode` (since it's also defined as an instance method with the same signature :/).
Wenson Hsieh
Comment 4
2020-11-03 10:02:46 PST
Created
attachment 413069
[details]
For landing
Simon Fraser (smfr)
Comment 5
2020-11-03 10:08:16 PST
Comment on
attachment 413069
[details]
For landing View in context:
https://bugs.webkit.org/attachment.cgi?id=413069&action=review
> Source/WebKit/Platform/IPC/Decoder.h:178 > + static Optional<T> decodeObject(const uint8_t* buffer, size_t bufferSize)
I would have called 'buffer' 'sourceBytes' or 'source'.
Geoffrey Garen
Comment 6
2020-11-03 10:11:59 PST
> > > Source/WebKit/Platform/IPC/Encoder.h:104 > > > + static RefPtr<WebCore::SharedBuffer> encodeObject(const T& object) > > > > Not sure what distinction "encodeObject" intends to make here, in comparison > > to Encoder's "encode" functions. Maybe this should just be called "encode"? > > Hm...so I originally just wanted to call this `encode` as well, but I ran > into compilation errors due to ambiguous calls to `encode` (since it's also > defined as an instance method with the same signature :/).
I guess the distinction is that the static methods encode/decode just one object, and into a standalone buffer without attachments, and without any message name or destination. Maybe we should call that "encodeSingleObject". But also, can we just create a separate class? It's not clear why this new behavior is a part of a class that also has attachments, message names, destination ID, alignment adjustment, etc. Can we make an object that's more specific to the task of serializing one object into shared memory, and that doesn't advertise member functions that would be broken if you called them? If there really is a significant chunk of code to share, maybe we can do that by making this new simpler class a base class, or by making stand-alone helper functions.
Wenson Hsieh
Comment 7
2020-11-03 10:38:28 PST
Comment on
attachment 413069
[details]
For landing View in context:
https://bugs.webkit.org/attachment.cgi?id=413069&action=review
>> Source/WebKit/Platform/IPC/Decoder.h:178 >> + static Optional<T> decodeObject(const uint8_t* buffer, size_t bufferSize) > > I would have called 'buffer' 'sourceBytes' or 'source'.
👍🏻 renamed these parameters to `source` and `numberOfBytes`.
Wenson Hsieh
Comment 8
2020-11-03 10:48:44 PST
(In reply to Geoffrey Garen from
comment #6
)
> > > > Source/WebKit/Platform/IPC/Encoder.h:104 > > > > + static RefPtr<WebCore::SharedBuffer> encodeObject(const T& object) > > > > > > Not sure what distinction "encodeObject" intends to make here, in comparison > > > to Encoder's "encode" functions. Maybe this should just be called "encode"? > > > > Hm...so I originally just wanted to call this `encode` as well, but I ran > > into compilation errors due to ambiguous calls to `encode` (since it's also > > defined as an instance method with the same signature :/). > > I guess the distinction is that the static methods encode/decode just one > object, and into a standalone buffer without attachments, and without any > message name or destination. > > Maybe we should call that "encodeSingleObject". > > But also, can we just create a separate class? It's not clear why this new > behavior is a part of a class that also has attachments, message names, > destination ID, alignment adjustment, etc. Can we make an object that's more > specific to the task of serializing one object into shared memory, and that > doesn't advertise member functions that would be broken if you called them? > > If there really is a significant chunk of code to share, maybe we can do > that by making this new simpler class a base class, or by making stand-alone > helper functions.
encodeSingleObject/decodeSingleObject sound good to me — I renamed these new static methods to those. I did consider making separate Encoder/Decoder classes (e.g. RawDataEncoder/RawDataDecoder), but felt that the functionality we require is so close to what's already in Encoder/Decoder, that exposing a couple of helper methods to encode/decode data using these existing classes would make more sense. I think some refactoring to either pull IPC::Attachments and IPC header logic out of Encoder/Decoder and into a derived class, or write new DataEncoder/DataDecoder classes makes sense to me. If possible, I'd like to tackle this separately.
Wenson Hsieh
Comment 9
2020-11-03 11:27:47 PST
Created
attachment 413081
[details]
Patch for landing
Geoffrey Garen
Comment 10
2020-11-03 12:12:47 PST
> encodeSingleObject/decodeSingleObject sound good to me — I renamed these new > static methods to those. I did consider making separate Encoder/Decoder > classes (e.g. RawDataEncoder/RawDataDecoder), but felt that the > functionality we require is so close to what's already in Encoder/Decoder, > that exposing a couple of helper methods to encode/decode data using these > existing classes would make more sense.
👍🏻
> I think some refactoring to either pull IPC::Attachments and IPC header > logic out of Encoder/Decoder and into a derived class, or write new > DataEncoder/DataDecoder classes makes sense to me. If possible, I'd like to > tackle this separately.
👍🏻
EWS
Comment 11
2020-11-03 12:20:43 PST
Committed
r269327
: <
https://trac.webkit.org/changeset/269327
> All reviewed patches have been landed. Closing bug and clearing flags on
attachment 413081
[details]
.
Radar WebKit Bug Importer
Comment 12
2020-11-03 12:21:21 PST
<
rdar://problem/71005847
>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug