Title: [122564] trunk/Source/WebKit/efl
Revision
122564
Author
[email protected]
Date
2012-07-13 04:43:43 -0700 (Fri, 13 Jul 2012)

Log Message

[EFL] Add const to the parameter of getters in ewk_security_origin
https://bugs.webkit.org/show_bug.cgi?id=90954

Patch by Kihong Kwon <[email protected]> on 2012-07-13
Reviewed by Kentaro Hara.

Move initialization of strings for protocol and host to the ewk_security_origin_new method,
which allows to add const qualifier for ewk_security_origin_protocol_get and ewk_security_origin_host_get.
In addition, add null checks to the getters.

* ewk/ewk_security_origin.cpp:
(ewk_security_origin_protocol_get):
(ewk_security_origin_host_get):
(ewk_security_origin_new):
* ewk/ewk_security_origin.h:

Modified Paths

Diff

Modified: trunk/Source/WebKit/efl/ChangeLog (122563 => 122564)


--- trunk/Source/WebKit/efl/ChangeLog	2012-07-13 11:24:25 UTC (rev 122563)
+++ trunk/Source/WebKit/efl/ChangeLog	2012-07-13 11:43:43 UTC (rev 122564)
@@ -1,3 +1,20 @@
+2012-07-13  Kihong Kwon  <[email protected]>
+
+        [EFL] Add const to the parameter of getters in ewk_security_origin
+        https://bugs.webkit.org/show_bug.cgi?id=90954
+
+        Reviewed by Kentaro Hara.
+
+        Move initialization of strings for protocol and host to the ewk_security_origin_new method,
+        which allows to add const qualifier for ewk_security_origin_protocol_get and ewk_security_origin_host_get.
+        In addition, add null checks to the getters.
+
+        * ewk/ewk_security_origin.cpp:
+        (ewk_security_origin_protocol_get):
+        (ewk_security_origin_host_get):
+        (ewk_security_origin_new):
+        * ewk/ewk_security_origin.h:
+
 2012-07-13  Gyuyoung Kim  <[email protected]>
 
         [EFL] Add *explicit* keyword to constructor which has a parameter

Modified: trunk/Source/WebKit/efl/ewk/ewk_security_origin.cpp (122563 => 122564)


--- trunk/Source/WebKit/efl/ewk/ewk_security_origin.cpp	2012-07-13 11:24:25 UTC (rev 122563)
+++ trunk/Source/WebKit/efl/ewk/ewk_security_origin.cpp	2012-07-13 11:43:43 UTC (rev 122564)
@@ -39,19 +39,15 @@
     const char* host;
 };
 
-const char* ewk_security_origin_protocol_get(Ewk_Security_Origin* origin)
+const char* ewk_security_origin_protocol_get(const Ewk_Security_Origin* origin)
 {
-    if (!origin->protocol)
-        origin->protocol = eina_stringshare_add(origin->securityOrigin->protocol().utf8().data());
-
+    EINA_SAFETY_ON_NULL_RETURN_VAL(origin, 0);
     return origin->protocol;
 }
 
-const char* ewk_security_origin_host_get(Ewk_Security_Origin* origin)
+const char* ewk_security_origin_host_get(const Ewk_Security_Origin* origin)
 {
-    if (!origin->host)
-        origin->host = eina_stringshare_add(origin->securityOrigin->host().utf8().data());
-
+    EINA_SAFETY_ON_NULL_RETURN_VAL(origin, 0);
     return origin->host;
 }
 
@@ -142,8 +138,8 @@
     Ewk_Security_Origin* origin = new Ewk_Security_Origin;
 
     origin->securityOrigin = coreOrigin;
-    origin->host = 0;
-    origin->protocol = 0;
+    origin->protocol = eina_stringshare_add(coreOrigin->protocol().utf8().data());
+    origin->host = eina_stringshare_add(coreOrigin->host().utf8().data());
 
     return origin;
 }

Modified: trunk/Source/WebKit/efl/ewk/ewk_security_origin.h (122563 => 122564)


--- trunk/Source/WebKit/efl/ewk/ewk_security_origin.h	2012-07-13 11:24:25 UTC (rev 122563)
+++ trunk/Source/WebKit/efl/ewk/ewk_security_origin.h	2012-07-13 11:43:43 UTC (rev 122564)
@@ -49,9 +49,9 @@
  * It returns a internal string which should not
  * be modified. The string is guaranteed to be stringshared.
  *
- * @return the protocol scheme
+ * @return the protocol scheme or @c 0 if there is not a protocol scheme
  */
-EAPI const char          *ewk_security_origin_protocol_get(Ewk_Security_Origin *o);
+EAPI const char          *ewk_security_origin_protocol_get(const Ewk_Security_Origin *o);
 
 /**
  * Returns the host of the security origin.
@@ -61,9 +61,9 @@
  *
  * @param o security origin object
  *
- * @return the host domain
+ * @return the host domain or @c 0 if there is not a host scheme
  */
-EAPI const char          *ewk_security_origin_host_get(Ewk_Security_Origin *o);
+EAPI const char          *ewk_security_origin_host_get(const Ewk_Security_Origin *o);
 
 /**
  * Returns the port of the security origin.
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to