This change-bundle is the start of loadFromStream(). Currently, I'm
only able to load the first burst from the RandomHTMLInputStream, because for some reason the native stream is getting closed prematurely. Need to investigate more. M classes_spec/org/mozilla/webclient/impl/wrapper_native/NavigationImpl.java - remove loadFromStreamBlocking. No point in implementing this since the loadFromStream() impl is inherently multi-threaded. M src_moz/EmbedWindow.cpp M src_moz/EmbedWindow.h - expose LoadStream() method that wraps same on nsIDocShell. M src_moz/InputStreamShim.cpp - Do a lock around our buffer deletion in or dtor. M src_moz/Makefile.in - activate nsActions and NavigationActionEvents M src_moz/NavigationActionEvents.cpp M src_moz/NavigationActionEvents.h - comment out everything but wsLoadFromStreamEvent. - fix it to work with the NativeBrowserControl. M src_moz/NavigationImpl.cpp - activate nativeLoadFromStream. This is the first *new* version method to use the old native event queue. M src_moz/ns_util.cpp M src_moz/ns_util.h - remove unused first arg from Post*Event methods. M test/automated/src/classes/org/mozilla/webclient/NavigationTest.java - activate loadFromStream test. M test/automated/src/classes/org/mozilla/webclient/RandomHTMLInputStream.java - add a randomExceptions param to the ctor to enable or disable randomly thrown exceptions. git-svn-id: svn://10.0.0.236/trunk@155640 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -40,6 +40,9 @@
|
||||
#include "nsIContentViewerEdit.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsIDocShellLoadInfo.h"
|
||||
|
||||
|
||||
#include "NativeBrowserControl.h"
|
||||
@@ -267,6 +270,20 @@ EmbedWindow::GetSelection(JNIEnv *env, jobject mSelection)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
EmbedWindow::LoadStream(nsIInputStream *aStream, nsIURI * aURI,
|
||||
const nsACString &aContentType,
|
||||
const nsACString &aContentCharset,
|
||||
nsIDocShellLoadInfo * aLoadInfo)
|
||||
{
|
||||
nsCOMPtr<nsIDocShell> docShell = do_GetInterface(mWebBrowser);
|
||||
if (!docShell) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
return docShell->LoadStream(aStream, aURI, aContentType, aContentCharset,
|
||||
aLoadInfo);
|
||||
}
|
||||
|
||||
// nsISupports
|
||||
|
||||
NS_IMPL_ADDREF(EmbedWindow)
|
||||
|
||||
@@ -42,6 +42,9 @@
|
||||
#include "nsString.h"
|
||||
|
||||
class NativeBrowserControl;
|
||||
class nsIInputStream;
|
||||
class nsIURI;
|
||||
class nsIDocShellLoadInfo;
|
||||
|
||||
#include "ns_util.h"
|
||||
|
||||
@@ -63,6 +66,11 @@ public:
|
||||
|
||||
nsresult SelectAll ();
|
||||
nsresult GetSelection (JNIEnv *env, jobject selection);
|
||||
|
||||
nsresult LoadStream (nsIInputStream *aStream, nsIURI * aURI,
|
||||
const nsACString &aContentType,
|
||||
const nsACString &aContentCharset,
|
||||
nsIDocShellLoadInfo * aLoadInfo);
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
|
||||
@@ -51,10 +51,14 @@ InputStreamShim::~InputStreamShim()
|
||||
|
||||
mContentLength = -1;
|
||||
|
||||
PR_Lock(mLock);
|
||||
|
||||
delete [] mBuffer;
|
||||
mBuffer = nsnull;
|
||||
mBufferLength = 0;
|
||||
|
||||
PR_Unlock(mLock);
|
||||
|
||||
mAvailable = 0;
|
||||
mAvailableForMozilla = 0;
|
||||
mNumRead = 0;
|
||||
|
||||
@@ -86,7 +86,6 @@ REQUIRES = xpcom \
|
||||
$(NULL)
|
||||
|
||||
# BROKEN SOURCES
|
||||
# nsActions.cpp \
|
||||
# CBrowserContainer.cpp \
|
||||
# PromptActionEvents.cpp \
|
||||
# CurrentPageActionEvents.cpp \
|
||||
@@ -94,11 +93,12 @@ REQUIRES = xpcom \
|
||||
# HistoryActionEvents.cpp \
|
||||
# ISupportsPeer.cpp \
|
||||
# NativeEventThreadActionEvents.cpp \
|
||||
# NavigationActionEvents.cpp \
|
||||
# WindowControlActionEvents.cpp \
|
||||
# WindowCreator.cpp \
|
||||
|
||||
CPPSRCS = \
|
||||
nsActions.cpp \
|
||||
NavigationActionEvents.cpp \
|
||||
InputStreamShim.cpp \
|
||||
CurrentPageImpl.cpp \
|
||||
NativeBrowserControl.cpp \
|
||||
|
||||
@@ -48,9 +48,10 @@
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIFrame.h"
|
||||
|
||||
/*
|
||||
* wsLoadURLEvent
|
||||
*/
|
||||
#include "NativeBrowserControl.h"
|
||||
#include "EmbedWindow.h"
|
||||
|
||||
/*****************************
|
||||
|
||||
wsLoadURLEvent::wsLoadURLEvent(nsIWebNavigation* webNavigation, PRUnichar * urlString, PRInt32 urlLength) :
|
||||
nsActionEvent(),
|
||||
@@ -81,14 +82,15 @@ wsLoadURLEvent::~wsLoadURLEvent ()
|
||||
delete mURL;
|
||||
}
|
||||
|
||||
***********************/
|
||||
|
||||
wsLoadFromStreamEvent::wsLoadFromStreamEvent(NativeBrowserControl *yourInitCx,
|
||||
wsLoadFromStreamEvent::wsLoadFromStreamEvent(NativeBrowserControl *yourNativeBC,
|
||||
void *globalStream,
|
||||
nsString &uriToCopy,
|
||||
const char *contentTypeToCopy,
|
||||
PRInt32 contentLength,
|
||||
void *globalLoadProperties) :
|
||||
nsActionEvent(), mInitContext(yourInitCx), mUriString(uriToCopy),
|
||||
nsActionEvent(), mNativeBrowserControl(yourNativeBC), mUriString(uriToCopy),
|
||||
mContentType(PL_strdup(contentTypeToCopy)),
|
||||
mProperties(globalLoadProperties), mShim(nsnull)
|
||||
{
|
||||
@@ -96,9 +98,9 @@ wsLoadFromStreamEvent::wsLoadFromStreamEvent(NativeBrowserControl *yourInitCx,
|
||||
NS_IF_ADDREF(mShim);
|
||||
}
|
||||
|
||||
wsLoadFromStreamEvent::wsLoadFromStreamEvent(NativeBrowserControl *yourInitCx,
|
||||
wsLoadFromStreamEvent::wsLoadFromStreamEvent(NativeBrowserControl *yourNativeBC,
|
||||
InputStreamShim *yourShim) :
|
||||
nsActionEvent(), mInitContext(yourInitCx), mUriString(nsnull),
|
||||
nsActionEvent(), mNativeBrowserControl(yourNativeBC), mUriString(nsnull),
|
||||
mContentType(nsnull), mProperties(nsnull), mShim(yourShim)
|
||||
{
|
||||
}
|
||||
@@ -128,8 +130,8 @@ wsLoadFromStreamEvent::handleEvent ()
|
||||
|
||||
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION);
|
||||
|
||||
// we must have both mInitContext and mShim to do anything
|
||||
if (!mInitContext || !mShim) {
|
||||
// we must have both mNativeBrowserControl and mShim to do anything
|
||||
if (!mNativeBrowserControl || !mShim) {
|
||||
return (void *) rv;
|
||||
}
|
||||
|
||||
@@ -162,16 +164,10 @@ wsLoadFromStreamEvent::handleEvent ()
|
||||
printf ("debug: capelli: LoadStream - mContentType: %s mUriString: %s\n",
|
||||
mContentType, mUriString.get());
|
||||
|
||||
rv = mInitContext->docShell->LoadStream(mShim, uri,
|
||||
rv = mNativeBrowserControl->mWindow->LoadStream(mShim, uri,
|
||||
nsDependentCString(mContentType),
|
||||
NS_LITERAL_CSTRING(""),
|
||||
nsnull);
|
||||
if (mProperties) {
|
||||
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION);
|
||||
::util_DeleteGlobalRef(env, (jobject) mProperties);
|
||||
mProperties = nsnull;
|
||||
}
|
||||
|
||||
// make it so we don't issue multiple LoadStream calls
|
||||
// for this InputStreamShim instance.
|
||||
|
||||
@@ -182,9 +178,9 @@ wsLoadFromStreamEvent::handleEvent ()
|
||||
// if there is more data
|
||||
if (NS_OK == readFromJavaStatus){
|
||||
// and we can create a copy of ourselves
|
||||
if (repeatEvent = new wsLoadFromStreamEvent(mInitContext, mShim)) {
|
||||
if (repeatEvent = new wsLoadFromStreamEvent(mNativeBrowserControl, mShim)) {
|
||||
// do the loop
|
||||
::util_PostEvent(mInitContext, (PLEvent *) *repeatEvent);
|
||||
::util_PostEvent((PLEvent *) *repeatEvent);
|
||||
rv = NS_OK;
|
||||
}
|
||||
else {
|
||||
@@ -204,12 +200,16 @@ wsLoadFromStreamEvent::~wsLoadFromStreamEvent ()
|
||||
{
|
||||
nsCRT::free(mContentType);
|
||||
mContentType = nsnull;
|
||||
if (mProperties) {
|
||||
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION);
|
||||
::util_DeleteGlobalRef(env, (jobject) mProperties);
|
||||
mProperties = nsnull;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* wsPostEvent
|
||||
*/
|
||||
/**********************
|
||||
wsPostEvent::wsPostEvent(NativeBrowserControl *yourInitContext,
|
||||
nsIURI *absoluteUri,
|
||||
const PRUnichar *targetToCopy,
|
||||
@@ -219,7 +219,7 @@ wsPostEvent::wsPostEvent(NativeBrowserControl *yourInitContext,
|
||||
PRInt32 postHeadersLength,
|
||||
const char *postHeadersToCopy) :
|
||||
nsActionEvent(),
|
||||
mInitContext(yourInitContext)
|
||||
mNativeBrowserControl(yourInitContext)
|
||||
{
|
||||
mAbsoluteURI = absoluteUri;
|
||||
if (targetToCopy != nsnull){
|
||||
@@ -253,8 +253,8 @@ wsPostEvent::handleEvent ()
|
||||
{
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
||||
// we must have mInitContext to do anything
|
||||
if (!mInitContext) {
|
||||
// we must have mNativeBrowserControl to do anything
|
||||
if (!mNativeBrowserControl) {
|
||||
return (void *) rv;
|
||||
}
|
||||
nsCOMPtr<nsIPresContext> presContext;
|
||||
@@ -265,7 +265,7 @@ wsPostEvent::handleEvent ()
|
||||
nsCOMPtr<nsILinkHandler> lh;
|
||||
nsCOMPtr<nsIInputStream> result;
|
||||
|
||||
rv = mInitContext->docShell->GetPresShell(getter_AddRefs(presShell));
|
||||
rv = mNativeBrowserControl->docShell->GetPresShell(getter_AddRefs(presShell));
|
||||
if (NS_FAILED(rv) || !presShell) {
|
||||
return (void *) rv;
|
||||
}
|
||||
@@ -280,7 +280,7 @@ wsPostEvent::handleEvent ()
|
||||
return (void *) rv;
|
||||
}
|
||||
|
||||
rv = mInitContext->docShell->GetPresContext(getter_AddRefs(presContext));
|
||||
rv = mNativeBrowserControl->docShell->GetPresContext(getter_AddRefs(presContext));
|
||||
if (NS_FAILED(rv) || !presContext) {
|
||||
return (void *) rv;
|
||||
}
|
||||
@@ -295,7 +295,6 @@ wsPostEvent::handleEvent ()
|
||||
if (!lh) {
|
||||
return (void *) rv;
|
||||
}
|
||||
*/
|
||||
|
||||
rv = presContext->GetLinkHandler(getter_AddRefs(lh));
|
||||
if (NS_FAILED(rv) || (!lh)) {
|
||||
@@ -342,10 +341,6 @@ wsPostEvent::~wsPostEvent ()
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* wsStopEvent
|
||||
*/
|
||||
|
||||
wsStopEvent::wsStopEvent(nsIWebNavigation* webNavigation) :
|
||||
nsActionEvent(),
|
||||
mWebNavigation(webNavigation)
|
||||
@@ -366,9 +361,6 @@ wsStopEvent::handleEvent ()
|
||||
|
||||
// Added by Mark Goddard OTMP 9/2/1999
|
||||
|
||||
/*
|
||||
* wsRefreshEvent
|
||||
*/
|
||||
|
||||
wsRefreshEvent::wsRefreshEvent(nsIWebNavigation* webNavigation, PRInt32 reloadType) :
|
||||
nsActionEvent(),
|
||||
@@ -408,3 +400,5 @@ wsSetPromptEvent::handleEvent ()
|
||||
}
|
||||
return nsnull;
|
||||
} // handleEvent()
|
||||
|
||||
**********************/
|
||||
|
||||
@@ -40,10 +40,10 @@
|
||||
#include "nsIURI.h"
|
||||
#include "ns_util.h"
|
||||
|
||||
struct NativeBrowserControl;
|
||||
class NativeBrowserControl;
|
||||
class InputStreamShim;
|
||||
|
||||
|
||||
/********************
|
||||
class wsLoadURLEvent : public nsActionEvent {
|
||||
public:
|
||||
wsLoadURLEvent (nsIWebNavigation* webNavigation, PRUnichar * urlString, PRInt32 urlLength);
|
||||
@@ -55,9 +55,11 @@ protected:
|
||||
nsString * mURL;
|
||||
};
|
||||
|
||||
******************/
|
||||
|
||||
class wsLoadFromStreamEvent : public nsActionEvent {
|
||||
public:
|
||||
wsLoadFromStreamEvent(NativeBrowserControl *yourInitContext,
|
||||
wsLoadFromStreamEvent(NativeBrowserControl *yourNativeBC,
|
||||
void *globalStream,
|
||||
nsString &uriToCopy,
|
||||
const char *contentTypeToCopy,
|
||||
@@ -71,17 +73,18 @@ private:
|
||||
|
||||
protected:
|
||||
|
||||
NativeBrowserControl *mInitContext;
|
||||
NativeBrowserControl *mNativeBrowserControl;
|
||||
nsString mUriString;
|
||||
char *mContentType; // MUST be delete'd in destructor
|
||||
void * mProperties; // MUST be util_deleteGlobalRef'd in destructor.
|
||||
InputStreamShim *mShim; // DO NOT delete this in the destructor
|
||||
};
|
||||
|
||||
/*****************
|
||||
|
||||
class wsPostEvent : public nsActionEvent {
|
||||
public:
|
||||
wsPostEvent(NativeBrowserControl *yourInitContext,
|
||||
wsPostEvent(NativeBrowserControl *yourNativeBC,
|
||||
nsIURI *absoluteUrl,
|
||||
const PRUnichar *targetToCopy,
|
||||
PRInt32 targetLength,
|
||||
@@ -97,7 +100,7 @@ private:
|
||||
|
||||
protected:
|
||||
|
||||
NativeBrowserControl *mInitContext;
|
||||
NativeBrowserControl *mNativeBrowserControl;
|
||||
nsCOMPtr<nsIURI> mAbsoluteURI;
|
||||
nsString *mTarget;
|
||||
const char *mPostData;
|
||||
@@ -139,7 +142,7 @@ protected:
|
||||
jobject mUserPrompt;
|
||||
};
|
||||
|
||||
|
||||
*******************/
|
||||
|
||||
#endif /* NavigationActionEvents_h___ */
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#include "nsNetCID.h"
|
||||
|
||||
#include "NativeBrowserControl.h"
|
||||
#include "NavigationActionEvents.h"
|
||||
#include "ns_util.h"
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_NavigationImpl_nativeLoadURL
|
||||
@@ -84,8 +85,6 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_Navigatio
|
||||
::util_ReleaseStringChars(env, urlString, (const jchar *) urlStringChars);
|
||||
}
|
||||
|
||||
/**********************
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_NavigationImpl_nativeLoadFromStream
|
||||
(JNIEnv *env, jobject obj, jint nativeBCPtr, jobject stream, jstring uri,
|
||||
jstring contentType, jint contentLength, jobject loadProperties)
|
||||
@@ -117,7 +116,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_Navigatio
|
||||
goto NLFS_CLEANUP;
|
||||
}
|
||||
|
||||
// the deleteGlobalRef is done in the wsLoadFromStream destructor
|
||||
// the deleteGlobalRef is done in the InputStreamShim destructor
|
||||
if (!(globalStream = ::util_NewGlobalRef(env, stream))) {
|
||||
::util_ThrowExceptionToJava(env, "Exception: nativeLoadFromStream: unable to create gloabal ref to stream");
|
||||
goto NLFS_CLEANUP;
|
||||
@@ -142,7 +141,7 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_Navigatio
|
||||
::util_ThrowExceptionToJava(env, "Exception: nativeLoadFromStream: can't create wsLoadFromStreamEvent");
|
||||
goto NLFS_CLEANUP;
|
||||
}
|
||||
::util_PostSynchronousEvent(nativeBrowserControl, (PLEvent *) *actionEvent);
|
||||
::util_PostSynchronousEvent((PLEvent *) *actionEvent);
|
||||
|
||||
NLFS_CLEANUP:
|
||||
::util_ReleaseStringChars(env, uri, (const jchar *) uriStringUniChars);
|
||||
@@ -153,6 +152,8 @@ JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_Navigatio
|
||||
// wsLoadFromStreamEvent destructor.
|
||||
}
|
||||
|
||||
/**********************
|
||||
|
||||
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_mozilla_webclient_impl_wrapper_1native_NavigationImpl_nativePost
|
||||
|
||||
@@ -57,7 +57,7 @@ const char *gSupportedListenerInterfaces[] = {
|
||||
nsnull
|
||||
};
|
||||
|
||||
void util_PostEvent(NativeBrowserControl * initContext, PLEvent * event)
|
||||
void util_PostEvent(PLEvent * event)
|
||||
{
|
||||
PL_ENTER_EVENT_QUEUE_MONITOR(NativeWrapperFactory::sActionQueue);
|
||||
|
||||
@@ -67,7 +67,7 @@ void util_PostEvent(NativeBrowserControl * initContext, PLEvent * event)
|
||||
} // PostEvent()
|
||||
|
||||
|
||||
void *util_PostSynchronousEvent(NativeWrapperFactory * initContext, PLEvent * event)
|
||||
void *util_PostSynchronousEvent(PLEvent * event)
|
||||
{
|
||||
void * voidResult = nsnull;
|
||||
|
||||
|
||||
@@ -97,15 +97,14 @@ extern const char *gSupportedListenerInterfaces[]; // defined in ns_util.cpp
|
||||
* http://lxr.mozilla.org/mozilla/source/xpcom/threads/plevent.c#248
|
||||
|
||||
* which simply uses nice monitors to insert the event into the provided
|
||||
* event queue, which is from NativeBrowserControl->actionQueue, which is
|
||||
* created in NativeEventThread.cpp:InitMozillaStuff(). The events are
|
||||
* processed in NativeEventThread.cpp:processEventLoop, which is called
|
||||
* from the Java NativeEventThread.run(). See the code and comments for
|
||||
* processEventLoop in NativeEventThread.cpp.
|
||||
* event queue, which is from NativeWrapperFactory::sActionQueue. The
|
||||
* events are processed in NativeEventThread.cpp:processEventLoop, which
|
||||
* is called from the Java NativeEventThread.run(). See the code and
|
||||
* comments for processEventLoop in NativeEventThread.cpp.
|
||||
|
||||
*/
|
||||
|
||||
void util_PostEvent (NativeBrowserControl * initContext, PLEvent * event);
|
||||
void util_PostEvent (PLEvent * event);
|
||||
|
||||
|
||||
/**
|
||||
@@ -121,7 +120,7 @@ void util_PostEvent (NativeBrowserControl * initContext, PLEvent * event);
|
||||
|
||||
*/
|
||||
|
||||
void * util_PostSynchronousEvent (NativeBrowserControl * initContext, PLEvent * event);
|
||||
void * util_PostSynchronousEvent (PLEvent * event);
|
||||
|
||||
typedef struct _wsStringStruct {
|
||||
const PRUnichar *uniStr;
|
||||
|
||||
Reference in New Issue
Block a user