[EFL] Clean up and refactor the memory cache functions in ewk_settings.
authorkubo@profusion.mobi <kubo@profusion.mobi@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 15 Dec 2011 19:45:35 +0000 (19:45 +0000)
committerkubo@profusion.mobi <kubo@profusion.mobi@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 15 Dec 2011 19:45:35 +0000 (19:45 +0000)
https://bugs.webkit.org/show_bug.cgi?id=72140

Reviewed by Antonio Gomes.

Use a better naming prefix, as "ewk_settings_cache" was too general,
and make it possible to pass all parameters to
MemoryCache::setCapacities().

* ewk/ewk_settings.cpp:
(ewk_settings_object_cache_capacity_set):
(ewk_settings_object_cache_enable_get):
(ewk_settings_object_cache_enable_set):
* ewk/ewk_settings.h:

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

Source/WebKit/efl/ChangeLog
Source/WebKit/efl/ewk/ewk_settings.cpp
Source/WebKit/efl/ewk/ewk_settings.h

index cd053cd47214598e02f4851be3cfceb7e7ca007f..b47272655cf127b7c57bb04e857f95ce752fa312 100644 (file)
@@ -1,3 +1,20 @@
+2011-12-15  Raphael Kubo da Costa  <kubo@profusion.mobi>
+
+        [EFL] Clean up and refactor the memory cache functions in ewk_settings.
+        https://bugs.webkit.org/show_bug.cgi?id=72140
+
+        Reviewed by Antonio Gomes.
+
+        Use a better naming prefix, as "ewk_settings_cache" was too general,
+        and make it possible to pass all parameters to
+        MemoryCache::setCapacities().
+
+        * ewk/ewk_settings.cpp:
+        (ewk_settings_object_cache_capacity_set):
+        (ewk_settings_object_cache_enable_get):
+        (ewk_settings_object_cache_enable_set):
+        * ewk/ewk_settings.h:
+
 2011-12-15  Raphael Kubo da Costa  <kubo@profusion.mobi>
 
         [EFL] Add a few more web database functions to ewk_settings.
index b8280d0013ec9466e88cd7ccf3aa500c245462ad..af561c3b6245043e635592c9021d64d58ebec67c 100644 (file)
@@ -220,24 +220,19 @@ Evas_Object* ewk_settings_icon_database_icon_object_add(const char* url, Evas* c
     return ewk_util_image_from_cairo_surface_add(canvas, surface);
 }
 
-Eina_Bool ewk_settings_cache_enable_get(void)
+void ewk_settings_object_cache_capacity_set(unsigned minDeadCapacity, unsigned maxDeadCapacity, unsigned totalCapacity)
 {
-    WebCore::MemoryCache* cache = WebCore::memoryCache();
-    return !cache->disabled();
+    WebCore::memoryCache()->setCapacities(minDeadCapacity, maxDeadCapacity, totalCapacity);
 }
 
-void ewk_settings_cache_enable_set(Eina_Bool set)
+Eina_Bool ewk_settings_object_cache_enable_get()
 {
-    WebCore::MemoryCache* cache = WebCore::memoryCache();
-    set = !set;
-    if (cache->disabled() != set)
-        cache->setDisabled(set);
+    return !WebCore::memoryCache()->disabled();
 }
 
-void ewk_settings_cache_capacity_set(unsigned capacity)
+void ewk_settings_object_cache_enable_set(Eina_Bool enable)
 {
-    WebCore::MemoryCache* cache = WebCore::memoryCache();
-    cache->setCapacities(0, capacity, capacity);
+    WebCore::memoryCache()->setDisabled(!enable);
 }
 
 void ewk_settings_memory_cache_clear()
index 7860573054d975d22116951cb2a00108474ceea7..1e61b4402cc7c38ad2e8eeb4ae2e6803f946409c 100644 (file)
@@ -203,30 +203,51 @@ EAPI void             ewk_settings_application_cache_max_quota_set(int64_t maxim
 EAPI void             ewk_settings_application_cache_clear(void);
 
 /**
- * Gets status of the memory cache of WebCore.
+ * Returns whether the in-memory object cache is enabled.
+ *
+ * The object cache is responsible for holding resources such as scripts, stylesheets
+ * and images in memory.
+ *
+ * By default, the cache is enabled.
  *
  * @return @c EINA_TRUE if the cache is enabled or @c EINA_FALSE if not
+ *
+ * @sa ewk_settings_object_cache_capacity_set
  */
-EAPI Eina_Bool        ewk_settings_cache_enable_get(void);
+EAPI Eina_Bool        ewk_settings_object_cache_enable_get(void);
 
 /**
- * Enables/disables the memory cache of WebCore, possibly clearing it.
+ * Enables/disables the in-memory object cache of WebCore, possibly clearing it.
+ *
+ * The object cache is responsible for holding resources such as scripts, stylesheets
+ * and images in memory.
+ *
+ * By default, the cache is enabled.
  *
  * Disabling the cache will remove all resources from the cache.
  * They may still live on if they are referenced by some Web page though.
  *
  * @param set @c EINA_TRUE to enable memory cache, @c EINA_FALSE to disable
  */
-EAPI void             ewk_settings_cache_enable_set(Eina_Bool set);
+EAPI void             ewk_settings_object_cache_enable_set(Eina_Bool set);
 
 /**
- * Sets capacity of memory cache of WebCore.
+ * Defines the capacities for the in-memory object cache.
+ *
+ * The object cache is responsible for holding resources such as scripts, stylesheets
+ * and images in memory.
+ *
+ * By default, @p min_dead_bytes is 0 and both @p max_dead_bytes and @p total_bytes are 8MB.
  *
- * WebCore sets default value of memory cache on 8192 * 1024 bytes.
+ * @param min_dead_bytes The maximum number of bytes that dead resources should consume when
+ *                       the cache is under pressure.
+ * @param max_dead_bytes The maximum number of bytes that dead resources should consume when
+ *                       the cache is not under pressure.
+ * @param total_bytes    The maximum number of bytes that the cache should consume overall.
  *
  * @param capacity the maximum number of bytes that the cache should consume overall
  */
-EAPI void             ewk_settings_cache_capacity_set(unsigned capacity);
+EAPI void             ewk_settings_object_cache_capacity_set(unsigned min_dead_bytes, unsigned max_dead_bytes, unsigned total_bytes);
 
 /**
  * Clears all memory caches.