Use std::unique_ptr for CachedResource
authorgyuyoung.kim@samsung.com <gyuyoung.kim@samsung.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 16 Oct 2014 03:57:28 +0000 (03:57 +0000)
committergyuyoung.kim@samsung.com <gyuyoung.kim@samsung.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 16 Oct 2014 03:57:28 +0000 (03:57 +0000)
https://bugs.webkit.org/show_bug.cgi?id=137736

Reviewed by Darin Adler.

No new tests, no behavior change.

* loader/cache/CachedResource.cpp: Use std::unique_ptr instead of PassOwnPtr|OwnPtr.
(WebCore::CachedResource::removeClient):
* loader/cache/CachedResource.h: Set ctor from private to public.
(WebCore::CachedResource::CachedResourceCallback::schedule):

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

Source/WebCore/ChangeLog
Source/WebCore/loader/cache/CachedResource.cpp
Source/WebCore/loader/cache/CachedResource.h

index 4dd4c45..25ee5c0 100644 (file)
@@ -1,5 +1,19 @@
 2014-10-15  Gyuyoung Kim  <gyuyoung.kim@samsung.com>
 
+        Use std::unique_ptr for CachedResource
+        https://bugs.webkit.org/show_bug.cgi?id=137736
+
+        Reviewed by Darin Adler.
+
+        No new tests, no behavior change.
+
+        * loader/cache/CachedResource.cpp: Use std::unique_ptr instead of PassOwnPtr|OwnPtr.
+        (WebCore::CachedResource::removeClient):
+        * loader/cache/CachedResource.h: Set ctor from private to public.
+        (WebCore::CachedResource::CachedResourceCallback::schedule):
+
+2014-10-15  Gyuyoung Kim  <gyuyoung.kim@samsung.com>
+
         Move TextCodec classes to std::unique_ptr
         https://bugs.webkit.org/show_bug.cgi?id=137738
 
index 00c30f0..7f4fa5a 100644 (file)
@@ -514,11 +514,11 @@ bool CachedResource::addClientToSet(CachedResourceClient* client)
 
 void CachedResource::removeClient(CachedResourceClient* client)
 {
-    OwnPtr<CachedResourceCallback> callback = m_clientsAwaitingCallback.take(client);
+    auto callback = m_clientsAwaitingCallback.take(client);
     if (callback) {
         ASSERT(!m_clients.contains(client));
         callback->cancel();
-        callback.clear();
+        callback = nullptr;
     } else {
         ASSERT(m_clients.contains(client));
         m_clients.remove(client);
index be32ebc..f40dd89 100644 (file)
@@ -35,7 +35,6 @@
 #include <time.h>
 #include <wtf/HashCountedSet.h>
 #include <wtf/HashSet.h>
-#include <wtf/OwnPtr.h>
 #include <wtf/TypeCasts.h>
 #include <wtf/Vector.h>
 #include <wtf/text/WTFString.h>
@@ -269,17 +268,18 @@ protected:
 
     class CachedResourceCallback {
     public:
-        static PassOwnPtr<CachedResourceCallback> schedule(CachedResource* resource, CachedResourceClient* client) { return adoptPtr(new CachedResourceCallback(resource, client)); }
+        CachedResourceCallback(CachedResource*, CachedResourceClient*);
+
+        static std::unique_ptr<CachedResourceCallback> schedule(CachedResource* resource, CachedResourceClient* client) { return std::make_unique<CachedResourceCallback>(resource, client); }
         void cancel();
     private:
-        CachedResourceCallback(CachedResource*, CachedResourceClient*);
         void timerFired(Timer<CachedResourceCallback>&);
 
         CachedResource* m_resource;
         CachedResourceClient* m_client;
         Timer<CachedResourceCallback> m_callbackTimer;
     };
-    HashMap<CachedResourceClient*, OwnPtr<CachedResourceCallback>> m_clientsAwaitingCallback;
+    HashMap<CachedResourceClient*, std::unique_ptr<CachedResourceCallback>> m_clientsAwaitingCallback;
 
     ResourceRequest m_resourceRequest;
     SessionID m_sessionID;