Bug 860213 - Use async version of set metadata. r=Neil

This commit is contained in:
Jan Horak 2013-05-06 09:04:16 -04:00
Родитель 815e0cf063
Коммит e2c0eef9eb
1 изменённых файлов: 22 добавлений и 5 удалений

Просмотреть файл

@ -2525,6 +2525,20 @@ nsDownload::~nsDownload()
{
}
#ifdef MOZ_ENABLE_GIO
static void gio_set_metadata_done(GObject *source_obj, GAsyncResult *res, gpointer user_data)
{
GError *err = NULL;
g_file_set_attributes_finish(G_FILE(source_obj), res, NULL, &err);
if (err) {
#ifdef DEBUG
NS_DebugBreak(NS_DEBUG_WARNING, "Set file metadata failed: ", err->message, __FILE__, __LINE__);
#endif
g_error_free(err);
}
}
#endif
nsresult
nsDownload::SetState(DownloadState aState)
{
@ -2670,11 +2684,14 @@ nsDownload::SetState(DownloadState aState)
GFile* gio_file = g_file_new_for_path(NS_ConvertUTF16toUTF8(path).get());
nsCString source_uri;
mSource->GetSpec(source_uri);
g_file_set_attribute(gio_file, "metadata::download-uri",
G_FILE_ATTRIBUTE_TYPE_STRING,
(gpointer)source_uri.get(),
G_FILE_QUERY_INFO_NONE, NULL, NULL);
GFileInfo *file_info = g_file_info_new();
g_file_info_set_attribute_string(file_info, "metadata::download-uri", source_uri.get());
g_file_set_attributes_async(gio_file,
file_info,
G_FILE_QUERY_INFO_NONE,
G_PRIORITY_DEFAULT,
NULL, gio_set_metadata_done, NULL);
g_object_unref(file_info);
g_object_unref(gio_file);
#endif
}