Bug 222992 - Use UniqueRef<> instead of std::unique_ptr<> when passing IPC::Encoder to sendMessage()
Summary: Use UniqueRef<> instead of std::unique_ptr<> when passing IPC::Encoder to sen...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit2 (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-03-09 14:25 PST by Chris Dumez
Modified: 2021-04-09 10:34 PDT (History)
12 users (show)

See Also:


Attachments
Patch (42.61 KB, patch)
2021-03-09 14:40 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (167.16 KB, patch)
2021-03-09 15:52 PST, Chris Dumez
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (167.20 KB, patch)
2021-03-09 16:02 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (167.43 KB, patch)
2021-03-09 17:06 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (167.43 KB, patch)
2021-03-09 17:08 PST, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2021-03-09 14:25:40 PST
Use UniqueRef<> instead of std::unique_ptr<> when passing IPC::Encoder to sendMessage(), to make it clear it cannot be null.
Comment 1 Chris Dumez 2021-03-09 14:40:07 PST
Created attachment 422761 [details]
Patch
Comment 2 Chris Dumez 2021-03-09 15:52:07 PST
Created attachment 422771 [details]
Patch
Comment 3 Chris Dumez 2021-03-09 16:02:09 PST
Created attachment 422774 [details]
Patch
Comment 4 Alex Christensen 2021-03-09 16:55:55 PST
Comment on attachment 422774 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=422774&action=review

> Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp:-637
> -        replyEncoder.reset();

There are two of these.  Why don't you remove both of them?

> Source/WebKit/NetworkProcess/WebStorage/StorageManagerSet.h:75
> +    bool didReceiveSyncMessage(IPC::Connection&, IPC::Decoder&, UniqueRef<IPC::Encoder>& replyEncoder);

We should probably use UniqueRef<>&& and move the ownership.
It would be worth putting in the change log that we need to return a boolean because we are not checking the null status of the unique_ptr any more.
Comment 5 Chris Dumez 2021-03-09 17:01:13 PST
Comment on attachment 422774 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=422774&action=review

>> Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp:-637
>> -        replyEncoder.reset();
> 
> There are two of these.  Why don't you remove both of them?

Those of these? I don't see any other replyEncoder.reset() in this function. If there was, I don't think it would build because UniqueRef::reset() is not a think AFAIK.
I must be misunderstanding your comment?

>> Source/WebKit/NetworkProcess/WebStorage/StorageManagerSet.h:75
>> +    bool didReceiveSyncMessage(IPC::Connection&, IPC::Decoder&, UniqueRef<IPC::Encoder>& replyEncoder);
> 
> We should probably use UniqueRef<>&& and move the ownership.
> It would be worth putting in the change log that we need to return a boolean because we are not checking the null status of the unique_ptr any more.

I will clarify the ChangeLog.

The result I used a reference instead of a rvalue-reference is that the call site would look really scary with a r-value reference:
if (didReceiveSyncMessage(connection, decoder, WTFMove(encoder))
    return;
// Use encoder here.

I get that it would work since WTFMove() is just a cast. But it looks scary so I am not sure I want to make that change. WDYT?
Comment 6 Alex Christensen 2021-03-09 17:03:44 PST
Comment on attachment 422774 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=422774&action=review

>>> Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp:-637
>>> -        replyEncoder.reset();
>> 
>> There are two of these.  Why don't you remove both of them?
> 
> Those of these? I don't see any other replyEncoder.reset() in this function. If there was, I don't think it would build because UniqueRef::reset() is not a think AFAIK.
> I must be misunderstanding your comment?

The Messages::RemoteGraphicsContextGL::messageReceiverName code for decoders does something like this too.  Never mind.
Comment 7 Chris Dumez 2021-03-09 17:06:17 PST
Created attachment 422780 [details]
Patch
Comment 8 Chris Dumez 2021-03-09 17:08:13 PST
Created attachment 422781 [details]
Patch
Comment 9 EWS 2021-03-09 18:21:49 PST
Committed r274189: <https://commits.webkit.org/r274189>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 422781 [details].
Comment 10 Radar WebKit Bug Importer 2021-03-09 18:22:19 PST
<rdar://problem/75244991>