Bug 133081 - WebKitTestRunner: Move PassOwnPtr and OwnPtr to std::unique_ptr
Summary: WebKitTestRunner: Move PassOwnPtr and OwnPtr to std::unique_ptr
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: David Farler
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-05-19 12:29 PDT by David Farler
Modified: 2014-05-20 09:24 PDT (History)
1 user (show)

See Also:


Attachments
Patch (9.97 KB, patch)
2014-05-19 12:31 PDT, David Farler
dbates: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David Farler 2014-05-19 12:29:23 PDT
WebKitTestRunner looks like a simple candidate to move off of {Pass,}OwnPtr.
Comment 1 David Farler 2014-05-19 12:31:08 PDT
Created attachment 231710 [details]
Patch
Comment 2 Daniel Bates 2014-05-19 20:42:38 PDT
Comment on attachment 231710 [details]
Patch

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

> Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:108
> +    m_pages.append(std::unique_ptr<InjectedBundlePage>(new InjectedBundlePage(page)));

Notice that Source/WTF/wtf/StdLibExtras.h, <http://trac.webkit.org/browser/trunk/Source/WTF/wtf/StdLibExtras.h?rev=167453#L347>, includes support for the C++14 std::make_unique<>(). We should make use of this convenience template function to write this line as:

m_pages.append(std::make_unique<InjectedBundlePage>(page));

> Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h:137
> +    Vector<std::unique_ptr<InjectedBundlePage> > m_pages;

"> >" => ">>"

That is, no need for the space character between the greater-than characters as C++11 compilers are smart enough to distinguish between a closing template and the right-shift operator.

> Tools/WebKitTestRunner/TestController.cpp:343
> +    m_geolocationProvider = std::unique_ptr<GeolocationProviderMock>(new GeolocationProviderMock(m_context.get()));

We should write this line using std::make_unique.

> Tools/WebKitTestRunner/TestController.cpp:420
> +    m_mainWebView = std::unique_ptr<PlatformWebView>(new PlatformWebView(m_context.get(), m_pageGroup.get(), 0, options));

We should write this line using std::make_unique. Also, we should substitute nullptr for 0.

> Tools/WebKitTestRunner/TestController.cpp:618
> +    m_eventSenderProxy = std::unique_ptr<EventSenderProxy>(new EventSenderProxy(this));

We should write this line using std::make_unique.

> Tools/WebKitTestRunner/TestController.cpp:762
> +    m_currentInvocation = std::unique_ptr<TestInvocation>(new TestInvocation(command.pathOrURL));

Ditto.

> Tools/WebKitTestRunner/WorkQueueManager.h:53
> +    typedef Deque<std::unique_ptr<class WorkQueueItem> > WorkQueue;

"> >" => ">>"

That is, no need for the space character between the greater-than characters. See my remark on line 137 for the reasoning behind this change.
Comment 3 David Farler 2014-05-20 09:23:43 PDT
Committed r169113: <http://trac.webkit.org/changeset/169113>
Comment 4 David Farler 2014-05-20 09:24:08 PDT
Landed patch with all of your suggestions - thanks!