Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* -*- Mode: Java; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil; -*- |
michael@0 | 2 | * This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | package org.mozilla.gecko.util; |
michael@0 | 7 | |
michael@0 | 8 | import org.mozilla.gecko.mozglue.JNITarget; |
michael@0 | 9 | |
michael@0 | 10 | /** |
michael@0 | 11 | * NativeJSContainer is a wrapper around the SpiderMonkey JSAPI to make it possible to |
michael@0 | 12 | * access Javascript objects in Java. |
michael@0 | 13 | * |
michael@0 | 14 | * A container must only be used on the thread it is attached to. To use it on another |
michael@0 | 15 | * thread, call {@link #clone()} to make a copy, and use the copy on the other thread. |
michael@0 | 16 | * When a copy is first used, it becomes attached to the thread using it. |
michael@0 | 17 | */ |
michael@0 | 18 | @JNITarget |
michael@0 | 19 | public final class NativeJSContainer extends NativeJSObject |
michael@0 | 20 | { |
michael@0 | 21 | private long mNativeObject; |
michael@0 | 22 | |
michael@0 | 23 | private NativeJSContainer(long nativeObject) { |
michael@0 | 24 | mNativeObject = nativeObject; |
michael@0 | 25 | } |
michael@0 | 26 | |
michael@0 | 27 | /** |
michael@0 | 28 | * Make a copy of this container for use by another thread. When the copy is first used, |
michael@0 | 29 | * it becomes attached to the thread using it. |
michael@0 | 30 | */ |
michael@0 | 31 | @Override |
michael@0 | 32 | public native NativeJSContainer clone(); |
michael@0 | 33 | |
michael@0 | 34 | /** |
michael@0 | 35 | * Dispose all associated native objects. Subsequent use of any objects derived from |
michael@0 | 36 | * this container will throw a NullPointerException. |
michael@0 | 37 | */ |
michael@0 | 38 | public native void dispose(); |
michael@0 | 39 | } |