| 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.internal.v8native; | 5 package org.chromium.sdk.internal.v8native; |
| 6 | 6 |
| 7 import java.util.ArrayList; | 7 import java.util.ArrayList; |
| 8 import java.util.List; | 8 import java.util.List; |
| 9 import java.util.Map; | 9 import java.util.Map; |
| 10 | 10 |
| 11 import org.chromium.sdk.JsEvaluateContext; | 11 import org.chromium.sdk.JsEvaluateContext; |
| 12 import org.chromium.sdk.JsValue; | 12 import org.chromium.sdk.JsValue; |
| 13 import org.chromium.sdk.JsVariable; | 13 import org.chromium.sdk.JsVariable; |
| 14 import org.chromium.sdk.RelayOk; | 14 import org.chromium.sdk.RelayOk; |
| 15 import org.chromium.sdk.SyncCallback; | 15 import org.chromium.sdk.SyncCallback; |
| 16 import org.chromium.sdk.internal.JsEvaluateContextBase; | 16 import org.chromium.sdk.internal.JsEvaluateContextBase; |
| 17 import org.chromium.sdk.internal.protocolparser.JsonProtocolParseException; | 17 import org.chromium.sdk.internal.protocolparser.JsonProtocolParseException; |
| 18 import org.chromium.sdk.internal.v8native.InternalContext.ContextDismissedChecke
dException; | 18 import org.chromium.sdk.internal.v8native.InternalContext.ContextDismissedChecke
dException; |
| 19 import org.chromium.sdk.internal.v8native.protocol.input.FailedCommandResponse.E
rrorDetails; | 19 import org.chromium.sdk.internal.v8native.protocol.input.FailedCommandResponse.E
rrorDetails; |
| 20 import org.chromium.sdk.internal.v8native.protocol.input.SuccessCommandResponse; | 20 import org.chromium.sdk.internal.v8native.protocol.input.SuccessCommandResponse; |
| 21 import org.chromium.sdk.internal.v8native.protocol.input.data.ValueHandle; | 21 import org.chromium.sdk.internal.v8native.protocol.input.data.ValueHandle; |
| 22 import org.chromium.sdk.internal.v8native.protocol.output.DebuggerMessage; | 22 import org.chromium.sdk.internal.v8native.protocol.output.DebuggerMessage; |
| 23 import org.chromium.sdk.internal.v8native.protocol.output.DebuggerMessageFactory
; | 23 import org.chromium.sdk.internal.v8native.protocol.output.DebuggerMessageFactory
; |
| 24 import org.chromium.sdk.internal.v8native.protocol.output.EvaluateMessage; | 24 import org.chromium.sdk.internal.v8native.protocol.output.EvaluateMessage; |
| 25 import org.chromium.sdk.internal.v8native.value.JsValueBase; | 25 import org.chromium.sdk.internal.v8native.value.JsValueBase; |
| 26 import org.chromium.sdk.internal.v8native.value.JsVariableImpl; | 26 import org.chromium.sdk.internal.v8native.value.JsVariableBase; |
| 27 import org.chromium.sdk.internal.v8native.value.ValueMirror; | 27 import org.chromium.sdk.internal.v8native.value.ValueMirror; |
| 28 import org.chromium.sdk.util.RelaySyncCallback; | 28 import org.chromium.sdk.util.RelaySyncCallback; |
| 29 import org.json.simple.JSONValue; | 29 import org.json.simple.JSONValue; |
| 30 | 30 |
| 31 /** | 31 /** |
| 32 * Generic implementation of {@link JsEvaluateContext}. The abstract class leave
s unspecified | 32 * Generic implementation of {@link JsEvaluateContext}. The abstract class leave
s unspecified |
| 33 * stack frame identifier (possibly null) and reference to {@link InternalContex
t}. | 33 * stack frame identifier (possibly null) and reference to {@link InternalContex
t}. |
| 34 */ | 34 */ |
| 35 abstract class JsEvaluateContextImpl extends JsEvaluateContextBase { | 35 abstract class JsEvaluateContextImpl extends JsEvaluateContextBase { |
| 36 public RelayOk evaluateAsyncImpl(final String expression, | 36 public RelayOk evaluateAsyncImpl(final String expression, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 54 public void success(SuccessCommandResponse successResponse) { | 54 public void success(SuccessCommandResponse successResponse) { |
| 55 ValueHandle body; | 55 ValueHandle body; |
| 56 try { | 56 try { |
| 57 body = successResponse.body().asEvaluateBody(); | 57 body = successResponse.body().asEvaluateBody(); |
| 58 } catch (JsonProtocolParseException e) { | 58 } catch (JsonProtocolParseException e) { |
| 59 throw new RuntimeException(e); | 59 throw new RuntimeException(e); |
| 60 } | 60 } |
| 61 InternalContext internalContext = getInternalContext(); | 61 InternalContext internalContext = getInternalContext(); |
| 62 ValueMirror mirror = internalContext.getValueLoader().addDataToMap(b
ody); | 62 ValueMirror mirror = internalContext.getValueLoader().addDataToMap(b
ody); |
| 63 final JsValue value = | 63 final JsValue value = |
| 64 JsVariableImpl.createValue(internalContext.getValueLoader(), mir
ror); | 64 JsVariableBase.createValue(internalContext.getValueLoader(), mir
ror); |
| 65 ResultOrException result = new ResultOrException() { | 65 ResultOrException result = new ResultOrException() { |
| 66 @Override public JsValue getResult() { | 66 @Override public JsValue getResult() { |
| 67 return value; | 67 return value; |
| 68 } | 68 } |
| 69 @Override public JsValue getException() { | 69 @Override public JsValue getException() { |
| 70 return null; | 70 return null; |
| 71 } | 71 } |
| 72 @Override public <R> R accept(Visitor<R> visitor) { | 72 @Override public <R> R accept(Visitor<R> visitor) { |
| 73 return visitor.visitResult(value); | 73 return visitor.visitResult(value); |
| 74 } | 74 } |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 return new JsValueBase.Impl(JsValue.Type.TYPE_NUMBER, JSONValue.toJSONStri
ng(value)); | 179 return new JsValueBase.Impl(JsValue.Type.TYPE_NUMBER, JSONValue.toJSONStri
ng(value)); |
| 180 } | 180 } |
| 181 @Override public JsValue createNumber(String stringRepresentation) { | 181 @Override public JsValue createNumber(String stringRepresentation) { |
| 182 return new JsValueBase.Impl(JsValue.Type.TYPE_NUMBER, stringRepresentation
); | 182 return new JsValueBase.Impl(JsValue.Type.TYPE_NUMBER, stringRepresentation
); |
| 183 } | 183 } |
| 184 @Override public JsValue createBoolean(boolean value) { | 184 @Override public JsValue createBoolean(boolean value) { |
| 185 return new JsValueBase.Impl(JsValue.Type.TYPE_BOOLEAN, JSONValue.toJSONStr
ing(value)); | 185 return new JsValueBase.Impl(JsValue.Type.TYPE_BOOLEAN, JSONValue.toJSONStr
ing(value)); |
| 186 } | 186 } |
| 187 }; | 187 }; |
| 188 } | 188 } |
| OLD | NEW |