This checkin makes DocumentLoadListener be fully functional for the
file:/// and LoadFromStream cases. There were some problems: 1. RandomHTMLInputStream was never returning -1 from available, even when there was no more data to be read. 2. the available ivars in InputStreamShim were PRUint32, and needed to be PRInt32 to accomodate the -1. 3. InputStreamShim wasn't looking for the -1 from java, and it was incorrectly returning NS_ERROR_NOT_AVAILABLE in that case, when it should have been returning NS_OK if there was more data for Mozilla. 4. The testcase had a deadlock: it tried to remove the DocumentLoadListener from the DocumentLoadListener callback. I had to move this outside of the listener callback. M src_moz/InputStreamShim.cpp M src_moz/InputStreamShim.h - make available be a signed int. - correctly handle the case when java says, "no more data available". M test/automated/src/classes/org/mozilla/webclient/NavigationTest.java - avoid deadlock by moving the call to removeDocumentLoadListener() outside of the listener itself. M test/automated/src/classes/org/mozilla/webclient/RandomHTMLInputStream.java - make sure to return -1 from available() when we have no more data. git-svn-id: svn://10.0.0.236/trunk@157855 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -118,12 +118,14 @@ nsresult InputStreamShim::doReadFromJava()
|
||||
}
|
||||
|
||||
// if we have all our data, give the error appropriate result
|
||||
if (0 == mAvailable ||
|
||||
if (mAvailable <= 0 ||
|
||||
(0 != mCountFromJava &&
|
||||
(((PRUint32)mContentLength) == mCountFromJava))) {
|
||||
mDoClose = PR_TRUE;
|
||||
doClose();
|
||||
rv = NS_ERROR_NOT_AVAILABLE;
|
||||
rv = doClose();
|
||||
if (0 == mAvailableForMozilla) {
|
||||
rv = NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
goto DRFJ_CLEANUP;
|
||||
}
|
||||
|
||||
@@ -150,12 +152,15 @@ nsresult InputStreamShim::doReadFromJava()
|
||||
rv = NS_ERROR_FAILURE;
|
||||
goto DRFJ_CLEANUP;
|
||||
}
|
||||
if (0 == mAvailable ||
|
||||
if (mAvailable <= 0 ||
|
||||
(0 != mCountFromJava &&
|
||||
(((PRUint32)mContentLength) == mCountFromJava))) {
|
||||
mDoClose = PR_TRUE;
|
||||
doClose();
|
||||
rv = NS_ERROR_NOT_AVAILABLE;
|
||||
rv = doClose();
|
||||
if (0 == mAvailableForMozilla) {
|
||||
rv = NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
goto DRFJ_CLEANUP;
|
||||
}
|
||||
|
||||
@@ -192,7 +197,7 @@ InputStreamShim::doAvailable(void)
|
||||
if (!(mid = env->GetMethodID(streamClass, "available", "()I"))) {
|
||||
return rv;
|
||||
}
|
||||
mAvailable = (PRUint32) env->CallIntMethod(mJavaStream, mid);
|
||||
mAvailable = (PRInt32) env->CallIntMethod(mJavaStream, mid);
|
||||
if (env->ExceptionOccurred()) {
|
||||
env->ExceptionDescribe();
|
||||
env->ExceptionClear();
|
||||
@@ -462,7 +467,7 @@ InputStreamShim::ReadSegments(nsWriteSegmentFun writer, void * aClosure,
|
||||
|
||||
PR_Lock(mLock);
|
||||
|
||||
PRUint32 bytesToWrite = mAvailableForMozilla;
|
||||
PRInt32 bytesToWrite = mAvailableForMozilla;
|
||||
PRUint32 bytesWritten;
|
||||
PRUint32 totalBytesWritten = 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user