firefox(-gnome-support) should be compiled with Gio support instead GnomeVFS

Bug #539226 reported by Javier Jardón
18
This bug affects 4 people
Affects Status Importance Assigned to Milestone
Mozilla Firefox
Fix Released
Wishlist
firefox (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

Binary package hint: firefox

GnomeVFS is deprecated and won't be included in future GNOME releases

Also, GNOME support in mozilla seems quite modular and can be selected the desired libraries:
https://hg.mozilla.org/mozilla-central/file/69cb1df1cb0f/toolkit/system/gnome/nsGnomeModule.cpp

Revision history for this message
In , Jhorak (jhorak) wrote :

Created an attachment (id=378853)
Initial extension patch

Use "--enable-extensions=gio" to compile with gio module.

Revision history for this message
In , Caillon (caillon) wrote :

closing in favor of the other bug

*** This bug has been marked as a duplicate of bug 402892 ***

Revision history for this message
In , Jhorak (jhorak) wrote :

Actually this bug/patch is about GnomeVFS extension which allows to open URI like sftp:// smb://.

Bug #402892 is concerned about FF integration into Gnome (file association, MIME types, default browser settings, etc.).

Therefore the review request is still valid.

Revision history for this message
In , Roc-ocallahan (roc-ocallahan) wrote :

(From update of attachment 378853)
I only took a cursory look at the patch --- i.e. this is really an sr, and really not an r :-)

Revision history for this message
In , Karlt (karlt) wrote :
Download full text (6.9 KiB)

(From update of attachment 378853)
>+REQUIRES = xpcom \

This can now be removed (since bug 398573).

>+# to install gnome-vfs2 in order to use the rest of mozilla ;-)

s/gnome-vfs2/gio/

>+ * This code is based on original Mozilla gnome-vfs extension. It implements
>+ * input stream provided by GVFS/GIO.

This should match the template at

http://www.mozilla.org/MPL/MPL-1.1.html#exhibit-a

so I think that means "The Original Code is the Mozilla gnome-vfs extension",
unfortunately. Although the comment is helpful, it would be better separated
from the license block.

>+ case G_IO_ERROR_FAILED: return NS_ERROR_UNEXPECTED;

Looks like G_IO_ERROR_FAILED is a generic failure, so "case
G_IO_ERROR_FAILED:" should probably just fall through to the "default:" to
return NS_ERROR_FAILURE.

>+ case G_IO_ERROR_NOT_MOUNTED:
>+ case G_IO_ERROR_HOST_NOT_FOUND: return NS_ERROR_UNKNOWN_HOST;

G_IO_ERROR_NOT_MOUNTED is here and in unhandled below. Consider
NS_ERROR_NOT_CONNECTED here, or just remove.

>+ G_IO_ERROR_INVALID_FILENAME,

NS_ERROR_FILE_INVALID_PATH

>+ G_IO_ERROR_WOULD_BLOCK,

NS_BASE_STREAM_WOULD_BLOCK

>+ G_IO_ERROR_TIMED_OUT,

Maybe NS_ERROR_NET_TIMEOUT.

>+ if (!gdk_win)
>+ return NULL;
>+
>+ // Get the container
>+ gpointer user_data = NULL;
>+ gdk_window_get_user_data(gdk_win, &user_data);
>+ if (!user_data)
>+ return NULL;

Indent the return statements, please.

>+ // Make sure its really a container
>+ MozContainer *parent_container = (MozContainer*) (user_data);
>+ if (!parent_container)
>+ return NULL;

This is barely pretending to "make sure".
It actually only needs to be a GtkWidget.
Either use GTK_IS_WIDGET or skip the check.

>+ nsCOMPtr<nsIBaseWindow> baseWin(do_QueryInterface(reinterpret_cast<nsISupports*> (window->GetDocShell()) ));

>+ baseWin = do_QueryInterface(reinterpret_cast<nsISupports*> (window->GetDocShell()) );

The reinterpret_casts don't look right.
Does including nsIDocShell should fix the problem?

>+ nsCOMPtr<nsIWindowWatcher> wwatch =
>+ do_GetService(NS_WINDOWWATCHER_CONTRACTID, &rv);
>+ //NS_ENSURE_SUCCESS(rv, rv);

Should check for failure here somehow.

>+
>+ nsCOMPtr<nsIDOMWindow> active;
>+ wwatch->GetActiveWindow(getter_AddRefs(active));
>+
>+ GtkWindow *parent_wnd = NULL;
>+ parent_wnd = get_gtk_window_for_nsiwidget(DOMWindowToWidget(active));

This doesn't look thread-safe.

And is there always an active window?

We actually have no idea which window is associated with the stream (AFAIK).
Is the transient parent important?

>+ GMountOperation* mount_op = gtk_mount_operation_new(parent_wnd);

gtk_mount_operation_new needs gtk+-2.14 so there needs to be a configure check
for that version.

Is GTK thread-safe?

>+ if (error) {
>+ g_warning("Error reading directory content: %s", error->message);
>+ nsresult rv = MapGIOResult(error);
>+ g_error_free(error);
>+ return rv;
>+ }
>+ g_object_unref(f_enum);

f_enum needs to be freed even if error.

>+ if (mime_type && strcmp(mime_type, APPLICATION_OCTET_STREAM) != 0) {
>+ SetContentTypeOfChannel(mime_type);
>+ g_free(mime_type);
>+ }

mime_type needs to b...

Read more...

Revision history for this message
In , Jhorak (jhorak) wrote :

Created an attachment (id=401429)
Patch 0.2, fixed according to review comments

Thanks a lot for your comments. I've tried to fix problematic issues. I've also dropped from searching for root window (to be able to create modal dialogue).

In fact while invoking command 'firefox sftp://etc' failed to get root window anyway. The problem is that if you close the Firefox while the login window is still showed the Firefox keeps naturally running. Right now I'm not sure how to solve this issue.

Could you look at this patch once again, please?

Also please look at GTK 2.14 checking in configure.in, I'm not very sure if this is the right way to do the version checking.

Revision history for this message
In , Karlt (karlt) wrote :

(In reply to comment #6)
> The problem is that if you close the Firefox while the login window is
> still showed the Firefox keeps naturally running. Right now I'm not sure how to
> solve this issue.

What did the gnomevfs extension do here?

nsAppStartup counts XUL windows and tries to quit when the last is closed;
that may cause some problems here.

Would it make sense to implement a GMountOperation (to replace the GtkMountOperation) using nsIAuthPrompt (like the gnomevfs extension used)?

One thing we need to tell the user when asking for a password is the host to which they are connecting.

Revision history for this message
In , Reed Loden (reed) wrote :

Jan, any updates on this?

Revision history for this message
In , Jhorak (jhorak) wrote :

Created an attachment (id=421233)
Patch 0.3, switched from gtk_mount_operation back to nsIAuthPrompt

Sorry for long delay. I've removed gtk_mount_operation and put nsIAuthPrompt back. I also switched to using observers for getting dialogue result.
Any ideas for?:
  while (!mMountFinished) {
    PR_Sleep(1000); // XXX waiting loop
  }
Please could you check it?

Revision history for this message
In , Jhorak (jhorak) wrote :

Created an attachment (id=421249)
Patch 0.3b, switched from gtk_mount_operation back to nsIAuthPrompt

Sorry, bogus diff parts.

Revision history for this message
In , Sgautherie-bz (sgautherie-bz) wrote :

(From update of attachment 421249)
>diff -r 1a3d81ba980a config/autoconf.mk.in
>@@ -261,16 +261,19 @@ MOZ_GCONF_CFLAGS = @MOZ_GCONF_CFLAGS@
> MOZ_GIO_CFLAGS = @MOZ_GIO_CFLAGS@
> MOZ_GIO_LIBS = @MOZ_GIO_LIBS@
>
>+MOZ_GIO_CFLAGS = @MOZ_GIO_CFLAGS@
>+MOZ_GIO_LIBS = @MOZ_GIO_LIBS@
>+

Bad merge?

Revision history for this message
In , Jhorak (jhorak) wrote :

Created an attachment (id=426480)
Patch 0.4, removed configure.in and autoconf.mk.in diffs.

Sorry, you're right. Removed diffs of configure.in and autoconf.mk.in as they are obsolete now.

Revision history for this message
Javier Jardón (jjardon) wrote :

Binary package hint: firefox

GnomeVFS is deprecated and won't be included in future GNOME releases

Also, GNOME support in mozilla seems quite modular and can be selected the desired libraries:
https://hg.mozilla.org/mozilla-central/file/69cb1df1cb0f/toolkit/system/gnome/nsGnomeModule.cpp

Changed in firefox:
status: Unknown → Confirmed
Revision history for this message
In , Karlt (karlt) wrote :
Download full text (7.0 KiB)

(From update of attachment 426480)
(In reply to comment #9)
> I also switched to using observers for getting dialogue result.

These observers are retrieving the result of g_file_mount_enclosing_volume
(rather than the password dialog). nsIObserverService is really for global
notifications. Here IIUC there could be multiple concurrent nsGIOInputStreams
and thus multiple GMountOperations. It seems that
mount_enclosing_volume_finished needs a reference to the nsGIOInputStream.

> Any ideas for?:
> while (!mMountFinished) {
> PR_Sleep(1000); // XXX waiting loop
> }
> Please could you check it?

mozilla::Monitor should suit this case:

http://hg.mozilla.org/mozilla-central/annotate/f7a9b2f21b09/xpcom/glue/Monitor.h#l59
https://developer.mozilla.org/en/NSPR_API_Reference/Introduction_to_NSPR#NSPR_Thread_Synchronization

It would be helpful to have some comments explaining on which thread the
callbacks from g_file_mount_enclosing_volume will be invoked.
(It's a little counter-intuitive that its neither the thread that called
g_file_mount_enclosing_volume nor the thread that created the GMountOperation.

I don't know that we can be sure that nsGIOInputStream::Read is always called
off the main thread. If it gets called on the main thread, MountVolume will
lock. I think the right thing to do if G_IO_ERROR_NOT_MOUNTED is received
when called on the main thread is just skip the MountVolume and return an
error. It looks like "bool NS_IsMainThread()" is the function to use to check
this.

Can you check the list of headers included please?
There have been some modifications so I think some are longer be needed.

configure.in should probably have a check that gio is available, similar to
the `echo "$MOZ_EXTENSIONS" | grep -c gnomevfs` test.

>+ * The Original Code is IBM Corporation.

"* The Original Code is the Mozilla gnome-vfs extension.
 *
 * The Initial Developer of the Original Code is IBM Corporation."

>+ case G_IO_ERROR_NOT_MOUNTED: return NS_ERROR_NOT_CONNECTED

>+/* unhandled:
>+ G_IO_ERROR_NOT_REGULAR_FILE,
>+ G_IO_ERROR_NOT_SYMBOLIC_LINK,
>+ G_IO_ERROR_NOT_MOUNTABLE_FILE,
>+ G_IO_ERROR_TOO_MANY_LINKS,
>+ G_IO_ERROR_NOT_MOUNTED,

G_IO_ERROR_NOT_MOUNTED is handled above so remove it from this list.

>+ // Make sure authIn->uri is consistent with the channel's URI.
>+ //
>+ // XXX This check is probably not IDN safe, and it might incorrectly
>+ // fire as a result of escaping differences. It's unclear what
>+ // kind of transforms GnomeVFS might have applied to the URI spec
>+ // that we originally gave to it. In spite of the likelihood of
>+ // false hits, this check is probably still valuable.
>+ //
>+ nsCAutoString spec;
>+ uri->GetSpec(spec);
>+ int uriLen = strlen(default_domain);
>+ if (!StringHead(spec, uriLen).Equals(nsDependentCString(default_domain, uriLen)))
>+ {
>+ LOG(("gnomevfs: [spec=%s authIn->uri=%s]\n", spec.get(), default_domain));
>+ NS_ERROR("URI mismatch");
>+ }

I wouldn't expect default_domain to be the same as the spec. It seems the
only reason this passes (when testing with sftp:) is that default_domain is
empty....

Read more...

Revision history for this message
In , Karlt (karlt) wrote :

(In reply to comment #13)
> It looks like the channel could be destroyed before
> mount_operation_ask_password is called.

Sorry, I think I'm wrong here and I expect what you have is fine.
I don't completely grasp the relationship between the nsGIOInputStream and the nsIChannel, but I assume that, if a thread is Read()ing the nsGIOInputStream, something must be holding a reference to the nsIChannel.

Revision history for this message
In , Jhorak (jhorak) wrote :

Created an attachment (id=445660)
Patch 0.5, Monitor added, observers removed

Removed observers replacing them with user pointer in mount_enclosing_volume_finished. Added comments about threads, Waiting loop replaced by monitor.

Usage of Cancel method for channels shows nice error messages to user which depends on gio failure type. Please have a look.

Revision history for this message
In , Karlt (karlt) wrote :

(From update of attachment 445660)
>+ else
>+ if test `echo "$MOZ_EXTENSIONS" | grep -c gio` -ne 0; then
>+ PKG_CHECK_MODULES(MOZ_GNOMEVFS, gio-2.0 >= $GIO_VERSION [
>+ MOZ_GIO_LIBS=`echo $MOZ_GIO_LIBS | sed 's/-llinc\>//'`
>+ ])
>+ fi

This would need a comma after GIO_VERSION, I assume, and the first argument
would need to be MOZ_GIO, but this doesn't work anyway because MOZ_EXTENSIONS
is not yet set.

That means that the same test for MOZ_GNOMEVFS doesn't work either and so
I guess no one has used that.

Therefore feel free to just leave configure.in as is and --enable-gio will be needed to build the gio extension.

>+LOCAL_INCLUDES = $(MOZ_GTK2_CFLAGS) \
>+ $(MOZ_GIO_CFLAGS)
>+

>+EXTRA_DSO_LDOPTS = \
>+ $(XPCOM_GLUE_LDOPTS) \
>+ $(NSPR_LIBS) \
>+ $(MOZ_GTK2_LIBS) \
>+ $(MOZ_GIO_LIBS) \
>+ $(NULL)

>+#include <gtk/gtk.h>

GTK is no longer used. I expect gio/gio.h would be sufficient.

>+ mozilla::MonitorAutoEnter mon(mMonitorMountInProgress);
>+ /* Waiting for finish of mount operation thread */
>+ mon.Wait();
>+ g_warning("monitor done");
 + g_object_unref(mount_op);

The state of the mount operation should be checked before waiting in case the
operation already Notify/signals before this wait starts. Also
pthread_cond_wait() can wakeup spuriously, so the state should be checked on
return from Wait(). If G_MOUNT_OPERATION_IN_PROGRESS were a
GMountOperationResult this would normally look something like

   while (mMountRes == G_MOUNT_OPERATION_IN_PROGRESS)
     mon.Wait();

>+ * nsGIOInputStream. This function is called in main thread as async request
>+ * from dbus.

How about "main thread as an async request typically from dbus"?
IIUC, while gvfs is implemented using dbus, GIO need not necessarily use dbus, for other modules for example.

If G_ASK_PASSWORD_NEED_DOMAIN is requested, should the reply be
G_MOUNT_OPERATION_UNHANDLED?

Please remove the debugging g_warnings.
Ideally g_warnings would only be for cases where the code is misused
(and normally we use NS_ASSERTION for that).

Revision history for this message
In , Karlt (karlt) wrote :

(In reply to comment #15)
> Usage of Cancel method for channels shows nice error messages to user which
> depends on gio failure type. Please have a look.

How do you get these error messages and where do you see them?
I tried sftp://notauser@localhost/etc, cancelling and entering the wrong
password 3 times.

And how do you know that it is safe to call nsIInputStreamChannel::Cancel()
from the Read() thread?

Revision history for this message
In , Bzbarsky (bzbarsky) wrote :

> And how do you know that it is safe to call nsIInputStreamChannel::Cancel()
> from the Read() thread?

It's not, unless the Read() thread is the main thread.

Revision history for this message
In , Bzbarsky (bzbarsky) wrote :

I'd think an error rv from Read() would propagate into the channel status. Does it not?

Revision history for this message
In , Jhorak (jhorak) wrote :

Created an attachment (id=446488)
Patch 0.6, warnings removed, Cancel removed

Sorry for confusion with Cancel. Error reporting works without calling it. Sorry also for g_warning leftovers (they was just for my debug runs).

I removed Cancel call, useless g_warnings and configure.in changes.

There is still no feedback when user aborts password dialog or fill wrong login/pass.

Revision history for this message
In , Karlt (karlt) wrote :

(From update of attachment 446488)
Thank you, Jan. This is looking good.

(In reply to comment #20)
> There is still no feedback when user aborts password dialog or fill wrong
> login/pass.

I don't think we need to sort that out in order to land this. The gnomevfs extension seems to leave no feedback on failure often enough.

>+ /* Calling g_file_mount_enclosing_volume creates a new thread */

Is this actually true? I thought typically it would start a new process and
send a dbus request. But really it could do anything. The key is that it is
asynchronous and the reply arrives on the main thread.

>+ /* Waiting for finish of mount operation thread */
>+ while (mMountRes == G_MOUNT_OPERATION_UNHANDLED)

I was initially worried that this might sometimes get set to
G_MOUNT_OPERATION_UNHANDLED as a GIO result of
g_file_mount_enclosing_volume().
But then I remembered that mMountRes is only set to internal values based on
the error from g_file_mount_enclosing_volume_finish.

I think it would be clearer to use an internal enum type for mMountRes with 3 values for the in-progress/failure/success states.

Changed in firefox:
importance: Unknown → Wishlist
Revision history for this message
In , Jhorak (jhorak) wrote :

Created attachment 501303
Patch 0.7, sync to mozilla-central

Please have a look at version synced with latest mozilla-central. When review gets positive I'll try to set need-checkin.

Revision history for this message
In , Karlt (karlt) wrote :

The merge with m-c looks good, thanks, but, before checkin, can you correct the "Calling g_file_mount_enclosing_volume creates a new thread" comment and use a new distinct enum type for mMountRes, in line with comment 21, please?

We'll also need to get approval2.0, but as this is not part of the default build, I don't expect that to be a problem.

Revision history for this message
In , Karlt (karlt) wrote :

Comment on attachment 501303
Patch 0.7, sync to mozilla-central

>+#include "nsIStandardURL.h"
>+#include "nsMimeTypes.h"
>+#include "nsNetUtil.h"
>+#include "mozilla/Monitor.h"
>+#include "nsIStandardURL.h"

One of the nsIStandardURL.h includes can be removed too :)

Revision history for this message
In , Jhorak (jhorak) wrote :

Created attachment 501632
Patch 0.8, fixed comments and added mount operation enum

Here it comes...

Revision history for this message
In , Karlt (karlt) wrote :

Comment on attachment 501632
Patch 0.8, fixed comments and added mount operation enum

>+nsGIOInputStream::SetMountResult(GMountOperationResult result, gint error_code)
>+{
>+ mozilla::MonitorAutoEnter mon(mMonitorMountInProgress);
>+ mMountRes = (result == G_MOUNT_OPERATION_HANDLED)
>+ ? MOUNT_OPERATION_SUCCESS : MOUNT_OPERATION_FAILED;

SetMountResult is only used in this file and the parameter is not really a
GMountOperationResult. It should be the internal enum "MountOperationResult".

>+ , mMountRes(MOUNT_OPERATION_IN_PROGRESS)

mMountRes is only used in nsGIOInputStream::MountVolume() so doesn't need to
be initialized here.

>+ /* A g_file_mount_enclosing_volume is using dbus request to mount volume.

"/* g_file_mount_enclosing_volume uses a dbus request to mount the volume."

>+ Callback mount_enclosing_volume_finished is called in main thread
>+ (not this thread from witch it this method called). */

"(not this thread on which this method is called)."

Revision history for this message
In , Jhorak (jhorak) wrote :

Created attachment 502458
Patch 0.9, fixed comments and mount operation enum

Ah, sorry about it, I was too hasty with enums. Thanks for fixing comments too.

Revision history for this message
In , Karlt (karlt) wrote :

Comment on attachment 502458
Patch 0.9, fixed comments and mount operation enum

>+++ b/extensions/gio/Makefile.in Mon Jan 10 12:32:39 2011 +0100
>+# This code is based on original Mozilla gnome-vfs extension. It implements
>+# input stream provided by GVFS/GIO.

This license header needs to be made consistent with the original gnomevfs
Makefile.in, in the same way as you fixed up for nsGIOProtocolHandler.cpp.

I think we can request approval2.0 when that's done.

Revision history for this message
In , Jhorak (jhorak) wrote :

Created attachment 502759
Patch 0.1, fixed license

Revision history for this message
In , Karlt (karlt) wrote :

(In reply to comment #23)
> ... this is not part of the default build ...

To be more precise:
This extension is not enabled by default. The only change to the default build here is a lookup of the service NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX"moz-gio" (which won't normally be present). This is similar to what is done for the gnomevfs extension.

The benefit of the patch is that distributions no longer shipping gnomevfs can enable the gio extension for similar behaviour using modern system libraries.

Revision history for this message
In , Jhorak (jhorak) wrote :

Setting checkin-needed, is it possible?

Revision history for this message
In , Mounir-lamouri (mounir-lamouri) wrote :

(In reply to comment #31)
> Setting checkin-needed, is it possible?

Unfortunately not. This patch need to be approved before landing on mozilla-central because we are too close to the release. If it's not approved, it will be able to be pushed after the release.

Revision history for this message
In , Roc-ocallahan (roc-ocallahan) wrote :

I really think we should take this post-FF4.

Changed in firefox:
status: Confirmed → In Progress
Revision history for this message
In , Jst (jst) wrote :

Comment on attachment 502759
Patch 0.1, fixed license

Agreed, this is too big of a change for Firefox 4 at this point. We'll get this in after branching!

Revision history for this message
In , Ehsan-mozilla (ehsan-mozilla) wrote :
Revision history for this message
In , Ehsan-mozilla (ehsan-mozilla) wrote :
Revision history for this message
In , Chpe (chpe) wrote :

The patch as checked in still is full of debugging g_warnings()s; I think they should be removed, as the reviewer in comment 5 and comment 16 also said.

MapGIOResult(gint) converts GIOErrorEnum codes to nsresult, but MapGIOResult(GError*) hands it any GError's ->code without first checking that ->domain == G_IO_ERROR (there's no guarantee all those gio functions only return G_IO_ERROR errors).

Changed in firefox:
status: In Progress → Fix Released
Revision history for this message
Micah Gersten (micahg) wrote :

Starting with Ubuntu 11.04, Firefox is compiled with gio. Please report any other issues you may find.

Changed in firefox (Ubuntu):
status: New → Fix Released
Revision history for this message
Alexandr (olexandr-dmitriev) wrote :

Hi!
When I go to File - Open - I don't see any network bookmars, only local folder.

Revision history for this message
In , Ben-bucksch (ben-bucksch) wrote :

xref bug 1058177 - gvfs within firefox process using 100% disk.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.