Bug 122942 - PingLoader objects unnecessarily pass through OwnPtr
Summary: PingLoader objects unnecessarily pass through OwnPtr
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Zan Dobersek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-10-17 00:00 PDT by Zan Dobersek
Modified: 2013-11-03 23:08 PST (History)
4 users (show)

See Also:


Attachments
Patch (3.85 KB, patch)
2013-10-17 00:18 PDT, Zan Dobersek
no flags Details | Formatted Diff | Diff
Patch (4.08 KB, patch)
2013-11-03 02:30 PST, Zan Dobersek
no flags Details | Formatted Diff | Diff
Patch (4.09 KB, patch)
2013-11-03 03:23 PST, Zan Dobersek
no flags Details | Formatted Diff | Diff
Patch (4.09 KB, patch)
2013-11-03 03:55 PST, Zan Dobersek
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Zan Dobersek 2013-10-17 00:00:19 PDT
PingLoader objects unnecessarily pass through OwnPtr
Comment 1 Zan Dobersek 2013-10-17 00:18:10 PDT
Created attachment 214425 [details]
Patch
Comment 2 Darin Adler 2013-11-02 14:16:10 PDT
Comment on attachment 214425 [details]
Patch

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

OK as is. Room for improvement.

> Source/WebCore/loader/PingLoader.cpp:71
> +    PingLoader* pingLoader = new PingLoader(frame, request);
> +    UNUSED_PARAM(pingLoader);

I don’t think we need the variable at all. It’s also strange to use UNUSED_PARAM for this. The word is “delete”, not “kill”.

Also, I think we should have a helper member function to hide the use of "new". I don’t like having these calls to new with the comments in three different places in the file. It should just be one small inline function.

> Source/WebCore/loader/PingLoader.cpp:102
> +    // No need to free the PingLoader object or manage it via a smart pointer - it will kill itself as soon as it receives a response.
> +    PingLoader* pingLoader = new PingLoader(frame, request);
> +    UNUSED_PARAM(pingLoader);

Ditto.

> Source/WebCore/loader/PingLoader.cpp:122
> +    // No need to free the PingLoader object or manage it via a smart pointer - it will kill itself as soon as it receives a response.
> +    PingLoader* pingLoader = new PingLoader(frame, request);
> +    UNUSED_PARAM(pingLoader);

Ditto.
Comment 3 Zan Dobersek 2013-11-03 02:30:52 PST
Created attachment 215859 [details]
Patch
Comment 4 Zan Dobersek 2013-11-03 03:23:03 PST
Created attachment 215863 [details]
Patch
Comment 5 Zan Dobersek 2013-11-03 03:55:13 PST
Created attachment 215864 [details]
Patch
Comment 6 Darin Adler 2013-11-03 16:57:59 PST
Comment on attachment 215864 [details]
Patch

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

> Source/WebCore/loader/PingLoader.h:68
> +    static inline void createPingLoader(Frame* frame, ResourceRequest& request)
> +    {
> +        // No need to free the PingLoader object or manage it via a smart pointer - it will kill itself as soon as it receives a response.
> +        new PingLoader(frame, request);
> +    }

Since this is in the class definition, the inline keyword is unneeded.

Since this is only used in the .cpp file, it need not be in the class definition. I can be in the .cpp file, and just be declared in the class definition.
Comment 7 Zan Dobersek 2013-11-03 23:08:15 PST
Committed r158558: <http://trac.webkit.org/changeset/158558>