This checkin extracts the thread coordination mechanism used within

webclient into an internal contract so it can be used by dom.

M dom/classes/org/mozilla/dom/DOMAccessor.java

- use RunnableRunner and ReturnRunnable to do internal thread
  coordination.

M webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/BookmarksImpl.java
M webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/CocoaBrowserControlCanvas.java
M webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/CurrentPageImpl.java
M webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/EventRegistrationImpl.java
M webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/GtkBrowserControlCanvas.java
M webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/HistoryImpl.java
M webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/NavigationImpl.java
M webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/PreferencesImpl.java
M webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/ProfileManagerImpl.java
M webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/RDFEnumeration.java
M webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/Win32BrowserControlCanvas.java
M webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/WindowControlImpl.java
M webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/WrapperFactoryImpl.java

- Refactor to rename WCRunnable to ReturnRunnable.

M webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/NativeEventThread.java
A util/classes/org/mozilla/util/ReturnRunnable.java

- Implement new RunnableRunner interface.

R webclient/classes_spec/org/mozilla/webclient/impl/wrapper_native/WCRunnable.java
A util/classes/org/mozilla/util/RunnableRunner.java

- moved class
This commit is contained in:
edburns%acm.org 2007-03-12 20:39:22 +00:00
Родитель 0c593ed48d
Коммит 9da9485c2d
18 изменённых файлов: 235 добавлений и 70 удалений

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

@ -80,22 +80,72 @@ package org.mozilla.dom;
import java.util.Vector;
import java.util.Enumeration;
import org.mozilla.util.ReturnRunnable;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import java.security.AccessController;
import org.mozilla.util.RunnableRunner;
public final class DOMAccessor {
private static final String JAVADOM_LOADED_PROPERTY_NAME =
"org.mozilla.webclient.impl.wrapper_native.javadomjni.loaded";
private static RunnableRunner runnableRunner = null;
private static Vector documentLoadListeners = new Vector();
private static JavaDOMPermission permission = new JavaDOMPermission("JavaDOM");
static {
System.loadLibrary("javadomjni");
private static boolean isNativeLibraryLoaded = false;
private static boolean isNativeLibraryLoadedPropertySet = false;
public static boolean isNativeLibraryLoaded() {
if (isNativeLibraryLoadedPropertySet) {
return isNativeLibraryLoaded;
}
boolean result = false;
String propValue = System.getProperty(JAVADOM_LOADED_PROPERTY_NAME);
if (null != propValue) {
try {
result = Boolean.valueOf(propValue).booleanValue();
}
catch (Exception e) {
result = isNativeLibraryLoaded;
}
}
else {
result = isNativeLibraryLoaded;
}
return result;
}
public static void setNativeLibraryLoaded(boolean newState) {
isNativeLibraryLoaded = newState;
isNativeLibraryLoadedPropertySet = true;
}
private void DOMAccessorImpl() {}
static {
if (!isNativeLibraryLoaded()) {
System.loadLibrary("javadomjni");
setNativeLibraryLoaded(true);
}
}
private void DOMAccessorImpl() {
if (null == runnableRunner) {
runnableRunner = new SameThreadRunnableRunner();
}
}
public static void setRunner(RunnableRunner runner) {
runnableRunner = runner;
}
public static RunnableRunner getRunner() {
return runnableRunner;
}
private static void register() {
nativeRegister();
@ -218,4 +268,20 @@ public final class DOMAccessor {
}
doGC();
}
}
class SameThreadRunnableRunner implements RunnableRunner {
SameThreadRunnableRunner() {}
public void pushRunnable(Runnable toInvoke) {
toInvoke.run();
}
public Object pushBlockingReturnRunnable(ReturnRunnable toInvoke) throws RuntimeException {
toInvoke.run();
return toInvoke.getResult();
}
}

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

@ -0,0 +1,47 @@
/*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is RaptorCanvas.
*
* The Initial Developer of the Original Code is Kirk Baker and
* Ian Wilkinson. Portions created by Kirk Baker and Ian Wilkinson are
* Copyright (C) 1999 Kirk Baker and Ian Wilkinson. All
* Rights Reserved.
*
* Contributor(s): Ed Burns <edburns@acm.org>
* Ashutosh Kulkarni <ashuk@eng.sun.com>
* Jason Mawdsley <jason@macadamian.com>
* Louis-Philippe Gagnon <louisphilippe@macadamian.com>
*/
package org.mozilla.util;
/**
* <p>Extend the concept of <code>java.lang.Runnable</code> to allow for
* the thing to have a return Object.</p>
*
*/
public abstract class ReturnRunnable {
public abstract Object run();
private Object result = null;
public Object getResult() {
return result;
}
public void setResult(Object result) {
this.result = result;
}
}

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

@ -0,0 +1,26 @@
/*
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is RaptorCanvas.
*
* Contributor(s): Ed Burns <edburns@acm.org>
*/
package org.mozilla.util;
/**
*
* @author edburns
*/
public interface RunnableRunner {
Object pushBlockingReturnRunnable(ReturnRunnable toInvoke) throws RuntimeException;
void pushRunnable(Runnable toInvoke);
}

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

@ -26,6 +26,7 @@ package org.mozilla.webclient.impl.wrapper_native;
import org.mozilla.util.Assert;
import org.mozilla.util.Log;
import org.mozilla.util.ParameterCheck;
import org.mozilla.util.ReturnRunnable;
import org.mozilla.webclient.Bookmarks;
import org.mozilla.webclient.BookmarkEntry;
@ -155,7 +156,7 @@ public TreeModel getBookmarks() throws IllegalStateException
if (null == bookmarksTree) {
TreeNode root;
Integer nativeBookmarks = (Integer)
NativeEventThread.instance.pushBlockingWCRunnable(new WCRunnable() {
NativeEventThread.instance.pushBlockingReturnRunnable(new ReturnRunnable() {
public Object run() {
Integer result =
new Integer(nativeGetBookmarks(getWrapperFactory().
@ -199,7 +200,7 @@ public BookmarkEntry newBookmarkEntry(String url)
final String finalUrl = new String(url);
getBookmarks();
Integer newNode = (Integer)
NativeEventThread.instance.pushBlockingWCRunnable(new WCRunnable() {
NativeEventThread.instance.pushBlockingReturnRunnable(new ReturnRunnable() {
public Object run() {
Integer result =
new Integer(nativeNewRDFNode(getNativeBrowserControl(),

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

@ -28,7 +28,7 @@ package org.mozilla.webclient.impl.wrapper_native;
import org.mozilla.webclient.BrowserControlCanvas;
import org.mozilla.webclient.impl.wrapper_native.WCRunnable;
import org.mozilla.util.ReturnRunnable;
import org.mozilla.webclient.impl.wrapper_native.NativeEventThread;
import java.awt.*;
@ -55,7 +55,7 @@ public class CocoaBrowserControlCanvas extends BrowserControlCanvas {
*/
protected int getWindow() {
Integer result = (Integer)
NativeEventThread.instance.pushBlockingWCRunnable(new WCRunnable(){
NativeEventThread.instance.pushBlockingReturnRunnable(new ReturnRunnable(){
public Object run() {
Integer result =
new Integer(CocoaBrowserControlCanvas.this.getHandleToPeer());

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

@ -29,6 +29,7 @@ import java.awt.datatransfer.StringSelection;
import java.awt.datatransfer.Transferable;
import org.mozilla.util.Assert;
import org.mozilla.util.ParameterCheck;
import org.mozilla.util.ReturnRunnable;
import org.mozilla.webclient.BrowserControl;
import org.mozilla.webclient.CurrentPage2;
@ -87,7 +88,7 @@ public CurrentPageImpl(WrapperFactory yourFactory,
super(yourFactory, yourBrowserControl);
// force the class to be loaded, thus loading the JNI library
if (!domInitialized) {
NativeEventThread.instance.pushBlockingWCRunnable(new WCRunnable() {
NativeEventThread.instance.pushBlockingReturnRunnable(new ReturnRunnable() {
public Object run() {
DOMAccessor.initialize();
return null;
@ -118,7 +119,7 @@ public void copyCurrentSelectionToSystemClipboard()
Assert.assert_it(-1 != getNativeBrowserControl());
plainTextSelection = null;
NativeEventThread.instance.pushBlockingWCRunnable(new WCRunnable() {
NativeEventThread.instance.pushBlockingReturnRunnable(new ReturnRunnable() {
public Object run() {
nativeCopyCurrentSelectionToSystemClipboard(CurrentPageImpl.this.getNativeBrowserControl());
return null;
@ -155,7 +156,7 @@ public void copyCurrentSelectionHtmlToSystemClipboard()
Assert.assert_it(-1 != getNativeBrowserControl());
htmlSelection = null;
NativeEventThread.instance.pushBlockingWCRunnable(new WCRunnable() {
NativeEventThread.instance.pushBlockingReturnRunnable(new ReturnRunnable() {
public Object run() {
nativeCopyCurrentSelectionToSystemClipboard(CurrentPageImpl.this.getNativeBrowserControl());
return null;
@ -190,7 +191,7 @@ public Selection getSelection() {
getWrapperFactory().verifyInitialized();
final Selection selection = new SelectionImpl();
NativeEventThread.instance.pushBlockingWCRunnable(new WCRunnable() {
NativeEventThread.instance.pushBlockingReturnRunnable(new ReturnRunnable() {
public Object run() {
nativeGetSelection(CurrentPageImpl.this.getNativeBrowserControl(),
selection);
@ -212,7 +213,7 @@ public void highlightSelection(Selection selection) {
final int startOffset = selection.getStartOffset();
final int endOffset = selection.getEndOffset();
NativeEventThread.instance.pushBlockingWCRunnable(new WCRunnable() {
NativeEventThread.instance.pushBlockingReturnRunnable(new ReturnRunnable() {
public Object run() {
nativeHighlightSelection(CurrentPageImpl.this.getNativeBrowserControl(),
startContainer, endContainer,
@ -228,7 +229,7 @@ public void highlightSelection(Selection selection) {
}
public void clearAllSelections() {
NativeEventThread.instance.pushBlockingWCRunnable(new WCRunnable() {
NativeEventThread.instance.pushBlockingReturnRunnable(new ReturnRunnable() {
public Object run() {
nativeClearAllSelections(CurrentPageImpl.this.getNativeBrowserControl());
return null;
@ -253,7 +254,7 @@ public boolean find(String toFind, boolean dir, boolean doCase)
Boolean result = Boolean.FALSE;
result = (Boolean)
NativeEventThread.instance.pushBlockingWCRunnable(new WCRunnable(){
NativeEventThread.instance.pushBlockingReturnRunnable(new ReturnRunnable(){
public Object run() {
boolean rc = nativeFind(CurrentPageImpl.this.getNativeBrowserControl(),
stringToFind, forward, matchCase);
@ -277,7 +278,7 @@ public boolean findNext()
Boolean result = Boolean.FALSE;
result = (Boolean)
NativeEventThread.instance.pushBlockingWCRunnable(new WCRunnable(){
NativeEventThread.instance.pushBlockingReturnRunnable(new ReturnRunnable(){
public Object run() {
boolean rc = nativeFindNext(CurrentPageImpl.this.getNativeBrowserControl());
return rc ? Boolean.TRUE : Boolean.FALSE;
@ -305,7 +306,7 @@ public Document getDOM()
{
final Document[] resultHolder = new Document[1];
resultHolder[0] = null;
NativeEventThread.instance.pushBlockingWCRunnable(new WCRunnable() {
NativeEventThread.instance.pushBlockingReturnRunnable(new ReturnRunnable() {
public Object run() {
Document result = nativeGetDOM(getNativeBrowserControl());
if (LOGGER.isLoggable((Level.INFO))) {
@ -345,7 +346,7 @@ public String getSource()
String HTMLContent = null;
final Selection selection = new SelectionImpl();
NativeEventThread.instance.pushBlockingWCRunnable(new WCRunnable() {
NativeEventThread.instance.pushBlockingReturnRunnable(new ReturnRunnable() {
public Object run() {
nativeGetSource(CurrentPageImpl.this.getNativeBrowserControl(),
selection);
@ -385,7 +386,7 @@ public void resetFind()
public void selectAll() {
getWrapperFactory().verifyInitialized();
NativeEventThread.instance.pushBlockingWCRunnable(new WCRunnable() {
NativeEventThread.instance.pushBlockingReturnRunnable(new ReturnRunnable() {
public Object run() {
nativeSelectAll(CurrentPageImpl.this.getNativeBrowserControl());
return null;

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

@ -39,6 +39,7 @@ import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.Component;
import org.mozilla.dom.DOMAccessor;
import org.mozilla.util.ReturnRunnable;
import org.mozilla.webclient.BrowserControl;
import org.mozilla.webclient.BrowserControlCanvas;
@ -154,7 +155,7 @@ public void addDocumentLoadListener(DocumentLoadListener listener)
synchronized(documentLoadListeners) {
if (listener instanceof PageInfoListener) {
NativeEventThread.instance.pushBlockingWCRunnable(new WCRunnable(){
NativeEventThread.instance.pushBlockingReturnRunnable(new ReturnRunnable(){
public Object run() {
nativeSetCapturePageInfo(getNativeBrowserControl(),
true);
@ -186,7 +187,7 @@ public void removeDocumentLoadListener(DocumentLoadListener listener)
documentLoadListeners.remove(listener);
if (0 == documentLoadListeners.size()) {
NativeEventThread.instance.pushBlockingWCRunnable(new WCRunnable(){
NativeEventThread.instance.pushBlockingReturnRunnable(new ReturnRunnable(){
public Object run() {
nativeSetCapturePageInfo(getNativeBrowserControl(),
false);
@ -264,7 +265,7 @@ public void setNewWindowListener(NewWindowListener listener)
getWrapperFactory().verifyInitialized();
final boolean doClear = null == listener;
NativeEventThread.instance.pushBlockingWCRunnable(new WCRunnable(){
NativeEventThread.instance.pushBlockingReturnRunnable(new ReturnRunnable(){
public Object run() {
if (doClear) {
nativeSetNewWindowListenerAttached(getNativeBrowserControl(),

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

@ -25,6 +25,7 @@ package org.mozilla.webclient.impl.wrapper_native;
import org.mozilla.util.Assert;
import org.mozilla.util.Log;
import org.mozilla.util.ParameterCheck;
import org.mozilla.util.ReturnRunnable;
import org.mozilla.webclient.BrowserControlCanvas;
@ -41,7 +42,7 @@ import java.awt.Dimension;
* There is one instance of GtkBrowserControlCanvas per top level awt Frame.
* @version $Id: GtkBrowserControlCanvas.java,v 1.2 2005-11-25 08:16:32 timeless%mozdev.org Exp $
* @version $Id: GtkBrowserControlCanvas.java,v 1.3 2007-03-12 20:39:22 edburns%acm.org Exp $
*
* @see org.mozilla.webclient.BrowserControlCanvasFactory
*
@ -87,7 +88,7 @@ public class GtkBrowserControlCanvas extends BrowserControlCanvas /* implements
//Use the AWT Native Peer interface to get the handle
//of this Canvas's native peer
Integer canvasWin = (Integer)
NativeEventThread.instance.pushBlockingWCRunnable(new WCRunnable() {
NativeEventThread.instance.pushBlockingReturnRunnable(new ReturnRunnable() {
public Object run() {
Integer result =
new Integer(GtkBrowserControlCanvas.this.getHandleToPeer());
@ -97,7 +98,7 @@ public class GtkBrowserControlCanvas extends BrowserControlCanvas /* implements
canvasWinID = canvasWin.intValue();
//Set our canvas as a parent of the top-level gtk widget
//which contains Mozilla.
NativeEventThread.instance.pushBlockingWCRunnable(new WCRunnable() {
NativeEventThread.instance.pushBlockingReturnRunnable(new ReturnRunnable() {
public Object run() {
GtkBrowserControlCanvas.this.reparentWindow(GtkBrowserControlCanvas.this.gtkWinID, GtkBrowserControlCanvas.this.canvasWinID);
return null;
@ -114,7 +115,7 @@ public class GtkBrowserControlCanvas extends BrowserControlCanvas /* implements
final int finalHeight = height;
synchronized(getTreeLock()) {
NativeEventThread.instance.pushBlockingWCRunnable(new WCRunnable() {
NativeEventThread.instance.pushBlockingReturnRunnable(new ReturnRunnable() {
public Object run() {
GtkBrowserControlCanvas.this.setGTKWindowSize(GtkBrowserControlCanvas.this.gtkTopWindow,
finalWidth, finalHeight);
@ -141,7 +142,7 @@ public class GtkBrowserControlCanvas extends BrowserControlCanvas /* implements
protected int getWindow() {
synchronized(getTreeLock()) {
Integer topWindow = (Integer)
NativeEventThread.instance.pushBlockingWCRunnable(new WCRunnable() {
NativeEventThread.instance.pushBlockingReturnRunnable(new ReturnRunnable() {
public Object run() {
Integer result =
new Integer(GtkBrowserControlCanvas.this.createTopLevelWindow());
@ -152,7 +153,7 @@ public class GtkBrowserControlCanvas extends BrowserControlCanvas /* implements
final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Integer winPtr = (Integer)
NativeEventThread.instance.pushBlockingWCRunnable(new WCRunnable() {
NativeEventThread.instance.pushBlockingReturnRunnable(new ReturnRunnable() {
public Object run() {
Integer result =
new Integer(GtkBrowserControlCanvas.this.createContainerWindow(GtkBrowserControlCanvas.this.gtkTopWindow, screenSize.width, screenSize.height));
@ -162,7 +163,7 @@ public class GtkBrowserControlCanvas extends BrowserControlCanvas /* implements
this.gtkWinPtr = winPtr.intValue();
Integer winId = (Integer)
NativeEventThread.instance.pushBlockingWCRunnable(new WCRunnable() {
NativeEventThread.instance.pushBlockingReturnRunnable(new ReturnRunnable() {
public Object run() {
Integer result = new Integer(GtkBrowserControlCanvas.this.getGTKWinID(GtkBrowserControlCanvas.this.gtkWinPtr));
return result;

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

@ -25,6 +25,7 @@ package org.mozilla.webclient.impl.wrapper_native;
import org.mozilla.util.Assert;
import org.mozilla.util.Log;
import org.mozilla.util.ParameterCheck;
import org.mozilla.util.ReturnRunnable;
import org.mozilla.webclient.BrowserControl;
import org.mozilla.webclient.History;
@ -79,7 +80,7 @@ public void back()
getWrapperFactory().verifyInitialized();
Assert.assert_it(-1 != getNativeBrowserControl());
NativeEventThread.instance.pushBlockingWCRunnable(new WCRunnable() {
NativeEventThread.instance.pushBlockingReturnRunnable(new ReturnRunnable() {
public Object run() {
nativeBack(getNativeBrowserControl());
return null;
@ -97,7 +98,7 @@ public boolean canBack()
Assert.assert_it(-1 != getNativeBrowserControl());
Boolean result = (Boolean)
NativeEventThread.instance.pushBlockingWCRunnable(new WCRunnable() {
NativeEventThread.instance.pushBlockingReturnRunnable(new ReturnRunnable() {
public Object run() {
boolean canBack = nativeCanBack(getNativeBrowserControl());
return new Boolean(canBack);
@ -144,7 +145,7 @@ public void forward()
getWrapperFactory().verifyInitialized();
Assert.assert_it(-1 != getNativeBrowserControl());
NativeEventThread.instance.pushBlockingWCRunnable(new WCRunnable() {
NativeEventThread.instance.pushBlockingReturnRunnable(new ReturnRunnable() {
public Object run() {
nativeForward(getNativeBrowserControl());
return null;
@ -162,7 +163,7 @@ public boolean canForward()
Assert.assert_it(-1 != getNativeBrowserControl());
Boolean result = (Boolean)
NativeEventThread.instance.pushBlockingWCRunnable(new WCRunnable() {
NativeEventThread.instance.pushBlockingReturnRunnable(new ReturnRunnable() {
public Object run() {
boolean canForward = nativeCanForward(getNativeBrowserControl());
return new Boolean(canForward);

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

@ -31,6 +31,8 @@ import java.util.logging.Logger;
import org.mozilla.util.Assert;
import org.mozilla.util.Log;
import org.mozilla.util.ParameterCheck;
import org.mozilla.util.ReturnRunnable;
import org.mozilla.util.RunnableRunner;
import org.mozilla.webclient.impl.WrapperFactory;
@ -40,7 +42,7 @@ import org.mozilla.webclient.impl.WrapperFactory;
* methods.</p>
*/
public class NativeEventThread extends Thread {
public class NativeEventThread extends Thread implements RunnableRunner {
//
// Class variables
@ -63,7 +65,7 @@ public class NativeEventThread extends Thread {
private WrapperFactory wrapperFactory;
private int nativeWrapperFactory;
private Queue<WCRunnable> blockingRunnables;
private Queue<ReturnRunnable> blockingRunnables;
private Queue<Runnable> runnables;
@ -85,7 +87,7 @@ public class NativeEventThread extends Thread {
ParameterCheck.nonNull(yourFactory);
wrapperFactory = yourFactory;
blockingRunnables = new ConcurrentLinkedQueue<WCRunnable>();
blockingRunnables = new ConcurrentLinkedQueue<ReturnRunnable>();
runnables = new ConcurrentLinkedQueue<Runnable>();
}
@ -162,7 +164,7 @@ public void run()
}
public void runUntilEventOfType(Class wcRunnableClass) {
WCRunnable result = null;
ReturnRunnable result = null;
while (doEventLoopOnce(wcRunnableClass)) {
}
}
@ -173,7 +175,7 @@ public void runUntilEventOfType(Class wcRunnableClass) {
private boolean doEventLoopOnce(Class... wcRunnableClass) {
Runnable runnable;
WCRunnable wcRunnable;
ReturnRunnable wcRunnable;
boolean result = true;
try {
Thread.sleep(1);
@ -252,13 +254,13 @@ public void runUntilEventOfType(Class wcRunnableClass) {
// Package methods
//
void pushRunnable(Runnable toInvoke) {
public void pushRunnable(Runnable toInvoke) {
synchronized (this) {
runnables.add(toInvoke);
}
}
Object pushBlockingWCRunnable(WCRunnable toInvoke) throws RuntimeException {
public Object pushBlockingReturnRunnable(ReturnRunnable toInvoke) throws RuntimeException {
Object result = null;
if (Thread.currentThread().getName().equals(instance.getName())){

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

@ -27,6 +27,7 @@ import org.mozilla.util.Assert;
import org.mozilla.util.Log;
import org.mozilla.util.ParameterCheck;
import org.mozilla.util.RangeException;
import org.mozilla.util.ReturnRunnable;
import org.mozilla.webclient.BrowserControl;
import org.mozilla.webclient.Navigation;
@ -136,7 +137,7 @@ public void refresh(long loadFlags)
final long finalLoadFlags = loadFlags;
Assert.assert_it(-1 != getNativeBrowserControl());
NativeEventThread.instance.pushBlockingWCRunnable(new WCRunnable() {
NativeEventThread.instance.pushBlockingReturnRunnable(new ReturnRunnable() {
public Object run() {
nativeRefresh(NavigationImpl.this.getNativeBrowserControl(),
finalLoadFlags);
@ -154,7 +155,7 @@ public void stop()
getWrapperFactory().verifyInitialized();
Assert.assert_it(-1 != getNativeBrowserControl());
NativeEventThread.instance.pushBlockingWCRunnable(new WCRunnable() {
NativeEventThread.instance.pushBlockingReturnRunnable(new ReturnRunnable() {
public Object run() {
nativeStop(getNativeBrowserControl());
return null;
@ -275,7 +276,7 @@ public static void main(String [] args)
Log.setApplicationName("NavigationImpl");
Log.setApplicationVersion("0.0");
Log.setApplicationVersionDate("$Id: NavigationImpl.java,v 1.12 2007-01-17 11:43:43 edburns%acm.org Exp $");
Log.setApplicationVersionDate("$Id: NavigationImpl.java,v 1.13 2007-03-12 20:39:22 edburns%acm.org Exp $");
try {
org.mozilla.webclient.BrowserControlFactory.setAppData(args[0]);

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

@ -24,6 +24,7 @@ package org.mozilla.webclient.impl.wrapper_native;
import org.mozilla.util.Assert;
import org.mozilla.util.Log;
import org.mozilla.util.ParameterCheck;
import org.mozilla.util.ReturnRunnable;
import org.mozilla.webclient.impl.WrapperFactory;
import org.mozilla.webclient.impl.Service;
@ -109,7 +110,7 @@ public void setPref(String prefName, String prefValue)
// determine the type of pref value: String, boolean, integer
try {
final Integer intVal = Integer.valueOf(prefValue);
NativeEventThread.instance.pushBlockingWCRunnable(new WCRunnable() {
NativeEventThread.instance.pushBlockingReturnRunnable(new ReturnRunnable() {
public Object run() {
nativeSetIntPref(getWrapperFactory().getNativeWrapperFactory(), finalName, intVal.intValue());
return null;
@ -124,7 +125,7 @@ public void setPref(String prefName, String prefValue)
if (null != prefValue &&
(prefValue.equals("true") || prefValue.equals("false"))) {
final Boolean boolVal = Boolean.valueOf(prefValue);
NativeEventThread.instance.pushBlockingWCRunnable(new WCRunnable(){
NativeEventThread.instance.pushBlockingReturnRunnable(new ReturnRunnable(){
public Object run() {
nativeSetBoolPref(getWrapperFactory().getNativeWrapperFactory(),
finalName, boolVal.booleanValue());
@ -140,7 +141,7 @@ public void setPref(String prefName, String prefValue)
// it must be a string
final String finalValue = (null != prefValue) ?
new String(prefValue) : null;
NativeEventThread.instance.pushBlockingWCRunnable(new WCRunnable(){
NativeEventThread.instance.pushBlockingReturnRunnable(new ReturnRunnable(){
public Object run() {
nativeSetUnicharPref(getWrapperFactory().getNativeWrapperFactory(), finalName, finalValue);
return null;
@ -157,7 +158,7 @@ public void setPref(String prefName, String prefValue)
public Properties getPrefs()
{
props = (Properties)
NativeEventThread.instance.pushBlockingWCRunnable(new WCRunnable() {
NativeEventThread.instance.pushBlockingReturnRunnable(new ReturnRunnable() {
public Object run() {
Properties result =
nativeGetPrefs(getWrapperFactory().getNativeWrapperFactory(),

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

@ -26,6 +26,7 @@ package org.mozilla.webclient.impl.wrapper_native;
import org.mozilla.util.Assert;
import org.mozilla.util.Log;
import org.mozilla.util.ParameterCheck;
import org.mozilla.util.ReturnRunnable;
import org.mozilla.webclient.ProfileManager;
import org.mozilla.webclient.impl.WrapperFactory;
@ -59,7 +60,7 @@ public void shutdown() {
public int getProfileCount()
{
Integer result = (Integer)
NativeEventThread.instance.pushBlockingWCRunnable(new WCRunnable() {
NativeEventThread.instance.pushBlockingReturnRunnable(new ReturnRunnable() {
public Object run() {
Integer count = new Integer(nativeGetProfileCount(getWrapperFactory().getNativeWrapperFactory()));
return count;
@ -71,7 +72,7 @@ public int getProfileCount()
public String [] getProfileList()
{
String [] list =
(String []) NativeEventThread.instance.pushBlockingWCRunnable(new WCRunnable() {
(String []) NativeEventThread.instance.pushBlockingReturnRunnable(new ReturnRunnable() {
public Object run() {
Object result = nativeGetProfileList(getWrapperFactory().getNativeWrapperFactory());
return result;
@ -84,7 +85,7 @@ public boolean profileExists(String profileName)
{
ParameterCheck.nonNull(profileName);
final String finalStr = new String(profileName);
Boolean exists = (Boolean) NativeEventThread.instance.pushBlockingWCRunnable(new WCRunnable() {
Boolean exists = (Boolean) NativeEventThread.instance.pushBlockingReturnRunnable(new ReturnRunnable() {
public Object run() {
Boolean result = new Boolean(nativeProfileExists(getWrapperFactory().getNativeWrapperFactory(),
finalStr));
@ -97,7 +98,7 @@ public boolean profileExists(String profileName)
public String getCurrentProfile()
{
String currProfile = (String)
NativeEventThread.instance.pushBlockingWCRunnable(new WCRunnable() {
NativeEventThread.instance.pushBlockingReturnRunnable(new ReturnRunnable() {
public Object run() {
Object result = nativeGetCurrentProfile(getWrapperFactory().getNativeWrapperFactory());
return result;
@ -110,7 +111,7 @@ public void setCurrentProfile(String profileName)
{
ParameterCheck.nonNull(profileName);
final String finalStr = new String(profileName);
NativeEventThread.instance.pushBlockingWCRunnable(new WCRunnable() {
NativeEventThread.instance.pushBlockingReturnRunnable(new ReturnRunnable() {
public Object run() {
nativeSetCurrentProfile(getWrapperFactory().getNativeWrapperFactory(),
finalStr);
@ -131,7 +132,7 @@ public void createNewProfile(String profileName,
final String finalLangcode = (null != langcode) ?
new String(langcode) : null;
final boolean finalExistingDir = useExistingDir;
NativeEventThread.instance.pushBlockingWCRunnable(new WCRunnable() {
NativeEventThread.instance.pushBlockingReturnRunnable(new ReturnRunnable() {
public Object run() {
nativeCreateNewProfile(getWrapperFactory().getNativeWrapperFactory(),
finalProfileName, finalProfileDir,
@ -147,7 +148,7 @@ public void renameProfile(String currName, String newName)
ParameterCheck.nonNull(newName);
final String finalCurrName = new String(currName);
final String finalNewName = new String(newName);
NativeEventThread.instance.pushBlockingWCRunnable(new WCRunnable() {
NativeEventThread.instance.pushBlockingReturnRunnable(new ReturnRunnable() {
public Object run() {
nativeRenameProfile(getWrapperFactory().getNativeWrapperFactory(),
finalCurrName, finalNewName);
@ -161,7 +162,7 @@ public void deleteProfile(String profileName, boolean canDeleteFiles)
ParameterCheck.nonNull(profileName);
final String finalProfileName = new String(profileName);
final boolean finalCanDeleteFiles = canDeleteFiles;
NativeEventThread.instance.pushBlockingWCRunnable(new WCRunnable() {
NativeEventThread.instance.pushBlockingReturnRunnable(new ReturnRunnable() {
public Object run() {
nativeDeleteProfile(getWrapperFactory().getNativeWrapperFactory(),
finalProfileName, finalCanDeleteFiles);

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

@ -26,6 +26,7 @@ import org.mozilla.util.Log;
import org.mozilla.util.ParameterCheck;
import java.util.Enumeration;
import org.mozilla.util.ReturnRunnable;
public class RDFEnumeration extends Object implements Enumeration
{
@ -102,7 +103,7 @@ public RDFEnumeration(int yourNativeContext,
protected void finalize() throws Throwable
{
NativeEventThread.instance.pushBlockingWCRunnable(new WCRunnable() {
NativeEventThread.instance.pushBlockingReturnRunnable(new ReturnRunnable() {
public Object run() {
nativeFinalize(RDFEnumeration.this.nativeContext);
return null;
@ -123,7 +124,7 @@ public boolean hasMoreElements()
{
Assert.assert_it(-1 != nativeRDFNode);
Boolean result = (Boolean)
NativeEventThread.instance.pushBlockingWCRunnable(new WCRunnable() {
NativeEventThread.instance.pushBlockingReturnRunnable(new ReturnRunnable() {
public Object run() {
Boolean result =
new Boolean(nativeHasMoreElements(RDFEnumeration.this.nativeContext,
@ -143,7 +144,7 @@ public Object nextElement()
Assert.assert_it(null != parent);
Object result = null;
Integer nextNativeRDFNode = (Integer)
NativeEventThread.instance.pushBlockingWCRunnable(new WCRunnable() {
NativeEventThread.instance.pushBlockingReturnRunnable(new ReturnRunnable() {
public Object run() {
Integer result =
new Integer(nativeNextElement(RDFEnumeration.this.nativeContext,

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

@ -27,7 +27,7 @@ import org.mozilla.util.Assert;
import org.mozilla.util.Log;
import org.mozilla.util.ParameterCheck;
import org.mozilla.webclient.impl.wrapper_native.WCRunnable;
import org.mozilla.util.ReturnRunnable;
import org.mozilla.webclient.impl.wrapper_native.NativeEventThread;
/**
@ -39,7 +39,7 @@ import org.mozilla.webclient.impl.wrapper_native.NativeEventThread;
* There is one instance of the BrowserControlCanvas per top level awt Frame.
* @version $Id: Win32BrowserControlCanvas.java,v 1.2 2007-01-17 11:43:43 edburns%acm.org Exp $
* @version $Id: Win32BrowserControlCanvas.java,v 1.3 2007-03-12 20:39:22 edburns%acm.org Exp $
*
* @see org.mozilla.webclient.BrowserControlCanvasFactory
*
@ -68,7 +68,7 @@ public class Win32BrowserControlCanvas extends BrowserControlCanvas {
*/
protected int getWindow() {
Integer result = (Integer)
NativeEventThread.instance.pushBlockingWCRunnable(new WCRunnable(){
NativeEventThread.instance.pushBlockingReturnRunnable(new ReturnRunnable(){
public Object run() {
Integer result =
new Integer(Win32BrowserControlCanvas.this.getHandleToPeer());

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

@ -24,6 +24,7 @@ package org.mozilla.webclient.impl.wrapper_native;
import org.mozilla.util.Assert;
import org.mozilla.util.Log;
import org.mozilla.util.ParameterCheck;
import org.mozilla.util.ReturnRunnable;
import org.mozilla.webclient.BrowserControl;
import org.mozilla.webclient.WindowControl;
@ -84,7 +85,7 @@ public void setBounds(Rectangle rect)
getWrapperFactory().verifyInitialized();
Assert.assert_it(-1 != getNativeBrowserControl());
final Rectangle newBounds = rect;
NativeEventThread.instance.pushBlockingWCRunnable(new WCRunnable() {
NativeEventThread.instance.pushBlockingReturnRunnable(new ReturnRunnable() {
public Object run() {
nativeSetBounds(getNativeBrowserControl(),
newBounds.x, newBounds.y,
@ -111,7 +112,7 @@ public void createWindow(int nativeWindow, Rectangle rect)
final int finalWidth = rect.width;
final int finalHeight = rect.height;
NativeEventThread.instance.pushBlockingWCRunnable(new NativeRealizeWCRunnable(nativeWin,
NativeEventThread.instance.pushBlockingReturnRunnable(new NativeRealizeWCRunnable(nativeWin,
nativeBc, rect, bc));
}
@ -152,7 +153,7 @@ public void setVisible(boolean newState)
{
getWrapperFactory().verifyInitialized();
final boolean finalBool = newState;
NativeEventThread.instance.pushBlockingWCRunnable(new WCRunnable() {
NativeEventThread.instance.pushBlockingReturnRunnable(new ReturnRunnable() {
public Object run() {
nativeSetVisible(getNativeBrowserControl(), finalBool);
return null;
@ -171,7 +172,7 @@ public void setFocus()
throw new UnimplementedException("\nUnimplementedException -----\n API Function WindowControl::setFocus has not yet been implemented.\n");
}
public class NativeRealizeWCRunnable extends WCRunnable {
public class NativeRealizeWCRunnable extends ReturnRunnable {
final private int nativeWin;
final private int nativeBc;
@ -235,7 +236,7 @@ public static void main(String [] args)
Log.setApplicationName("WindowControlImpl");
Log.setApplicationVersion("0.0");
Log.setApplicationVersionDate("$Id: WindowControlImpl.java,v 1.7 2007-01-22 12:35:14 edburns%acm.org Exp $");
Log.setApplicationVersionDate("$Id: WindowControlImpl.java,v 1.8 2007-03-12 20:39:22 edburns%acm.org Exp $");
try {
org.mozilla.webclient.BrowserControlFactory.setAppData(args[0]);

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

@ -24,6 +24,7 @@ package org.mozilla.webclient.impl.wrapper_native;
import org.mozilla.util.Assert;
import org.mozilla.util.Log;
import org.mozilla.util.ParameterCheck;
import org.mozilla.util.ReturnRunnable;
import org.mozilla.webclient.BrowserControl;
import org.mozilla.webclient.BrowserControlCanvas;
@ -36,6 +37,8 @@ import org.mozilla.webclient.ImplObject;
import org.mozilla.webclient.impl.WrapperFactory;
import org.mozilla.webclient.impl.Service;
import org.mozilla.dom.DOMAccessor;
import java.util.Map;
import java.util.HashMap;
@ -71,8 +74,11 @@ import java.util.HashMap;
public class WrapperFactoryImpl extends Object implements WrapperFactory {
//
// Protected Constants
// Constants
//
public static final String JAVADOM_LOADED_PROPERTY_NAME =
"org.mozilla.webclient.impl.wrapper_native.javadomjni.loaded";
//
// Class Variables
@ -145,7 +151,7 @@ public class WrapperFactoryImpl extends Object implements WrapperFactory {
BrowserControl result = new BrowserControlImpl(this);
final int nativeBrowserControl = nativeCreateBrowserControl();
eventThread.pushBlockingWCRunnable(new WCRunnable() {
eventThread.pushBlockingReturnRunnable(new ReturnRunnable() {
public Object run() {
WrapperFactoryImpl.this.nativeInitBrowserControl(nativeWrapperFactory, nativeBrowserControl);
return null;
@ -166,7 +172,7 @@ public class WrapperFactoryImpl extends Object implements WrapperFactory {
if (null != (nativeBc = (Integer) browserControls.get(toDelete))) {
final int nativeBrowserControl = nativeBc.intValue();
eventThread.pushBlockingWCRunnable(new WCRunnable() {
eventThread.pushBlockingReturnRunnable(new ReturnRunnable() {
public Object run() {
WrapperFactoryImpl.this.nativeDestroyBrowserControl(nativeBrowserControl);
return null;
@ -279,6 +285,14 @@ public class WrapperFactoryImpl extends Object implements WrapperFactory {
public int loadNativeLibraryIfNecessary() {
System.loadLibrary("webclient");
System.setProperty(JAVADOM_LOADED_PROPERTY_NAME, "true");
try {
System.loadLibrary("javadomjni");
DOMAccessor.setNativeLibraryLoaded(true);
}
catch (Exception ex) {
System.setProperty(JAVADOM_LOADED_PROPERTY_NAME, "false");
}
nativeWrapperFactory = nativeCreateNativeWrapperFactory();
Assert.assert_it(-1 != nativeWrapperFactory);
@ -335,7 +349,7 @@ public class WrapperFactoryImpl extends Object implements WrapperFactory {
initialized = true;
try {
eventThread.pushBlockingWCRunnable(new WCRunnable() {
eventThread.pushBlockingReturnRunnable(new ReturnRunnable() {
public Object run() {
((Service)WrapperFactoryImpl.this.profileManager).startup();
@ -372,7 +386,7 @@ public void terminate() throws Exception
throw new IllegalStateException("Already terminated");
}
eventThread.pushBlockingWCRunnable(new WCRunnable() {
eventThread.pushBlockingReturnRunnable(new ReturnRunnable() {
public Object run() {
Assert.assert_it(null != bookmarks);
// PENDING(edburns): 20070130 XULRunner has no bookmarks ((Service)bookmarks).shutdown();