Bug 656781 - More efficient way to use g_app_info_launch_uris and gnome_vfs_mime_application_launch, r=karlt
authorHiroyuki Ikezoe <hiikezoe@mozilla-japan.org>
Thu, 12 May 2011 20:55:00 -0700
changeset 69557 a593b2b745ff77e6bf6c605423ac620d3611304e
parent 69556 47818a93c7b96f0c06ec40e7b1408504bea86255
child 69558 b79aa8807705d43ab1737d8e8a60677ffe48a38d
push id20012
push userphilringnalda@gmail.com
push dateMon, 16 May 2011 01:11:03 +0000
treeherdermozilla-central@a593b2b745ff [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskarlt
bugs656781
milestone6.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 656781 - More efficient way to use g_app_info_launch_uris and gnome_vfs_mime_application_launch, r=karlt
toolkit/system/gnome/nsGIOService.cpp
toolkit/system/gnome/nsGnomeVFSService.cpp
--- a/toolkit/system/gnome/nsGIOService.cpp
+++ b/toolkit/system/gnome/nsGIOService.cpp
@@ -130,32 +130,22 @@ nsGIOMimeApp::GetExpectsURIs(PRInt32* aE
 {
   *aExpects = g_app_info_supports_uris(mApp);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsGIOMimeApp::Launch(const nsACString& aUri)
 {
-  char *uri = strdup(PromiseFlatCString(aUri).get());
-
-  if (!uri)
-    return NS_ERROR_OUT_OF_MEMORY;
-
-  GList *uris = g_list_append(NULL, uri);
+  GList uris = { 0 };
+  PromiseFlatCString flatUri(aUri);
+  uris.data = const_cast<char*>(flatUri.get());
 
-  if (!uris) {
-    g_free(uri);
-    return NS_ERROR_OUT_OF_MEMORY;
-  }
   GError *error = NULL;
-  gboolean result = g_app_info_launch_uris(mApp, uris, NULL, &error);
-
-  g_free(uri);
-  g_list_free(uris);
+  gboolean result = g_app_info_launch_uris(mApp, &uris, NULL, &error);
 
   if (!result) {
     g_warning("Cannot launch application: %s", error->message);
     g_error_free(error);
     return NS_ERROR_FAILURE;
   }
 
   return NS_OK;
--- a/toolkit/system/gnome/nsGnomeVFSService.cpp
+++ b/toolkit/system/gnome/nsGnomeVFSService.cpp
@@ -102,27 +102,21 @@ nsGnomeVFSMimeApp::GetExpectsURIs(PRInt3
 NS_IMETHODIMP
 nsGnomeVFSMimeApp::Launch(const nsACString &aUri)
 {
   char *uri = gnome_vfs_make_uri_from_input(PromiseFlatCString(aUri).get());
 
   if (! uri)
     return NS_ERROR_FAILURE;
 
-  GList *uris = g_list_append(NULL, uri);
+  GList uris = { 0 };
+  uris.data = uri;
 
-  if (! uris) {
-    g_free(uri);
-    return NS_ERROR_FAILURE;
-  }
-
-  GnomeVFSResult result = gnome_vfs_mime_application_launch(mApp, uris);
-
+  GnomeVFSResult result = gnome_vfs_mime_application_launch(mApp, &uris);
   g_free(uri);
-  g_list_free(uris);
 
   if (result != GNOME_VFS_OK)
     return NS_ERROR_FAILURE;
 
   return NS_OK;
 }
 
 class UTF8StringEnumerator : public nsIUTF8StringEnumerator