Bug 1119692 - Part 1: Get cached jar file fd if it exists instead of always openning it. r=smaug, r=jduell

This commit is contained in:
Ting-Yu Chou 2015-08-17 10:25:59 +08:00
parent b7149c5d65
commit c53cabad73
3 changed files with 25 additions and 4 deletions

View File

@ -66,6 +66,9 @@
#include "nsIWidget.h"
#include "nsIWindowMediator.h"
#include "nsIWindowWatcher.h"
#ifndef XP_WIN
#include "nsJARProtocolHandler.h"
#endif
#include "nsOpenURIInFrameParams.h"
#include "nsPIDOMWindow.h"
#include "nsPIWindowWatcher.h"
@ -898,9 +901,21 @@ TabParent::LoadURL(nsIURI* aURI)
rv = packageFile->GetPath(path);
NS_ENSURE_SUCCESS_VOID(rv);
nsRefPtr<OpenFileAndSendFDRunnable> openFileRunnable =
new OpenFileAndSendFDRunnable(path, this);
openFileRunnable->Dispatch();
#ifndef XP_WIN
PRFileDesc* cachedFd = nullptr;
gJarHandler->JarCache()->GetFd(packageFile, &cachedFd);
if (cachedFd) {
FileDescriptor::PlatformHandleType handle =
FileDescriptor::PlatformHandleType(PR_FileDesc2NativeHandle(cachedFd));
unused << SendCacheFileDescriptor(path, FileDescriptor(handle));
} else
#endif
{
nsRefPtr<OpenFileAndSendFDRunnable> openFileRunnable =
new OpenFileAndSendFDRunnable(path, this);
openFileRunnable->Dispatch();
}
}
}
}

View File

@ -161,6 +161,11 @@ if CONFIG['MOZ_SANDBOX'] and CONFIG['OS_ARCH'] == 'WINNT':
'/security/sandbox/chromium-shim',
]
if CONFIG['OS_ARCH'] != 'WINNT':
LOCAL_INCLUDES += [
'/modules/libjar',
]
DEFINES['BIN_SUFFIX'] = '"%s"' % CONFIG['BIN_SUFFIX']
if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('android', 'gtk2', 'gonk', 'qt'):

View File

@ -225,6 +225,8 @@ RemoteOpenFileChild::AsyncRemoteFileOpen(int32_t aFlags,
MOZ_CRASH("Couldn't get path from file!");
}
mListener = aListener;
if (mTabChild) {
if (mTabChild->GetCachedFileDescriptor(path, this)) {
// The file descriptor was found in the cache and OnCachedFileDescriptor()
@ -244,7 +246,6 @@ RemoteOpenFileChild::AsyncRemoteFileOpen(int32_t aFlags,
// The chrome process now has a logical ref to us until it calls Send__delete.
AddIPDLReference();
mListener = aListener;
mAsyncOpenCalled = true;
return NS_OK;
#endif