Load cookie jar in an idle callback

This improves perceived startup time a lot.
This commit is contained in:
Christian Dywan 2009-03-28 03:04:27 +01:00
parent 1e68d8fa40
commit fb1d931e2c

View file

@ -1433,6 +1433,28 @@ midori_create_diagnostic_dialog (MidoriWebSettings* settings,
return dialog; return dialog;
} }
static gboolean
midori_load_cookie_jar (gpointer data)
{
MidoriWebSettings* settings = MIDORI_WEB_SETTINGS (data);
SoupSession* webkit_session;
KatzeNet* net;
SoupSession* s_session;
SoupCookieJar* jar;
webkit_session = webkit_get_default_session ();
net = katze_net_new ();
s_session = katze_net_get_session (net);
jar = soup_cookie_jar_new ();
g_object_set_data (G_OBJECT (jar), "midori-settings", settings);
midori_soup_session_prepare (s_session, jar, settings);
midori_soup_session_prepare (webkit_session, jar, settings);
g_object_unref (jar);
g_object_unref (net);
return FALSE;
}
static gboolean static gboolean
midori_load_extensions (gpointer data) midori_load_extensions (gpointer data)
{ {
@ -1645,10 +1667,6 @@ main (int argc,
gchar* uri; gchar* uri;
KatzeItem* item; KatzeItem* item;
gchar* uri_ready; gchar* uri_ready;
KatzeNet* net;
SoupSession* webkit_session;
SoupSession* s_session;
SoupCookieJar* jar;
#if HAVE_SQLITE #if HAVE_SQLITE
sqlite3* db; sqlite3* db;
gint max_history_age; gint max_history_age;
@ -1872,16 +1890,6 @@ main (int argc,
} }
g_string_free (error_messages, TRUE); g_string_free (error_messages, TRUE);
webkit_session = webkit_get_default_session ();
net = katze_net_new ();
s_session = katze_net_get_session (net);
jar = soup_cookie_jar_new ();
g_object_set_data (G_OBJECT (jar), "midori-settings", settings);
midori_soup_session_prepare (s_session, jar, settings);
midori_soup_session_prepare (webkit_session, jar, settings);
g_object_unref (jar);
g_object_unref (net);
/* Open as many tabs as we have uris, seperated by pipes */ /* Open as many tabs as we have uris, seperated by pipes */
i = 0; i = 0;
while (uris && uris[i]) while (uris && uris[i])
@ -1995,6 +2003,7 @@ main (int argc,
g_signal_connect (app, "add-browser", g_signal_connect (app, "add-browser",
G_CALLBACK (midori_app_add_browser_cb), NULL); G_CALLBACK (midori_app_add_browser_cb), NULL);
g_idle_add (midori_load_cookie_jar, settings);
g_idle_add (midori_load_extensions, app); g_idle_add (midori_load_extensions, app);
katze_item_set_parent (KATZE_ITEM (_session), app); katze_item_set_parent (KATZE_ITEM (_session), app);
g_idle_add (midori_load_session, _session); g_idle_add (midori_load_session, _session);