aboutsummaryrefslogtreecommitdiffstats
path: root/embed/ephy-favicon-cache.c
diff options
context:
space:
mode:
authorDiego Escalante Urrelo <diegoe@svn.gnome.org>2007-01-03 16:18:47 +0800
committerDiego Escalante Urrelo <diegoe@src.gnome.org>2007-01-03 16:18:47 +0800
commit3442e0b90e66938881c2205c1bfd26e343ade466 (patch)
tree521e879ebbc0ef917b88abc2c59b262f6ac49ed1 /embed/ephy-favicon-cache.c
parent1783853f31349da7285a26107d2525e809cdaa8e (diff)
downloadgsoc2013-epiphany-3442e0b90e66938881c2205c1bfd26e343ade466.tar
gsoc2013-epiphany-3442e0b90e66938881c2205c1bfd26e343ade466.tar.gz
gsoc2013-epiphany-3442e0b90e66938881c2205c1bfd26e343ade466.tar.bz2
gsoc2013-epiphany-3442e0b90e66938881c2205c1bfd26e343ade466.tar.lz
gsoc2013-epiphany-3442e0b90e66938881c2205c1bfd26e343ade466.tar.xz
gsoc2013-epiphany-3442e0b90e66938881c2205c1bfd26e343ade466.tar.zst
gsoc2013-epiphany-3442e0b90e66938881c2205c1bfd26e343ade466.zip
Avoid use of localtime by computing expiry in seconds instead of days.
2007-01-03 Diego Escalante Urrelo <diegoe@svn.gnome.org> * embed/ephy-favicon-cache.c: (icon_is_obsolete), (remove_obsolete_icons): * embed/ephy-history.c: (page_is_obsolete), (remove_obsolete_pages): Avoid use of localtime by computing expiry in seconds instead of days. Patch by Chris Wilson. svn path=/trunk/; revision=6786
Diffstat (limited to 'embed/ephy-favicon-cache.c')
-rw-r--r--embed/ephy-favicon-cache.c28
1 files changed, 7 insertions, 21 deletions
diff --git a/embed/ephy-favicon-cache.c b/embed/ephy-favicon-cache.c
index 2892fb496..36a5c8144 100644
--- a/embed/ephy-favicon-cache.c
+++ b/embed/ephy-favicon-cache.c
@@ -47,6 +47,7 @@
#define EPHY_FAVICON_CACHE_XML_VERSION (const xmlChar *)"1.1"
#define EPHY_FAVICON_CACHE_OBSOLETE_DAYS 30
+#define SECS_PER_DAY (60*60*24)
/* how often to save the cache, in seconds */
#define CACHE_SAVE_INTERVAL (10 * 60) /* seconds */
@@ -90,7 +91,7 @@ typedef struct
guint load_failed : 1;
} PixbufCacheEntry;
-typedef gboolean (* FilterFunc) (EphyNode*, GDate *);
+typedef gboolean (* FilterFunc) (EphyNode*, time_t);
enum
{
@@ -189,23 +190,13 @@ pixbuf_cache_entry_free (PixbufCacheEntry *entry)
}
static gboolean
-icon_is_obsolete (EphyNode *node, GDate *now)
+icon_is_obsolete (EphyNode *node, time_t now)
{
int last_visit;
- GDate date;
last_visit = ephy_node_get_property_int
(node, EPHY_NODE_FAVICON_PROP_LAST_USED);
-
- g_date_clear (&date, 1);
-#if GLIB_CHECK_VERSION (2,9,0)
- g_date_set_time_t (&date, last_visit);
-#else
- g_date_set_time (&date, last_visit);
-#endif
-
- return (g_date_days_between (&date, now) >=
- EPHY_FAVICON_CACHE_OBSOLETE_DAYS);
+ return now - last_visit >= EPHY_FAVICON_CACHE_OBSOLETE_DAYS*SECS_PER_DAY;
}
static void
@@ -239,14 +230,9 @@ remove_obsolete_icons (EphyFaviconCache *cache,
EphyFaviconCachePrivate *priv = cache->priv;
GPtrArray *children;
int i;
- GDate current_date;
+ time_t now;
- g_date_clear (&current_date, 1);
-#if GLIB_CHECK_VERSION (2,9,0)
- g_date_set_time_t (&current_date, time (NULL));
-#else
- g_date_set_time (&current_date, time (NULL));
-#endif
+ now = time (NULL);
children = ephy_node_get_children (priv->icons);
for (i = (int) children->len - 1; i >= 0; i--)
@@ -255,7 +241,7 @@ remove_obsolete_icons (EphyFaviconCache *cache,
kid = g_ptr_array_index (children, i);
- if (!filter || filter (kid, &current_date))
+ if (!filter || filter (kid, now))
{
const char *filename;
char *path;