Title: [183186] trunk/Source/WebCore
Revision
183186
Author
[email protected]
Date
2015-04-23 08:52:20 -0700 (Thu, 23 Apr 2015)

Log Message

Use std::unique_ptr instead of OwnPtr in ThreadGlobalData
https://bugs.webkit.org/show_bug.cgi?id=141950

Patch by Joonghun Park <[email protected]> on 2015-04-23
Reviewed by Darin Adler.

No new tests, no behavior changes.

* dom/EventNames.h:
(WebCore::EventNames::create):
* loader/cache/CachedResourceRequestInitiators.h:
* platform/ThreadGlobalData.cpp:
(WebCore::ThreadGlobalData::ThreadGlobalData):
(WebCore::ThreadGlobalData::destroy):
* platform/ThreadGlobalData.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (183185 => 183186)


--- trunk/Source/WebCore/ChangeLog	2015-04-23 15:49:47 UTC (rev 183185)
+++ trunk/Source/WebCore/ChangeLog	2015-04-23 15:52:20 UTC (rev 183186)
@@ -1,3 +1,20 @@
+2015-04-23  Joonghun Park  <[email protected]>
+
+        Use std::unique_ptr instead of OwnPtr in ThreadGlobalData
+        https://bugs.webkit.org/show_bug.cgi?id=141950
+
+        Reviewed by Darin Adler.
+
+        No new tests, no behavior changes.
+
+        * dom/EventNames.h:
+        (WebCore::EventNames::create):
+        * loader/cache/CachedResourceRequestInitiators.h:
+        * platform/ThreadGlobalData.cpp:
+        (WebCore::ThreadGlobalData::ThreadGlobalData):
+        (WebCore::ThreadGlobalData::destroy):
+        * platform/ThreadGlobalData.h:
+
 2015-04-23  Eric Carlson  <[email protected]>
 
         Some media tests assert after r183096

Modified: trunk/Source/WebCore/dom/EventNames.h (183185 => 183186)


--- trunk/Source/WebCore/dom/EventNames.h	2015-04-23 15:49:47 UTC (rev 183185)
+++ trunk/Source/WebCore/dom/EventNames.h	2015-04-23 15:52:20 UTC (rev 183186)
@@ -267,6 +267,20 @@
     DOM_EVENT_NAMES_FOR_EACH(DOM_EVENT_NAMES_DECLARE)
 #undef DOM_EVENT_NAMES_DECLARE
 
+    // FIXME: The friend declaration to std::make_unique below does not work in windows port.
+    //
+    // template<class T, class... Args>
+    // friend typename std::_Unique_if<T>::_Single_object std::make_unique(Args&&...);
+    //
+    // This create function should be deleted later and is only for keeping EventNames as private.
+    // std::make_unique should be used instead.
+    //
+    template<class... Args>
+    static std::unique_ptr<EventNames> create(Args&&... args)
+    {
+        return std::unique_ptr<EventNames>(new EventNames(std::forward<Args>(args)...));
+    }
+
     // FIXME: Inelegant to call these both event names and event types.
     // We should choose one term and stick to it.
     bool isWheelEventType(const AtomicString& eventType) const;

Modified: trunk/Source/WebCore/loader/cache/CachedResourceRequestInitiators.h (183185 => 183186)


--- trunk/Source/WebCore/loader/cache/CachedResourceRequestInitiators.h	2015-04-23 15:49:47 UTC (rev 183185)
+++ trunk/Source/WebCore/loader/cache/CachedResourceRequestInitiators.h	2015-04-23 15:52:20 UTC (rev 183186)
@@ -32,12 +32,13 @@
 namespace WebCore {
 
 struct CachedResourceRequestInitiators {
+    CachedResourceRequestInitiators();
+
     const AtomicString css;
     const AtomicString icon;
     const AtomicString xmlhttprequest;
     WTF_MAKE_NONCOPYABLE(CachedResourceRequestInitiators); WTF_MAKE_FAST_ALLOCATED;
 private:
-    CachedResourceRequestInitiators();
     friend class ThreadGlobalData;
 };
 

Modified: trunk/Source/WebCore/platform/ThreadGlobalData.cpp (183185 => 183186)


--- trunk/Source/WebCore/platform/ThreadGlobalData.cpp	2015-04-23 15:49:47 UTC (rev 183185)
+++ trunk/Source/WebCore/platform/ThreadGlobalData.cpp	2015-04-23 15:52:20 UTC (rev 183186)
@@ -49,15 +49,15 @@
 #endif
 
 ThreadGlobalData::ThreadGlobalData()
-    : m_cachedResourceRequestInitiators(adoptPtr(new CachedResourceRequestInitiators))
-    , m_eventNames(adoptPtr(new EventNames))
-    , m_threadTimers(adoptPtr(new ThreadTimers))
+    : m_cachedResourceRequestInitiators(std::make_unique<CachedResourceRequestInitiators>())
+    , m_eventNames(EventNames::create())
+    , m_threadTimers(std::make_unique<ThreadTimers>())
 #ifndef NDEBUG
     , m_isMainThread(isMainThread())
 #endif
-    , m_cachedConverterICU(adoptPtr(new ICUConverterWrapper))
+    , m_cachedConverterICU(std::make_unique<ICUConverterWrapper>())
 #if PLATFORM(MAC)
-    , m_cachedConverterTEC(adoptPtr(new TECConverterWrapper))
+    , m_cachedConverterTEC(std::make_unique<TECConverterWrapper>())
 #endif
 {
     // This constructor will have been called on the main thread before being called on
@@ -75,13 +75,13 @@
 void ThreadGlobalData::destroy()
 {
 #if PLATFORM(MAC)
-    m_cachedConverterTEC.clear();
+    m_cachedConverterTEC = nullptr;
 #endif
 
-    m_cachedConverterICU.clear();
+    m_cachedConverterICU = nullptr;
 
-    m_eventNames.clear();
-    m_threadTimers.clear();
+    m_eventNames = nullptr;
+    m_threadTimers = nullptr;
 }
 
 #if USE(WEB_THREAD)

Modified: trunk/Source/WebCore/platform/ThreadGlobalData.h (183185 => 183186)


--- trunk/Source/WebCore/platform/ThreadGlobalData.h	2015-04-23 15:49:47 UTC (rev 183185)
+++ trunk/Source/WebCore/platform/ThreadGlobalData.h	2015-04-23 15:52:20 UTC (rev 183186)
@@ -68,18 +68,18 @@
 #endif
 
     private:
-        OwnPtr<CachedResourceRequestInitiators> m_cachedResourceRequestInitiators;
-        OwnPtr<EventNames> m_eventNames;
-        OwnPtr<ThreadTimers> m_threadTimers;
+        std::unique_ptr<CachedResourceRequestInitiators> m_cachedResourceRequestInitiators;
+        std::unique_ptr<EventNames> m_eventNames;
+        std::unique_ptr<ThreadTimers> m_threadTimers;
 
 #ifndef NDEBUG
         bool m_isMainThread;
 #endif
 
-        OwnPtr<ICUConverterWrapper> m_cachedConverterICU;
+        std::unique_ptr<ICUConverterWrapper> m_cachedConverterICU;
 
 #if PLATFORM(MAC)
-        OwnPtr<TECConverterWrapper> m_cachedConverterTEC;
+        std::unique_ptr<TECConverterWrapper> m_cachedConverterTEC;
 #endif
 
         WEBCORE_EXPORT static ThreadSpecific<ThreadGlobalData>* staticData;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to