M webclient/classes_spec/org/mozilla/webclient/impl/WrapperFactory.java
M webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/NativeEventThread.java M webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/WrapperFactoryImpl.java - cause the webclient native library to be loaded from the NativeEventThread. This eliminates many native thread safety assertions. M webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/CurrentPageImpl.java - Initialize the dom on the NativeEventThread - Get the dom on the NativeEventThread M webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/EventRegistrationImpl.java - remove unnecessary synchronized block. git-svn-id: svn://10.0.0.236/trunk@221615 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
2c0dda82d9
commit
b73d7d3c86
@ -51,6 +51,20 @@ public interface WrapperFactory {
|
|||||||
public String getProfile();
|
public String getProfile();
|
||||||
public void setProfile(String profileName);
|
public void setProfile(String profileName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* <p>This method must not be called by the developer.
|
||||||
|
*
|
||||||
|
* <p>Cause the native library to be loaded, if necessary. This method
|
||||||
|
* must be called from the native event thread.</p>
|
||||||
|
*
|
||||||
|
* <p>POSTCONDITION: Native library for webclient has been loaded.</p>
|
||||||
|
*
|
||||||
|
* @return implmentation specific native int.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public int loadNativeLibraryIfNecessary();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* <p>Cause the native library to be loaded, if necessary.</p>
|
* <p>Cause the native library to be loaded, if necessary.</p>
|
||||||
|
|||||||
@ -87,7 +87,15 @@ public CurrentPageImpl(WrapperFactory yourFactory,
|
|||||||
super(yourFactory, yourBrowserControl);
|
super(yourFactory, yourBrowserControl);
|
||||||
// force the class to be loaded, thus loading the JNI library
|
// force the class to be loaded, thus loading the JNI library
|
||||||
if (!domInitialized) {
|
if (!domInitialized) {
|
||||||
DOMAccessor.initialize();
|
NativeEventThread.instance.pushBlockingWCRunnable(new WCRunnable() {
|
||||||
|
public Object run() {
|
||||||
|
DOMAccessor.initialize();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
public String toString() {
|
||||||
|
return "WCRunnable.CurrentPageImpl ctor";
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
domDumper = new DOMTreeDumper();
|
domDumper = new DOMTreeDumper();
|
||||||
}
|
}
|
||||||
@ -295,13 +303,24 @@ public String getCurrentURL()
|
|||||||
|
|
||||||
public Document getDOM()
|
public Document getDOM()
|
||||||
{
|
{
|
||||||
// PENDING(edburns): run this on the event thread.
|
final Document[] resultHolder = new Document[1];
|
||||||
Document result = nativeGetDOM(getNativeBrowserControl());
|
resultHolder[0] = null;
|
||||||
if (LOGGER.isLoggable((Level.INFO))) {
|
NativeEventThread.instance.pushBlockingWCRunnable(new WCRunnable() {
|
||||||
LOGGER.info("CurrentPageImpl.getDOM(): getting DOM with URI: " +
|
public Object run() {
|
||||||
result.getDocumentURI());
|
Document result = nativeGetDOM(getNativeBrowserControl());
|
||||||
}
|
if (LOGGER.isLoggable((Level.INFO))) {
|
||||||
return result;
|
LOGGER.info("CurrentPageImpl.getDOM(): getting DOM with URI: " +
|
||||||
|
result.getDocumentURI());
|
||||||
|
}
|
||||||
|
resultHolder[0] = result;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
public String toString() {
|
||||||
|
return "WCRunnable.CurrentPageImpl.getDOM";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return resultHolder[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
public Properties getPageInfo()
|
public Properties getPageInfo()
|
||||||
|
|||||||
@ -263,28 +263,26 @@ public void setNewWindowListener(NewWindowListener listener)
|
|||||||
{
|
{
|
||||||
getWrapperFactory().verifyInitialized();
|
getWrapperFactory().verifyInitialized();
|
||||||
|
|
||||||
synchronized(this) {
|
final boolean doClear = null == listener;
|
||||||
final boolean doClear = null == listener;
|
NativeEventThread.instance.pushBlockingWCRunnable(new WCRunnable(){
|
||||||
NativeEventThread.instance.pushBlockingWCRunnable(new WCRunnable(){
|
public Object run() {
|
||||||
public Object run() {
|
if (doClear) {
|
||||||
if (doClear) {
|
nativeSetNewWindowListenerAttached(getNativeBrowserControl(),
|
||||||
nativeSetNewWindowListenerAttached(getNativeBrowserControl(),
|
false);
|
||||||
false);
|
}
|
||||||
}
|
else {
|
||||||
else {
|
nativeSetNewWindowListenerAttached(getNativeBrowserControl(),
|
||||||
nativeSetNewWindowListenerAttached(getNativeBrowserControl(),
|
true);
|
||||||
true);
|
}
|
||||||
}
|
return null;
|
||||||
return null;
|
}
|
||||||
}
|
public String toString() {
|
||||||
public String toString() {
|
return "WCRunnable.nativeSetNewWindowListenerAttached";
|
||||||
return "WCRunnable.nativeSetNewWindowListenerAttached";
|
}
|
||||||
}
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
newWindowListener = listener;
|
newWindowListener = listener;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -76,8 +76,7 @@ public class NativeEventThread extends Thread {
|
|||||||
//
|
//
|
||||||
|
|
||||||
public NativeEventThread(String threadName,
|
public NativeEventThread(String threadName,
|
||||||
WrapperFactory yourFactory,
|
WrapperFactory yourFactory) {
|
||||||
int yourNativeWrapperFactory) {
|
|
||||||
super(threadName);
|
super(threadName);
|
||||||
// Don't do this check for subclasses
|
// Don't do this check for subclasses
|
||||||
if (this.getClass() == NativeEventThread.class) {
|
if (this.getClass() == NativeEventThread.class) {
|
||||||
@ -86,8 +85,6 @@ public class NativeEventThread extends Thread {
|
|||||||
ParameterCheck.nonNull(yourFactory);
|
ParameterCheck.nonNull(yourFactory);
|
||||||
|
|
||||||
wrapperFactory = yourFactory;
|
wrapperFactory = yourFactory;
|
||||||
nativeWrapperFactory = yourNativeWrapperFactory;
|
|
||||||
|
|
||||||
blockingRunnables = new ConcurrentLinkedQueue<WCRunnable>();
|
blockingRunnables = new ConcurrentLinkedQueue<WCRunnable>();
|
||||||
runnables = new ConcurrentLinkedQueue<Runnable>();
|
runnables = new ConcurrentLinkedQueue<Runnable>();
|
||||||
}
|
}
|
||||||
@ -142,6 +139,8 @@ public class NativeEventThread extends Thread {
|
|||||||
|
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
|
nativeWrapperFactory = wrapperFactory.loadNativeLibraryIfNecessary();
|
||||||
|
|
||||||
// our owner must have put an event in the queue
|
// our owner must have put an event in the queue
|
||||||
Assert.assert_it(!runnables.isEmpty());
|
Assert.assert_it(!runnables.isEmpty());
|
||||||
((Runnable)runnables.poll()).run();
|
((Runnable)runnables.poll()).run();
|
||||||
|
|||||||
@ -277,22 +277,24 @@ public class WrapperFactoryImpl extends Object implements WrapperFactory {
|
|||||||
return profileName;
|
return profileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int loadNativeLibraryIfNecessary() {
|
||||||
|
System.loadLibrary("webclient");
|
||||||
|
|
||||||
|
nativeWrapperFactory = nativeCreateNativeWrapperFactory();
|
||||||
|
Assert.assert_it(-1 != nativeWrapperFactory);
|
||||||
|
return nativeWrapperFactory;
|
||||||
|
}
|
||||||
|
|
||||||
public void initialize(String verifiedBinDirAbsolutePath) throws SecurityException, UnsatisfiedLinkError {
|
public void initialize(String verifiedBinDirAbsolutePath) throws SecurityException, UnsatisfiedLinkError {
|
||||||
if (initialized) {
|
if (initialized) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
System.loadLibrary("webclient");
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Do the first initialization call
|
// Do the first initialization call
|
||||||
//
|
//
|
||||||
|
|
||||||
nativeWrapperFactory = nativeCreateNativeWrapperFactory();
|
eventThread = new NativeEventThread("WebclientEventThread", this);
|
||||||
Assert.assert_it(-1 != nativeWrapperFactory);
|
|
||||||
|
|
||||||
eventThread = new NativeEventThread("WebclientEventThread", this,
|
|
||||||
nativeWrapperFactory);
|
|
||||||
|
|
||||||
final String finalStr = new String(verifiedBinDirAbsolutePath);
|
final String finalStr = new String(verifiedBinDirAbsolutePath);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user