[Webkit-unassigned] [Bug 27899] [Gtk] Expose a database API
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Mon Aug 31 23:37:42 PDT 2009
https://bugs.webkit.org/show_bug.cgi?id=27899
--- Comment #14 from Xan Lopez <xan.lopez at gmail.com> 2009-08-31 23:37:42 PDT ---
(From update of attachment 38847)
> +static void webkit_security_origin_finalize(GObject* object)
> +{
> + WebKitSecurityOrigin* securityOrigin = WEBKIT_SECURITY_ORIGIN(object);
> + WebKitSecurityOriginPrivate* priv = securityOrigin->priv;
> +
> + g_free(priv->protocol);
> + g_free(priv->host);
> +
> + G_OBJECT_CLASS(securityOrigin)->finalize(object);
You have to chain to your parent class, not to yourself! I believe this should
enter an infinite loop, does it actually work?
> +}
> +
> +static void webkit_security_origin_dispose(GObject* object)
> +{
> + WebKitSecurityOrigin* securityOrigin = WEBKIT_SECURITY_ORIGIN(object);
> + WebKitSecurityOriginPrivate* priv = securityOrigin->priv;
> +
> + if (!priv->disposed) {
> + priv->coreOrigin->deref();
> + g_hash_table_destroy(priv->webDatabases);
> + priv->disposed = true;
> + }
> +
> + G_OBJECT_CLASS(securityOrigin)->dispose(object);
Same thing here.
> +static void webkit_security_origin_class_init(WebKitSecurityOriginClass* klass)
> +{
> + GObjectClass* gobject_class = G_OBJECT_CLASS(klass);
gobjectClass
> +
> + /**
> + * WebKitSecurityOrigin:web-database-usage:
> + *
> + * The cumulative size of all web databases in the security origin in bytes.
> + *
> + * Since: 1.1.13
> + */
> + g_object_class_install_property(gobject_class, PROP_DATABASE_USAGE,
> + g_param_spec_uint64("web-database-usage",
> + _("Web Database Usage"),
> + _("The cumulative size of all web databases in the security origin"),
> + 0, G_MAXUINT64, 0,
> + WEBKIT_PARAM_READABLE));
The indentation is off here.
> + /**
> + * WebKitSecurityOrigin:web-database-quota:
> + *
> + * The web database qouta of the security origin in bytes.
> + *
> + * Since: 1.1.13
> + */
> + g_object_class_install_property(gobject_class, PROP_DATABASE_QUOTA,
> + g_param_spec_uint64("web-database-quota",
> + _("Web Database Quota"),
> + _("The web database quota of the security origin in bytes"),
> + 0, G_MAXUINT64, 0,
> + WEBKIT_PARAM_READWRITE));
Same.
> +
> +/**
> + * webkit_security_origin_get_protocol:
> + * @security_origin: a #WebKitSecurityOrigin
> + *
> + * Returns the protocol for the security origin.
> + *
> + * Returns: the protocol for the security origin
> + *
> + * Since: 1.1.13
> + **/
> +G_CONST_RETURN gchar* webkit_security_origin_get_protocol(WebKitSecurityOrigin* security_origin)
securityOrigin for the parameter
> +{
> + g_return_val_if_fail(WEBKIT_IS_SECURITY_ORIGIN(security_origin), NULL);
> +
> + WebKitSecurityOriginPrivate* priv = security_origin->priv;
> + WebCore::String protocol = priv->coreOrigin->protocol();
> +
> + if (protocol.isEmpty())
> + return "";
> +
> + g_free(priv->protocol);
> + priv->protocol = g_strdup(protocol.utf8().data());
> + return priv->protocol;
> +}
> +
> +/**
> + * webkit_security_origin_get_host:
> + * @security_origin: a #WebKitSecurityOrigin
> + *
> + * Returns the hostname for the security origin.
> + *
> + * Returns: the hostname for the security origin
> + *
> + * Since: 1.1.13
> + **/
> +G_CONST_RETURN gchar* webkit_security_origin_get_host(WebKitSecurityOrigin* security_origin)
> +{
> + g_return_val_if_fail(WEBKIT_IS_SECURITY_ORIGIN(security_origin), NULL);
> +
> + WebKitSecurityOriginPrivate* priv = security_origin->priv;
> + WebCore::String host = priv->coreOrigin->host();
> +
> + if (host.isEmpty()) {
> + return "";
> + } else {
> + g_free(priv->host);
> + priv->host = g_strdup(host.utf8().data());
> + return priv->host;
> + }
> +}
Mmm, can't the host and protocol properties be cached? Or can they actually
between each call?
> +
> +WebKitWebDatabase* webkit_security_origin_get_web_database(WebKitSecurityOrigin* security_origin, const gchar* database_name)
and databaseName here.
> +{
> + g_return_val_if_fail(WEBKIT_IS_SECURITY_ORIGIN(security_origin), NULL);
> +
> + WebKitSecurityOriginPrivate* priv = security_origin->priv;
> + GHashTable* databaseHash = priv->webDatabases;
> + WebKitWebDatabase* database = (WebKitWebDatabase*) g_hash_table_lookup(databaseHash, database_name);
> +
> + if (!database) {
> + database = WEBKIT_WEB_DATABASE(g_object_new(WEBKIT_TYPE_WEB_DATABASE,
> + "security-origin", security_origin,
> + "name", database_name,
> + NULL));
> + g_hash_table_insert(databaseHash, g_strdup(database_name), database);
> + }
> +
> + return database;
> +}
> +
> +
> +/**
> + * SECTION:webkitwebdatabase
> + * @short_description: A WebKit web application database
> + *
> + * #WebKitWebDatabase is a representation of a Web Database database. The
> + * proposed Web Database standard introduces support for SQL databases that web
> + * sites can create and access on a local computer through JavaScript.
> + *
> + * To get access to all databases defined by a security origin, use
> + * #webkit_security_origin_get_databases. Each database has a canonical
> + * name, as well as a user-friendly display name.
> + *
> + * WebKit uses SQLite to create and access the local SQL databases. The location
> + * of a #WebKitWebDatabase can be accessed wth #webkit_web_database_get_filename.
> + * You can configure the location of all databases with
> + * #webkit_set_database_directory_path.
> + *
> + * For each database the web site can define an estimated size which can be
> + * accessed with #webkit_web_database_get_expected_size. The current size of the
> + * database in bytes is returned by #webkit_web_database_get_size.
> + *
> + * For more information refer to the Web Database specification proposal at
> + * http://dev.w3.org/html5/webdatabase
> + */
Awesome documentation!
> +static void webkit_web_database_finalize(GObject* object)
> +{
> + WebKitWebDatabase* webDatabase = WEBKIT_WEB_DATABASE(object);
> + WebKitWebDatabasePrivate* priv = webDatabase->priv;
> +
> + if (priv->origin)
> + g_object_unref(priv->origin);
This should be done in dispose, not in finalize.
> +
> + g_free(priv->name);
> + g_free(priv->display_name);
> + g_free(priv->filename);
> +
> + G_OBJECT_CLASS(webkit_web_database_parent_class)->finalize(object);
> +}
> +
Also you need to s/1.1.13/1.1.14/ everywhere :)
--
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
More information about the webkit-unassigned
mailing list