Use std::make_unique<> when creating an unique_ptr object.
authorgyuyoung.kim@webkit.org <gyuyoung.kim@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 31 Jan 2016 11:41:44 +0000 (11:41 +0000)
committergyuyoung.kim@webkit.org <gyuyoung.kim@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 31 Jan 2016 11:41:44 +0000 (11:41 +0000)
https://bugs.webkit.org/show_bug.cgi?id=153705

Reviewed by Darin Adler.

Source/WebCore:

Some factory functions have used std::unique_ptr<> for creating an unique_ptr object.
It is wrong. We have to use std::make_unique<>.

* Modules/mediasession/WebMediaSessionManager.cpp:
(WebCore::WebMediaSessionManager::mockPicker):
* inspector/InspectorTimelineAgent.cpp:
(WebCore::InspectorTimelineAgent::internalStart):
* platform/cf/RunLoopObserver.cpp:
(WebCore::RunLoopObserver::create): Deleted.
* platform/cf/RunLoopObserver.h:
(WebCore::RunLoopObserver::RunLoopObserver):
* platform/graphics/avfoundation/WebMediaSessionManagerMac.cpp:
(WebCore::WebMediaSessionManagerMac::platformPicker):
* platform/graphics/avfoundation/objc/MediaPlaybackTargetPickerMac.h:
* platform/graphics/avfoundation/objc/MediaPlaybackTargetPickerMac.mm:
(WebCore::MediaPlaybackTargetPickerMac::create): Deleted.
* platform/graphics/ca/cocoa/LayerFlushSchedulerMac.cpp:
(WebCore::LayerFlushScheduler::LayerFlushScheduler):
* platform/mock/MediaPlaybackTargetPickerMock.cpp:
(WebCore::MediaPlaybackTargetPickerMock::create): Deleted.
* platform/mock/MediaPlaybackTargetPickerMock.h:
* rendering/FloatingObjects.cpp:
(WebCore::FloatingObject::copyToNewContainer):

Source/WebKit2:

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::WebPageProxy): Use std::make_unique<> instead of RunLoopObserver::create().

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@195925 268f45cc-cd09-0410-ab3c-d52691b4dbfc

14 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Modules/mediasession/WebMediaSessionManager.cpp
Source/WebCore/inspector/InspectorTimelineAgent.cpp
Source/WebCore/platform/cf/RunLoopObserver.cpp
Source/WebCore/platform/cf/RunLoopObserver.h
Source/WebCore/platform/graphics/avfoundation/WebMediaSessionManagerMac.cpp
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlaybackTargetPickerMac.h
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlaybackTargetPickerMac.mm
Source/WebCore/platform/graphics/ca/cocoa/LayerFlushSchedulerMac.cpp
Source/WebCore/platform/mock/MediaPlaybackTargetPickerMock.cpp
Source/WebCore/platform/mock/MediaPlaybackTargetPickerMock.h
Source/WebCore/rendering/FloatingObjects.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/WebPageProxy.cpp

index 961e06a..c276c53 100644 (file)
@@ -1,3 +1,34 @@
+2016-01-31  Gyuyoung Kim  <gyuyoung.kim@webkit.org>
+
+        Use std::make_unique<> when creating an unique_ptr object.
+        https://bugs.webkit.org/show_bug.cgi?id=153705
+
+        Reviewed by Darin Adler.
+
+        Some factory functions have used std::unique_ptr<> for creating an unique_ptr object.
+        It is wrong. We have to use std::make_unique<>.
+
+        * Modules/mediasession/WebMediaSessionManager.cpp:
+        (WebCore::WebMediaSessionManager::mockPicker):
+        * inspector/InspectorTimelineAgent.cpp:
+        (WebCore::InspectorTimelineAgent::internalStart):
+        * platform/cf/RunLoopObserver.cpp:
+        (WebCore::RunLoopObserver::create): Deleted.
+        * platform/cf/RunLoopObserver.h:
+        (WebCore::RunLoopObserver::RunLoopObserver):
+        * platform/graphics/avfoundation/WebMediaSessionManagerMac.cpp:
+        (WebCore::WebMediaSessionManagerMac::platformPicker):
+        * platform/graphics/avfoundation/objc/MediaPlaybackTargetPickerMac.h:
+        * platform/graphics/avfoundation/objc/MediaPlaybackTargetPickerMac.mm:
+        (WebCore::MediaPlaybackTargetPickerMac::create): Deleted.
+        * platform/graphics/ca/cocoa/LayerFlushSchedulerMac.cpp:
+        (WebCore::LayerFlushScheduler::LayerFlushScheduler):
+        * platform/mock/MediaPlaybackTargetPickerMock.cpp:
+        (WebCore::MediaPlaybackTargetPickerMock::create): Deleted.
+        * platform/mock/MediaPlaybackTargetPickerMock.h:
+        * rendering/FloatingObjects.cpp:
+        (WebCore::FloatingObject::copyToNewContainer):
+
 2016-01-30  Michael Catanzaro  <mcatanzaro@igalia.com>
 
         Unreviewed, fix GTK debug build after r195899
index ab30042..7a3369f 100644 (file)
@@ -113,7 +113,7 @@ void WebMediaSessionManager::setMockMediaPlaybackTargetPickerState(const String&
 MediaPlaybackTargetPickerMock& WebMediaSessionManager::mockPicker()
 {
     if (!m_pickerOverride)
-        m_pickerOverride = MediaPlaybackTargetPickerMock::create(*this);
+        m_pickerOverride = std::make_unique<MediaPlaybackTargetPickerMock>(*this);
 
     return *m_pickerOverride.get();
 }
index 5728534..9283a67 100644 (file)
@@ -134,7 +134,7 @@ void InspectorTimelineAgent::internalStart(const int* maxCallStackDepth)
     // FIXME: Abstract away platform-specific code once https://bugs.webkit.org/show_bug.cgi?id=142748 is fixed.
 
 #if PLATFORM(COCOA)
-    m_frameStartObserver = RunLoopObserver::create(0, [this]() {
+    m_frameStartObserver = std::make_unique<RunLoopObserver>(0, [this]() {
         if (!m_enabled || m_environment.scriptDebugServer().isPaused())
             return;
 
@@ -143,7 +143,7 @@ void InspectorTimelineAgent::internalStart(const int* maxCallStackDepth)
         m_runLoopNestingLevel++;
     });
 
-    m_frameStopObserver = RunLoopObserver::create(frameStopRunLoopOrder, [this]() {
+    m_frameStopObserver = std::make_unique<RunLoopObserver>(frameStopRunLoopOrder, [this]() {
         if (!m_enabled || m_environment.scriptDebugServer().isPaused())
             return;
 
index 7042f8f..99bbc73 100644 (file)
 
 namespace WebCore {
 
-std::unique_ptr<RunLoopObserver> RunLoopObserver::create(CFIndex order, RunLoopObserver::RunLoopObserverCallback callback)
-{
-    return std::unique_ptr<RunLoopObserver>(new RunLoopObserver(order, callback));
-}
-
 RunLoopObserver::~RunLoopObserver()
 {
     invalidate();
index 2fa8f8e..e202c93 100644 (file)
@@ -38,7 +38,10 @@ class RunLoopObserver {
 public:
     typedef std::function<void ()> RunLoopObserverCallback;
 
-    WEBCORE_EXPORT static std::unique_ptr<RunLoopObserver> create(CFIndex order, RunLoopObserverCallback callback);
+    RunLoopObserver(CFIndex order, RunLoopObserverCallback callback)
+        : m_order(order)
+        , m_callback(callback)
+    { }
 
     WEBCORE_EXPORT ~RunLoopObserver();
 
@@ -52,11 +55,6 @@ public:
     };
 
 protected:
-    RunLoopObserver(CFIndex order, RunLoopObserverCallback callback)
-        : m_order(order)
-        , m_callback(callback)
-    { }
-
     void runLoopObserverFired();
 
 private:
index a449881..ffb3df3 100644 (file)
@@ -51,7 +51,7 @@ WebMediaSessionManagerMac::~WebMediaSessionManagerMac()
 WebCore::MediaPlaybackTargetPicker& WebMediaSessionManagerMac::platformPicker()
 {
     if (!m_targetPicker)
-        m_targetPicker = MediaPlaybackTargetPickerMac::create(*this);
+        m_targetPicker = std::make_unique<MediaPlaybackTargetPickerMac>(*this);
 
     return *m_targetPicker.get();
 }
index e07faac..9a13869 100644 (file)
@@ -39,9 +39,9 @@ namespace WebCore {
 class MediaPlaybackTargetPickerMac final : public MediaPlaybackTargetPicker {
     WTF_MAKE_NONCOPYABLE(MediaPlaybackTargetPickerMac);
 public:
-    virtual ~MediaPlaybackTargetPickerMac();
+    explicit MediaPlaybackTargetPickerMac(MediaPlaybackTargetPicker::Client&);
 
-    WEBCORE_EXPORT static std::unique_ptr<MediaPlaybackTargetPickerMac> create(MediaPlaybackTargetPicker::Client&);
+    virtual ~MediaPlaybackTargetPickerMac();
 
     void showPlaybackTargetPicker(const FloatRect&, bool checkActiveRoute) override;
     void startingMonitoringPlaybackTargets() override;
@@ -49,8 +49,6 @@ public:
     void invalidatePlaybackTargets() override;
 
 private:
-    explicit MediaPlaybackTargetPickerMac(MediaPlaybackTargetPicker::Client&);
-
     bool externalOutputDeviceAvailable() override;
     Ref<MediaPlaybackTarget> playbackTarget() override;
 
index c7c88c0..10aaa50 100644 (file)
@@ -67,11 +67,6 @@ static NSString *externalOutputDevicePickedKeyName = @"externalOutputDevicePicke
 
 namespace WebCore {
 
-std::unique_ptr<MediaPlaybackTargetPickerMac> MediaPlaybackTargetPickerMac::create(MediaPlaybackTargetPicker::Client& client)
-{
-    return std::unique_ptr<MediaPlaybackTargetPickerMac>(new MediaPlaybackTargetPickerMac(client));
-}
-
 MediaPlaybackTargetPickerMac::MediaPlaybackTargetPickerMac(MediaPlaybackTargetPicker::Client& client)
     : MediaPlaybackTargetPicker(client)
     , m_outputDeviceMenuControllerDelegate(adoptNS([[WebAVOutputDeviceMenuControllerHelper alloc] initWithCallback:this]))
index 5ef8cd2..444b4c6 100644 (file)
@@ -58,7 +58,7 @@ LayerFlushScheduler::LayerFlushScheduler(LayerFlushSchedulerClient* client)
 {
     ASSERT_ARG(client, client);
 
-    m_runLoopObserver = RunLoopObserver::create(layerFlushRunLoopOrder, [this]() {
+    m_runLoopObserver = std::make_unique<RunLoopObserver>(layerFlushRunLoopOrder, [this]() {
         if (this->isSuspended())
             return;
         this->layerFlushCallback();
index 7128148..774259d 100644 (file)
@@ -39,11 +39,6 @@ namespace WebCore {
 
 static const double timerInterval = 1.0 / 10.0;
 
-std::unique_ptr<MediaPlaybackTargetPickerMock> MediaPlaybackTargetPickerMock::create(MediaPlaybackTargetPicker::Client& client)
-{
-    return std::unique_ptr<MediaPlaybackTargetPickerMock>(new MediaPlaybackTargetPickerMock(client));
-}
-
 MediaPlaybackTargetPickerMock::MediaPlaybackTargetPickerMock(MediaPlaybackTargetPicker::Client& client)
     : MediaPlaybackTargetPicker(client)
     , m_timer(RunLoop::main(), this, &MediaPlaybackTargetPickerMock::timerFired)
index 714834d..35cc954 100644 (file)
@@ -37,9 +37,9 @@ namespace WebCore {
 class MediaPlaybackTargetPickerMock final : public MediaPlaybackTargetPicker {
     WTF_MAKE_NONCOPYABLE(MediaPlaybackTargetPickerMock);
 public:
-    virtual ~MediaPlaybackTargetPickerMock();
+    explicit MediaPlaybackTargetPickerMock(MediaPlaybackTargetPicker::Client&);
 
-    WEBCORE_EXPORT static std::unique_ptr<MediaPlaybackTargetPickerMock> create(MediaPlaybackTargetPicker::Client&);
+    virtual ~MediaPlaybackTargetPickerMock();
 
     void showPlaybackTargetPicker(const FloatRect&, bool checkActiveRoute) override;
     void startingMonitoringPlaybackTargets() override;
@@ -49,8 +49,6 @@ public:
     void setState(const String&, MediaPlaybackTargetContext::State);
 
 private:
-    explicit MediaPlaybackTargetPickerMock(MediaPlaybackTargetPicker::Client&);
-
     bool externalOutputDeviceAvailable() override;
     Ref<MediaPlaybackTarget> playbackTarget() override;
 
index 304f009..e31f7df 100644 (file)
@@ -85,8 +85,7 @@ std::unique_ptr<FloatingObject> FloatingObject::create(RenderBox& renderer)
 
 std::unique_ptr<FloatingObject> FloatingObject::copyToNewContainer(LayoutSize offset, bool shouldPaint, bool isDescendant) const
 {
-    // FIXME: Use make_unique here, once we can get it to compile on all platforms we support.
-    return std::unique_ptr<FloatingObject>(new FloatingObject(renderer(), type(), LayoutRect(frameRect().location() - offset, frameRect().size()), shouldPaint, isDescendant));
+    return std::make_unique<FloatingObject>(renderer(), type(), LayoutRect(frameRect().location() - offset, frameRect().size()), shouldPaint, isDescendant);
 }
 
 std::unique_ptr<FloatingObject> FloatingObject::unsafeClone() const
index a711a1c..cb37d3f 100644 (file)
@@ -1,3 +1,13 @@
+2016-01-31  Gyuyoung Kim  <gyuyoung.kim@webkit.org>
+
+        Use std::make_unique<> when creating an unique_ptr object.
+        https://bugs.webkit.org/show_bug.cgi?id=153705
+
+        Reviewed by Darin Adler.
+
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::WebPageProxy): Use std::make_unique<> instead of RunLoopObserver::create().
+
 2016-01-30  Dan Bernstein  <mitz@apple.com>
 
         [Cocoa] Get rid of many WK_ macros for nullability
index 728b6ee..b5fb9e8 100644 (file)
@@ -485,7 +485,7 @@ WebPageProxy::WebPageProxy(PageClient& pageClient, WebProcessProxy& process, uin
 
 #if PLATFORM(COCOA)
     const CFIndex viewStateChangeRunLoopOrder = (CFIndex)RunLoopObserver::WellKnownRunLoopOrders::CoreAnimationCommit - 1;
-    m_viewStateChangeDispatcher = RunLoopObserver::create(viewStateChangeRunLoopOrder, [this] {
+    m_viewStateChangeDispatcher = std::make_unique<RunLoopObserver>(viewStateChangeRunLoopOrder, [this] {
         this->dispatchViewStateChange();
     });
 #endif