To address the issue of listening for XMLHttpRequest traffic, I've taken

a cue from Doron Rosenberg in #developers and looked at the Eclipse ATF
project's XHRObserver.java.

This was my first look at java code that uses the java xpcom bridge, and
I'm very impressed.  Once I get webclient 2.0 done, I'll definately
rewrite as much as possible of the mozilla implementation using the java
xpcom bridge.  For now, I'm going to continue to crank with my
"on-demand hand coded JNI C++" approach.  I think I can get results
pretty quickly with this.  For example, just yesterday I learned that
the regular nsIWebProgressListener doesn't get notifications on Ajax
requests, and now I see a way to do it (thanks to Doron).

Here is the work in progress.

A webclient/src_moz/AjaxListener.cpp
A webclient/src_moz/AjaxListener.h
M logging.properties

- set "ALL" for MCP level

M dist/mcp-test/src/test/java/cardemo/CarDemoTest.java

- Cause an Ajax transaction to happen

M webclient/classes_spec/org/mozilla/mcp/MCP.java

- log messages for outgoing HTTP requests

M webclient/src_moz/EmbedProgress.cpp
M webclient/src_moz/EmbedProgress.h

- Leverage new AjaxListener class

M webclient/src_moz/Makefile.in

- add xmlextras, to include nsIXMLHttpRequest.


git-svn-id: svn://10.0.0.236/trunk@221474 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
edburns%acm.org
2007-03-07 21:02:54 +00:00
parent ba509eecbb
commit 2329e00781
8 changed files with 264 additions and 11 deletions

View File

@@ -37,10 +37,13 @@
#include "NativeBrowserControl.h"
#include "HttpHeaderVisitorImpl.h"
#include "AjaxListener.h"
#include "ns_globals.h" // for prLogModuleInfo
EmbedProgress::EmbedProgress(void) : mCapturePageInfo(JNI_FALSE)
EmbedProgress::EmbedProgress(void) :
mCapturePageInfo(JNI_FALSE),
mAjaxListener(nsnull)
{
mOwner = nsnull;
mEventRegistration = nsnull;
@@ -53,6 +56,7 @@ EmbedProgress::~EmbedProgress()
::util_DeleteGlobalRef(env, mEventRegistration);
mEventRegistration = nsnull;
}
RemoveAjaxListener();
}
@@ -94,6 +98,17 @@ nsresult
EmbedProgress::SetCapturePageInfo(jboolean newState)
{
mCapturePageInfo = newState;
nsresult rv = NS_OK;
AjaxListener *observer = nsnull;
rv = GetAjaxListener(&observer);
if (observer && NS_SUCCEEDED(rv)) {
if (mCapturePageInfo) {
observer->StartObserving();
}
else {
observer->StopObserving();
}
}
return NS_OK;
}
@@ -464,6 +479,32 @@ EmbedProgress::OnSecurityChange(nsIWebProgress *aWebProgress,
return NS_OK;
}
NS_IMETHODIMP
EmbedProgress::GetAjaxListener(AjaxListener* *result)
{
if (nsnull == result) {
return NS_ERROR_NULL_POINTER;
}
nsresult rv = NS_ERROR_FAILURE;
if (nsnull == mAjaxListener) {
JNIEnv *env = (JNIEnv *) JNU_GetEnv(gVm, JNI_VERSION);
mAjaxListener = new AjaxListener(this, env, mEventRegistration);
}
*result = mAjaxListener;
rv = NS_OK;
return rv;
}
NS_IMETHODIMP
EmbedProgress::RemoveAjaxListener(void)
{
nsresult rv = NS_ERROR_NOT_IMPLEMENTED;
return rv;
}
/* static */
void
EmbedProgress::RequestToURIString(nsIRequest *aRequest, char **aString)