mobile/android/base/util/NativeJSContainer.java

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

mercurial