[grilo] net: ensure cache is created with the proper size



commit 85c26ba5a52ec8b90e5984db50385dffd8ab066b
Author: Juan A. Suarez Romero <jasuarez igalia com>
Date:   Wed May 15 21:40:57 2013 +0200

    net: ensure cache is created with the proper size
    
    This covers the case of deactivating and reactivating later the cache.
    As soon as we create it, we need to set the configured sized.

 libs/net/grl-net-soup-unstable.c |   16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)
---
diff --git a/libs/net/grl-net-soup-unstable.c b/libs/net/grl-net-soup-unstable.c
index 05d18bc..07ae5fb 100644
--- a/libs/net/grl-net-soup-unstable.c
+++ b/libs/net/grl-net-soup-unstable.c
@@ -120,6 +120,11 @@ cache_up (GrlNetWc *self)
 
   soup_session_add_feature (priv->session,
                             SOUP_SESSION_FEATURE (cache));
+
+  if (priv->cache_size) {
+    soup_cache_set_max_size (cache, priv->cache_size * 1024 * 1024);
+  }
+
   g_object_unref (cache);
 }
 
@@ -132,6 +137,11 @@ cache_is_available (GrlNetWc *self)
 void
 cache_set_size (GrlNetWc *self, guint size)
 {
+  if (self->priv->cache_size == size)
+    return;
+
+  self->priv->cache_size = size;
+
   SoupSessionFeature *cache = soup_session_get_feature (self->priv->session, SOUP_TYPE_CACHE);
   if (!cache)
     return;
@@ -142,11 +152,7 @@ cache_set_size (GrlNetWc *self, guint size)
 guint
 cache_get_size (GrlNetWc *self)
 {
-  SoupSessionFeature *cache = soup_session_get_feature (self->priv->session, SOUP_TYPE_CACHE);
-  if (!cache)
-    return 0;
-
-  return soup_cache_get_max_size (SOUP_CACHE (cache));
+  return self->priv->cache_size;
 }
 
 struct request_res {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]