Title: [131463] trunk/Source/WebKit2
Revision
131463
Author
[email protected]
Date
2012-10-16 09:21:49 -0700 (Tue, 16 Oct 2012)

Log Message

[EFL][WK2] Have intent classes subclass RefCounted
https://bugs.webkit.org/show_bug.cgi?id=99467

Patch by Christophe Dumez <[email protected]> on 2012-10-16
Reviewed by Kenneth Rohde Christiansen.

Make Ewk_Intent and Ewk_Intent_Service subclass
RefCounted so that we can use smart pointers
internally.

* UIProcess/API/efl/ewk_intent.cpp:
(ewk_intent_ref):
(ewk_intent_unref):
* UIProcess/API/efl/ewk_intent_private.h:
(_Ewk_Intent):
(_Ewk_Intent::_Ewk_Intent):
* UIProcess/API/efl/ewk_intent_service.cpp:
(ewk_intent_service_ref):
(ewk_intent_service_unref):
* UIProcess/API/efl/ewk_intent_service_private.h:
(_Ewk_Intent_Service):
(_Ewk_Intent_Service::_Ewk_Intent_Service):
* UIProcess/API/efl/ewk_view_loader_client.cpp:
(didReceiveIntentForFrame):
(registerIntentServiceForFrame):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (131462 => 131463)


--- trunk/Source/WebKit2/ChangeLog	2012-10-16 16:21:24 UTC (rev 131462)
+++ trunk/Source/WebKit2/ChangeLog	2012-10-16 16:21:49 UTC (rev 131463)
@@ -1,3 +1,30 @@
+2012-10-16  Christophe Dumez  <[email protected]>
+
+        [EFL][WK2] Have intent classes subclass RefCounted
+        https://bugs.webkit.org/show_bug.cgi?id=99467
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Make Ewk_Intent and Ewk_Intent_Service subclass
+        RefCounted so that we can use smart pointers
+        internally.
+
+        * UIProcess/API/efl/ewk_intent.cpp:
+        (ewk_intent_ref):
+        (ewk_intent_unref):
+        * UIProcess/API/efl/ewk_intent_private.h:
+        (_Ewk_Intent):
+        (_Ewk_Intent::_Ewk_Intent):
+        * UIProcess/API/efl/ewk_intent_service.cpp:
+        (ewk_intent_service_ref):
+        (ewk_intent_service_unref):
+        * UIProcess/API/efl/ewk_intent_service_private.h:
+        (_Ewk_Intent_Service):
+        (_Ewk_Intent_Service::_Ewk_Intent_Service):
+        * UIProcess/API/efl/ewk_view_loader_client.cpp:
+        (didReceiveIntentForFrame):
+        (registerIntentServiceForFrame):
+
 2012-10-16  Mikhail Pozdnyakov  <[email protected]>
 
         [EFL][WK2] Inherit Ewk_Download_Job, Ewk_Back_Forward_List_Item, Ewk_Url_Response, Ewk_Navigation_Policy_Decision from RefCounted

Modified: trunk/Source/WebKit2/UIProcess/API/efl/ewk_intent.cpp (131462 => 131463)


--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_intent.cpp	2012-10-16 16:21:24 UTC (rev 131462)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_intent.cpp	2012-10-16 16:21:49 UTC (rev 131463)
@@ -29,9 +29,6 @@
 #include "WKAPICast.h"
 #include "WKArray.h"
 #include "WKDictionary.h"
-#include "WKEinaSharedString.h"
-#include "WKIntentData.h"
-#include "WKRetainPtr.h"
 #include "WKString.h"
 #include "WKURL.h"
 #include "ewk_intent_private.h"
@@ -39,35 +36,6 @@
 
 using namespace WebKit;
 
-/**
- * \struct  _Ewk_Intent
- * @brief   Contains the intent data.
- */
-struct _Ewk_Intent {
-    unsigned int __ref; /**< the reference count of the object */
-#if ENABLE(WEB_INTENTS)
-    WKRetainPtr<WKIntentDataRef> wkIntent;
-#endif
-    WKEinaSharedString action;
-    WKEinaSharedString type;
-    WKEinaSharedString service;
-
-    _Ewk_Intent(WKIntentDataRef intentRef)
-        : __ref(1)
-#if ENABLE(WEB_INTENTS)
-        , wkIntent(intentRef)
-        , action(AdoptWK, WKIntentDataCopyAction(intentRef))
-        , type(AdoptWK, WKIntentDataCopyType(intentRef))
-        , service(AdoptWK, WKIntentDataCopyService(intentRef))
-#endif
-    { }
-
-    ~_Ewk_Intent()
-    {
-        ASSERT(!__ref);
-    }
-};
-
 #define EWK_INTENT_WK_GET_OR_RETURN(intent, wkIntent_, ...)    \
     if (!(intent)) {                                           \
         EINA_LOG_CRIT("intent is NULL.");                      \
@@ -83,7 +51,8 @@
 {
 #if ENABLE(WEB_INTENTS)
     EINA_SAFETY_ON_NULL_RETURN_VAL(intent, 0);
-    ++intent->__ref;
+
+    intent->ref();
 #endif
 
     return intent;
@@ -94,10 +63,7 @@
 #if ENABLE(WEB_INTENTS)
     EINA_SAFETY_ON_NULL_RETURN(intent);
 
-    if (--intent->__ref)
-        return;
-
-    delete intent;
+    intent->deref();
 #endif
 }
 

Modified: trunk/Source/WebKit2/UIProcess/API/efl/ewk_intent_private.h (131462 => 131463)


--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_intent_private.h	2012-10-16 16:21:24 UTC (rev 131462)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_intent_private.h	2012-10-16 16:21:49 UTC (rev 131463)
@@ -28,10 +28,32 @@
 
 #if ENABLE(WEB_INTENTS)
 
+#include "WKEinaSharedString.h"
+#include "WKIntentData.h"
+#include "WKRetainPtr.h"
 #include <WebKit2/WKBase.h>
+#include <wtf/RefCounted.h>
 
 typedef struct _Ewk_Intent Ewk_Intent;
 
+/**
+ * \struct  _Ewk_Intent
+ * @brief   Contains the intent data.
+ */
+struct _Ewk_Intent : public RefCounted<_Ewk_Intent> {
+    WKRetainPtr<WKIntentDataRef> wkIntent;
+    WKEinaSharedString action;
+    WKEinaSharedString type;
+    WKEinaSharedString service;
+
+    _Ewk_Intent(WKIntentDataRef intentRef)
+        : wkIntent(intentRef)
+        , action(AdoptWK, WKIntentDataCopyAction(intentRef))
+        , type(AdoptWK, WKIntentDataCopyType(intentRef))
+        , service(AdoptWK, WKIntentDataCopyService(intentRef))
+    { }
+};
+
 Ewk_Intent* ewk_intent_new(WKIntentDataRef intentData);
 WKIntentDataRef ewk_intent_WKIntentDataRef_get(const Ewk_Intent* intent);
 

Modified: trunk/Source/WebKit2/UIProcess/API/efl/ewk_intent_service.cpp (131462 => 131463)


--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_intent_service.cpp	2012-10-16 16:21:24 UTC (rev 131462)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_intent_service.cpp	2012-10-16 16:21:49 UTC (rev 131463)
@@ -28,8 +28,6 @@
 
 #include "IntentServiceInfo.h"
 #include "WKAPICast.h"
-#include "WKEinaSharedString.h"
-#include "WKIntentServiceInfo.h"
 #include "WKRetainPtr.h"
 #include "WKURL.h"
 #include "ewk_intent_service_private.h"
@@ -37,41 +35,11 @@
 
 using namespace WebKit;
 
-/**
- * \struct _Ewk_Intent_Service
- * @brief Contains the intent service data.
- */
-struct _Ewk_Intent_Service {
-    unsigned int __ref; /**< the reference count of the object */
-
-    WKEinaSharedString action;
-    WKEinaSharedString type;
-    WKEinaSharedString href;
-    WKEinaSharedString title;
-    WKEinaSharedString disposition;
-
-    _Ewk_Intent_Service(WKIntentServiceInfoRef serviceRef)
-        : __ref(1)
-#if ENABLE(WEB_INTENTS_TAG)
-        , action(AdoptWK, WKIntentServiceInfoCopyAction(serviceRef))
-        , type(AdoptWK, WKIntentServiceInfoCopyType(serviceRef))
-        , href(AdoptWK, WKIntentServiceInfoCopyHref(serviceRef))
-        , title(AdoptWK, WKIntentServiceInfoCopyTitle(serviceRef))
-        , disposition(AdoptWK, WKIntentServiceInfoCopyDisposition(serviceRef))
-#endif
-    { }
-
-    ~_Ewk_Intent_Service()
-    {
-        ASSERT(!__ref);
-    }
-};
-
 Ewk_Intent_Service* ewk_intent_service_ref(Ewk_Intent_Service* service)
 {
 #if ENABLE(WEB_INTENTS_TAG)
     EINA_SAFETY_ON_NULL_RETURN_VAL(service, 0);
-    ++service->__ref;
+    service->ref();
 #endif
 
     return service;
@@ -82,10 +50,7 @@
 #if ENABLE(WEB_INTENTS_TAG)
     EINA_SAFETY_ON_NULL_RETURN(service);
 
-    if (--service->__ref)
-        return;
-
-    delete service;
+    service->deref();
 #endif
 }
 

Modified: trunk/Source/WebKit2/UIProcess/API/efl/ewk_intent_service_private.h (131462 => 131463)


--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_intent_service_private.h	2012-10-16 16:21:24 UTC (rev 131462)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_intent_service_private.h	2012-10-16 16:21:49 UTC (rev 131463)
@@ -28,10 +28,33 @@
 
 #if ENABLE(WEB_INTENTS_TAG)
 
+#include "WKEinaSharedString.h"
+#include "WKIntentServiceInfo.h"
 #include <WebKit2/WKBase.h>
+#include <wtf/RefCounted.h>
 
 typedef struct _Ewk_Intent_Service Ewk_Intent_Service;
 
+/**
+ * \struct _Ewk_Intent_Service
+ * @brief Contains the intent service data.
+ */
+struct _Ewk_Intent_Service : public RefCounted<_Ewk_Intent_Service> {
+    WKEinaSharedString action;
+    WKEinaSharedString type;
+    WKEinaSharedString href;
+    WKEinaSharedString title;
+    WKEinaSharedString disposition;
+
+    _Ewk_Intent_Service(WKIntentServiceInfoRef serviceRef)
+        : action(AdoptWK, WKIntentServiceInfoCopyAction(serviceRef))
+        , type(AdoptWK, WKIntentServiceInfoCopyType(serviceRef))
+        , href(AdoptWK, WKIntentServiceInfoCopyHref(serviceRef))
+        , title(AdoptWK, WKIntentServiceInfoCopyTitle(serviceRef))
+        , disposition(AdoptWK, WKIntentServiceInfoCopyDisposition(serviceRef))
+    { }
+};
+
 Ewk_Intent_Service* ewk_intent_service_new(WKIntentServiceInfoRef wkService);
 
 #endif // ENABLE(WEB_INTENTS_TAG)

Modified: trunk/Source/WebKit2/UIProcess/API/efl/ewk_view_loader_client.cpp (131462 => 131463)


--- trunk/Source/WebKit2/UIProcess/API/efl/ewk_view_loader_client.cpp	2012-10-16 16:21:24 UTC (rev 131462)
+++ trunk/Source/WebKit2/UIProcess/API/efl/ewk_view_loader_client.cpp	2012-10-16 16:21:49 UTC (rev 131463)
@@ -52,9 +52,8 @@
 static void didReceiveIntentForFrame(WKPageRef, WKFrameRef, WKIntentDataRef intent, WKTypeRef, const void* clientInfo)
 {
     Evas_Object* ewkView = static_cast<Evas_Object*>(const_cast<void*>(clientInfo));
-    Ewk_Intent* ewkIntent = ewk_intent_new(intent);
-    ewk_view_intent_request_new(ewkView, ewkIntent);
-    ewk_intent_unref(ewkIntent);
+    RefPtr<Ewk_Intent> ewkIntent = adoptRef(ewk_intent_new(intent));
+    ewk_view_intent_request_new(ewkView, ewkIntent.get());
 }
 #endif
 
@@ -62,9 +61,8 @@
 static void registerIntentServiceForFrame(WKPageRef, WKFrameRef, WKIntentServiceInfoRef serviceInfo, WKTypeRef, const void *clientInfo)
 {
     Evas_Object* ewkView = static_cast<Evas_Object*>(const_cast<void*>(clientInfo));
-    Ewk_Intent_Service* ewkIntentService = ewk_intent_service_new(serviceInfo);
-    ewk_view_intent_service_register(ewkView, ewkIntentService);
-    ewk_intent_service_unref(ewkIntentService);
+    RefPtr<Ewk_Intent_Service> ewkIntentService = adoptRef(ewk_intent_service_new(serviceInfo));
+    ewk_view_intent_service_register(ewkView, ewkIntentService.get());
 }
 #endif
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to