| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.sdk; | 5 package org.chromium.sdk; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * An object that represents a variable in a browser JavaScript VM call frame. | 8 * An object that represents a variable in a browser JavaScript VM call frame. |
| 9 */ | 9 */ |
| 10 public interface JsVariable { | 10 public interface JsVariable { |
| 11 | 11 |
| 12 /** | 12 /** |
| 13 * A callback to use while setting a variable value. | |
| 14 */ | |
| 15 interface SetValueCallback { | |
| 16 void success(); | |
| 17 | |
| 18 void failure(String errorMessage); | |
| 19 } | |
| 20 | |
| 21 /** | |
| 22 * @return whether it is possible to read this variable | 13 * @return whether it is possible to read this variable |
| 23 */ | 14 */ |
| 24 boolean isReadable(); | 15 boolean isReadable(); |
| 25 | 16 |
| 26 /** | 17 /** |
| 27 * Returns the value of this variable. | 18 * Returns the value of this variable. |
| 28 * | 19 * |
| 29 * @return a [probably compound] JsValue corresponding to this variable. | 20 * @return a [probably compound] JsValue corresponding to this variable. |
| 30 * {@code null} if there was an error reading the value data | 21 * {@code null} if there was an error reading the value data |
| 31 * or the property has accessor descriptor | 22 * or the property has accessor descriptor |
| (...skipping 15 matching lines...) Expand all Loading... |
| 47 /** | 38 /** |
| 48 * @return whether it is possible to modify this variable | 39 * @return whether it is possible to modify this variable |
| 49 */ | 40 */ |
| 50 boolean isMutable(); | 41 boolean isMutable(); |
| 51 | 42 |
| 52 /** | 43 /** |
| 53 * Sets a new value for this variable. | 44 * Sets a new value for this variable. |
| 54 * | 45 * |
| 55 * @param newValue to set | 46 * @param newValue to set |
| 56 * @param callback to report the operation result to | 47 * @param callback to report the operation result to |
| 48 * @param syncCallback to report the end of any processing |
| 57 * @see #isMutable() | 49 * @see #isMutable() |
| 58 * @throws UnsupportedOperationException if this variable is not mutable | 50 * @throws UnsupportedOperationException if this variable is not mutable |
| 59 */ | 51 */ |
| 60 void setValue(String newValue, SetValueCallback callback) | 52 RelayOk setValue(JsValue newValue, SetValueCallback callback, SyncCallback syn
cCallback) |
| 61 throws UnsupportedOperationException; | 53 throws UnsupportedOperationException; |
| 62 | 54 |
| 63 /** | 55 /** |
| 56 * A callback to use while setting a variable value. |
| 57 */ |
| 58 interface SetValueCallback { |
| 59 /** |
| 60 * Variable is successfully updated. New value is available in {@link JsVari
able#getValue()}. |
| 61 */ |
| 62 void success(); |
| 63 |
| 64 /** |
| 65 * Variable hasn't been updated because exception was thrown. Most probably
this exception was |
| 66 * thrown from setter function. |
| 67 */ |
| 68 void exceptionThrown(JsValue exception); |
| 69 |
| 70 /** |
| 71 * Variable hasn't been updated for unknown reason. |
| 72 */ |
| 73 void failure(Exception cause); |
| 74 } |
| 75 |
| 76 /** |
| 64 * Returns object property data if variable is an object property and its desc
riptor | 77 * Returns object property data if variable is an object property and its desc
riptor |
| 65 * is available. | 78 * is available. |
| 66 */ | 79 */ |
| 67 JsObjectProperty asObjectProperty(); | 80 JsObjectProperty asObjectProperty(); |
| 68 } | 81 } |
| OLD | NEW |