OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012, the Dart project authors. | 2 * Copyright (c) 2012, the Dart project authors. |
3 * | 3 * |
4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u
se this file except | 4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u
se this file except |
5 * in compliance with the License. You may obtain a copy of the License at | 5 * in compliance with the License. You may obtain a copy of the License at |
6 * | 6 * |
7 * http://www.eclipse.org/legal/epl-v10.html | 7 * http://www.eclipse.org/legal/epl-v10.html |
8 * | 8 * |
9 * Unless required by applicable law or agreed to in writing, software distribut
ed under the License | 9 * Unless required by applicable law or agreed to in writing, software distribut
ed under the License |
10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K
IND, either express | 10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K
IND, either express |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 @Override | 122 @Override |
123 public void handleResult(JSONObject result) throws JSONException { | 123 public void handleResult(JSONObject result) throws JSONException { |
124 callback.handleResult(convertEvaluateResult(result)); | 124 callback.handleResult(convertEvaluateResult(result)); |
125 } | 125 } |
126 }); | 126 }); |
127 } catch (JSONException exception) { | 127 } catch (JSONException exception) { |
128 throw new IOException(exception); | 128 throw new IOException(exception); |
129 } | 129 } |
130 } | 130 } |
131 | 131 |
| 132 public void callListLength(String objectId, final WebkitCallback<Integer> call
back) |
| 133 throws IOException { |
| 134 if (objectId == null) { |
| 135 WebkitResult<Integer> result = new WebkitResult<Integer>(); |
| 136 result.setResult(new Integer(0)); |
| 137 callback.handleResult(result); |
| 138 return; |
| 139 } |
| 140 |
| 141 try { |
| 142 JSONObject request = new JSONObject(); |
| 143 |
| 144 request.put("method", "Runtime.callFunctionOn"); |
| 145 request.put( |
| 146 "params", |
| 147 new JSONObject().put("objectId", objectId).put("functionDeclaration",
"() => length").put( |
| 148 "returnByValue", |
| 149 false)); |
| 150 |
| 151 connection.sendRequest(request, new Callback() { |
| 152 @Override |
| 153 public void handleResult(JSONObject result) throws JSONException { |
| 154 WebkitResult<WebkitRemoteObject> functionResult = convertEvaluateResul
t(result); |
| 155 |
| 156 WebkitResult<Integer> r = new WebkitResult<Integer>(); |
| 157 |
| 158 if (functionResult.getWasThrown()) { |
| 159 r.setError(functionResult.getResult().getValue()); |
| 160 } else { |
| 161 r.setResult(functionResult.getResult() == null ? new Integer(0) : ne
w Integer( |
| 162 functionResult.getResult().getValue())); |
| 163 } |
| 164 |
| 165 callback.handleResult(r); |
| 166 } |
| 167 }); |
| 168 } catch (JSONException exception) { |
| 169 throw new IOException(exception); |
| 170 } |
| 171 } |
| 172 |
132 /** | 173 /** |
133 * Calls the toString() method on the given remote object. This is a convenien
ce method for the | 174 * Calls the toString() method on the given remote object. This is a convenien
ce method for the |
134 * Runtime.callFunctionOn call. | 175 * Runtime.callFunctionOn call. |
135 * | 176 * |
136 * @param objectId | 177 * @param objectId |
137 * @throws IOException | 178 * @throws IOException |
138 */ | 179 */ |
139 public void callToString(String objectId, final WebkitCallback<String> callbac
k) | 180 public void callToString(String objectId, final WebkitCallback<String> callbac
k) |
140 throws IOException { | 181 throws IOException { |
141 if (objectId == null) { | 182 if (objectId == null) { |
142 WebkitResult<String> result = new WebkitResult<String>(); | 183 WebkitResult<String> result = new WebkitResult<String>(); |
143 result.setResult(null); | 184 result.setResult(null); |
144 callback.handleResult(result); | 185 callback.handleResult(result); |
145 return; | 186 return; |
146 } | 187 } |
147 | 188 |
148 try { | 189 try { |
149 JSONObject request = new JSONObject(); | 190 JSONObject request = new JSONObject(); |
150 | 191 |
151 request.put("method", "Runtime.callFunctionOn"); | 192 request.put("method", "Runtime.callFunctionOn"); |
152 request.put( | 193 request.put( |
153 "params", | 194 "params", |
154 new JSONObject().put("objectId", objectId).put( | 195 new JSONObject().put("objectId", objectId).put("functionDeclaration",
"() => toString()").put( |
155 "functionDeclaration", | 196 "returnByValue", |
156 "() => toString()").put("returnByValue", false)); | 197 false)); |
157 | 198 |
158 connection.sendRequest(request, new Callback() { | 199 connection.sendRequest(request, new Callback() { |
159 @Override | 200 @Override |
160 public void handleResult(JSONObject result) throws JSONException { | 201 public void handleResult(JSONObject result) throws JSONException { |
161 WebkitResult<WebkitRemoteObject> functionResult = convertEvaluateResul
t(result); | 202 WebkitResult<WebkitRemoteObject> functionResult = convertEvaluateResul
t(result); |
162 | 203 |
163 WebkitResult<String> r = new WebkitResult<String>(); | 204 WebkitResult<String> r = new WebkitResult<String>(); |
164 | 205 |
165 if (functionResult.getWasThrown()) { | 206 if (functionResult.getWasThrown()) { |
166 r.setError(functionResult.getResult().getValue()); | 207 r.setError(functionResult.getResult().getValue()); |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 if (object.has("result")) { | 384 if (object.has("result")) { |
344 JSONObject obj = object.getJSONObject("result"); | 385 JSONObject obj = object.getJSONObject("result"); |
345 | 386 |
346 result.setResult(WebkitPropertyDescriptor.createFrom(obj.getJSONArray("res
ult"))); | 387 result.setResult(WebkitPropertyDescriptor.createFrom(obj.getJSONArray("res
ult"))); |
347 } | 388 } |
348 | 389 |
349 return result; | 390 return result; |
350 } | 391 } |
351 | 392 |
352 } | 393 } |
OLD | NEW |