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

--HG--
extra : rebase_source : d813c90648f62071a1b8eeac800431b24e22a370
This commit is contained in:
Ting-Yu Chou 2015-08-17 10:25:59 +08:00
Родитель a29eae1818
Коммит 08e0ed4155
3 изменённых файлов: 16 добавлений и 4 удалений

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

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

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

@ -147,6 +147,7 @@ LOCAL_INCLUDES += [
'/hal/sandbox',
'/layout/base',
'/media/webrtc',
'/modules/libjar',
'/netwerk/base',
'/toolkit/xre',
'/uriloader/exthandler',

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

@ -229,6 +229,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()
@ -248,7 +250,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