Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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.wip; | 5 package org.chromium.sdk.internal.wip; |
| 6 | 6 |
| 7 import static org.chromium.sdk.util.BasicUtil.getSafe; | 7 import static org.chromium.sdk.util.BasicUtil.getSafe; |
| 8 | 8 |
| 9 import java.util.ArrayList; | 9 import java.util.ArrayList; |
| 10 import java.util.Collection; | 10 import java.util.Collection; |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 322 functionName = frameData.functionName(); | 322 functionName = frameData.functionName(); |
| 323 id = frameData.callFrameId(); | 323 id = frameData.callFrameId(); |
| 324 sourceId = frameData.location().scriptId(); | 324 sourceId = frameData.location().scriptId(); |
| 325 final List<ScopeValue> scopeDataList = frameData.scopeChain(); | 325 final List<ScopeValue> scopeDataList = frameData.scopeChain(); |
| 326 | 326 |
| 327 scopeData = LazyConstructable.create(new LazyConstructable.Factory<List< JsScope>>() { | 327 scopeData = LazyConstructable.create(new LazyConstructable.Factory<List< JsScope>>() { |
| 328 @Override | 328 @Override |
| 329 public List<JsScope> construct() { | 329 public List<JsScope> construct() { |
| 330 final List<JsScope> scopes = new ArrayList<JsScope>(scopeDataList.si ze()); | 330 final List<JsScope> scopes = new ArrayList<JsScope>(scopeDataList.si ze()); |
| 331 | 331 |
| 332 ScopeHolderParams holderParams = new ScopeHolderParams(id, null); | |
| 333 | |
| 332 for (int i = 0; i < scopeDataList.size(); i++) { | 334 for (int i = 0; i < scopeDataList.size(); i++) { |
| 333 ScopeValue scopeData = scopeDataList.get(i); | 335 ScopeValue scopeData = scopeDataList.get(i); |
| 334 scopes.add(createScope(scopeData, valueLoader)); | 336 scopes.add(createScope(scopeData, valueLoader, holderParams, i)); |
| 335 } | 337 } |
| 336 return scopes; | 338 return scopes; |
| 337 } | 339 } |
| 338 }); | 340 }); |
| 339 | 341 |
| 340 RemoteObjectValue thisObjectData = frameData.getThis(); | 342 RemoteObjectValue thisObjectData = frameData.getThis(); |
| 341 if (thisObjectData == null) { | 343 if (thisObjectData == null) { |
| 342 LOGGER.log(Level.SEVERE, "Missing local scope", new Exception()); | 344 LOGGER.log(Level.SEVERE, "Missing local scope", new Exception()); |
| 343 thisObject = null; | 345 thisObject = null; |
| 344 } else { | 346 } else { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 403 public String getFunctionName() { | 405 public String getFunctionName() { |
| 404 return functionName; | 406 return functionName; |
| 405 } | 407 } |
| 406 | 408 |
| 407 @Override | 409 @Override |
| 408 public JsEvaluateContext getEvaluateContext() { | 410 public JsEvaluateContext getEvaluateContext() { |
| 409 return evaluateContext; | 411 return evaluateContext; |
| 410 } | 412 } |
| 411 | 413 |
| 412 private JsVariable createSimpleNameVariable(String name, RemoteObjectValue thisObjectData) { | 414 private JsVariable createSimpleNameVariable(String name, RemoteObjectValue thisObjectData) { |
| 413 return valueLoader.getValueBuilder().createVariable(thisObjectData, name ); | 415 return valueLoader.getValueBuilder().createVariable(thisObjectData, name , null); |
| 414 } | 416 } |
| 415 | 417 |
| 416 private final WipEvaluateContextBase<?> evaluateContext = | 418 private final WipEvaluateContextBase<?> evaluateContext = |
| 417 new WipEvaluateContextBase<EvaluateOnCallFrameData>(getValueLoader()) { | 419 new WipEvaluateContextBase<EvaluateOnCallFrameData>(getValueLoader()) { |
| 418 @Override | 420 @Override |
| 419 protected WipParamsWithResponse<EvaluateOnCallFrameData> createRequestPa rams( | 421 protected WipParamsWithResponse<EvaluateOnCallFrameData> createRequestPa rams( |
| 420 String expression, WipValueLoader destinationValueLoader) { | 422 String expression, WipValueLoader destinationValueLoader) { |
| 421 return new EvaluateOnCallFrameParams(id, expression, | 423 return new EvaluateOnCallFrameParams(id, expression, |
| 422 destinationValueLoader.getObjectGroupId(), false, null, false, nul l); | 424 destinationValueLoader.getObjectGroupId(), false, null, false, nul l); |
| 423 } | 425 } |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 556 return callFrameImpl.restart(callback, syncCallback); | 558 return callFrameImpl.restart(callback, syncCallback); |
| 557 } | 559 } |
| 558 | 560 |
| 559 @Override | 561 @Override |
| 560 public boolean canRestartFrame(CallFrame callFrame) { | 562 public boolean canRestartFrame(CallFrame callFrame) { |
| 561 return callFrame.getScript() != null; | 563 return callFrame.getScript() != null; |
| 562 } | 564 } |
| 563 }; | 565 }; |
| 564 | 566 |
| 565 | 567 |
| 566 static JsScope createScope(ScopeValue scopeData, WipValueLoader valueLoader) { | 568 static JsScope createScope(ScopeValue scopeData, WipValueLoader valueLoader, |
| 569 ScopeHolderParams holderParams, int number) { | |
|
apavlov
2013/02/18 11:34:08
"number"? Should it be "scopeIndex" instead?
Peter Rybin
2013/02/18 23:32:52
Done.
| |
| 567 JsScope.Type type = WIP_TO_SDK_SCOPE_TYPE.get(scopeData.type()); | 570 JsScope.Type type = WIP_TO_SDK_SCOPE_TYPE.get(scopeData.type()); |
| 568 if (type == null) { | 571 if (type == null) { |
| 569 type = JsScope.Type.UNKNOWN; | 572 type = JsScope.Type.UNKNOWN; |
| 570 } | 573 } |
| 571 if (type == JsScope.Type.WITH || type == JsScope.Type.GLOBAL) { | 574 if (type == JsScope.Type.WITH || type == JsScope.Type.GLOBAL) { |
| 572 return new ObjectScopeImpl(scopeData, type, valueLoader); | 575 return new ObjectScopeImpl(scopeData, type, valueLoader); |
| 573 } else { | 576 } else { |
| 574 return new DeclarativeScopeImpl(scopeData, type, valueLoader); | 577 ScopeParams scopeParams = new ScopeParams(holderParams, number); |
| 578 return new DeclarativeScopeImpl(scopeData, scopeParams, type, valueLoader) ; | |
| 575 } | 579 } |
| 576 } | 580 } |
| 577 | 581 |
| 578 private static class DeclarativeScopeImpl implements JsScope.Declarative { | 582 private static class DeclarativeScopeImpl implements JsScope.Declarative { |
| 579 private final AsyncFutureRef<Getter<ScopeVariables>> propertiesRef = | 583 private final AsyncFutureRef<Getter<ScopeVariables>> propertiesRef = |
| 580 new AsyncFutureRef<Getter<ScopeVariables>>(); | 584 new AsyncFutureRef<Getter<ScopeVariables>>(); |
| 581 private final String objectId; | 585 private final String objectId; |
| 586 private final ScopeParams scopeParams; | |
| 582 private final Type type; | 587 private final Type type; |
| 583 private final WipValueLoader valueLoader; | 588 private final WipValueLoader valueLoader; |
| 584 | 589 |
| 585 public DeclarativeScopeImpl(ScopeValue scopeData, Type type, WipValueLoader valueLoader) { | 590 public DeclarativeScopeImpl(ScopeValue scopeData, ScopeParams scopeParams, T ype type, |
| 591 WipValueLoader valueLoader) { | |
| 586 this.type = type; | 592 this.type = type; |
| 593 this.scopeParams = scopeParams; | |
| 587 this.objectId = scopeData.object().objectId(); | 594 this.objectId = scopeData.object().objectId(); |
| 588 this.valueLoader = valueLoader; | 595 this.valueLoader = valueLoader; |
| 589 } | 596 } |
| 590 | 597 |
| 591 @Override public Type getType() { | 598 @Override public Type getType() { |
| 592 return type; | 599 return type; |
| 593 } | 600 } |
| 594 | 601 |
| 595 @Override public Declarative asDeclarativeScope() { | 602 @Override public Declarative asDeclarativeScope() { |
| 596 return this; | 603 return this; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 634 @Override | 641 @Override |
| 635 public Getter<ScopeVariables> process(List<? extends PropertyDescriptorV alue> propertyList, | 642 public Getter<ScopeVariables> process(List<? extends PropertyDescriptorV alue> propertyList, |
| 636 List<? extends InternalPropertyDescriptorValue> internalPropertyList , | 643 List<? extends InternalPropertyDescriptorValue> internalPropertyList , |
| 637 int currentCacheState) { | 644 int currentCacheState) { |
| 638 final List<JsVariable> properties = new ArrayList<JsVariable>(property List.size()); | 645 final List<JsVariable> properties = new ArrayList<JsVariable>(property List.size()); |
| 639 | 646 |
| 640 WipValueBuilder valueBuilder = valueLoader.getValueBuilder(); | 647 WipValueBuilder valueBuilder = valueLoader.getValueBuilder(); |
| 641 for (PropertyDescriptorValue property : propertyList) { | 648 for (PropertyDescriptorValue property : propertyList) { |
| 642 final String name = property.name(); | 649 final String name = property.name(); |
| 643 | 650 |
| 644 JsVariable variable; | 651 JsVariable variable = valueBuilder.createVariable(property.value(), name, scopeParams); |
| 645 if (objectId == null) { | |
| 646 variable = valueBuilder.createVariable(property.value(), name); | |
| 647 } else { | |
| 648 variable = valueBuilder.createObjectProperty(property, objectId, n ame); | |
| 649 } | |
| 650 properties.add(variable); | 652 properties.add(variable); |
| 651 } | 653 } |
| 652 final ScopeVariables scopeVariables = new ScopeVariables(properties, c urrentCacheState); | 654 final ScopeVariables scopeVariables = new ScopeVariables(properties, c urrentCacheState); |
| 653 return new Getter<ScopeVariables>() { | 655 return new Getter<ScopeVariables>() { |
| 654 @Override | 656 @Override |
| 655 ScopeVariables get() { | 657 ScopeVariables get() { |
| 656 return scopeVariables; | 658 return scopeVariables; |
| 657 } | 659 } |
| 658 }; | 660 }; |
| 659 } | 661 } |
| 660 | 662 |
| 661 @Override | 663 @Override |
| 662 public Getter<ScopeVariables> getEmptyResult() { | 664 public Getter<ScopeVariables> getEmptyResult() { |
| 663 return EMPTY_SCOPE_VARIABLES_OPTIONAL; | 665 return EMPTY_SCOPE_VARIABLES_OPTIONAL; |
| 664 } | 666 } |
| 665 | 667 |
| 666 @Override | 668 @Override |
| 667 public Getter<ScopeVariables> forException(Exception exception) { | 669 public Getter<ScopeVariables> forException(Exception exception) { |
| 668 return WipValueLoader.Getter.newFailure(exception); | 670 return WipValueLoader.Getter.newFailure(exception); |
| 669 } | 671 } |
| 670 }; | 672 }; |
| 671 // This is blocking. | 673 // This is blocking. |
| 672 valueLoader.loadPropertiesInFuture(objectId, processor, reload, currentCac heState, | 674 valueLoader.loadPropertiesInFuture(objectId, processor, reload, currentCac heState, |
| 673 propertiesRef); | 675 propertiesRef); |
| 674 } | 676 } |
| 675 } | 677 } |
| 676 | 678 |
| 679 static class ScopeHolderParams { | |
| 680 private final String callFrameId; | |
| 681 private final String functionId; | |
| 682 | |
| 683 ScopeHolderParams(String callFrameId, String functionId) { | |
| 684 this.callFrameId = callFrameId; | |
| 685 this.functionId = functionId; | |
| 686 } | |
| 687 } | |
| 688 | |
| 689 static class ScopeParams { | |
| 690 private final ScopeHolderParams scopeHolder; | |
| 691 private final int scopeNumber; | |
|
apavlov
2013/02/18 11:34:08
scopeIndex?
Peter Rybin
2013/02/18 23:32:52
Done.
| |
| 692 | |
| 693 private ScopeParams(ScopeHolderParams scopeHolder, int scopeNumber) { | |
| 694 this.scopeHolder = scopeHolder; | |
| 695 this.scopeNumber = scopeNumber; | |
| 696 } | |
| 697 String getCallFrameId() { | |
| 698 return scopeHolder.callFrameId; | |
| 699 } | |
| 700 String getFunctionId() { | |
| 701 return scopeHolder.functionId; | |
| 702 } | |
| 703 int getScopeNumber() { | |
| 704 return scopeNumber; | |
| 705 } | |
| 706 } | |
| 707 | |
| 677 private static class ObjectScopeImpl implements JsScope.ObjectBased { | 708 private static class ObjectScopeImpl implements JsScope.ObjectBased { |
| 678 private final JsValue jsValue; | 709 private final JsValue jsValue; |
| 679 private final JsScope.Type type; | 710 private final JsScope.Type type; |
| 680 | 711 |
| 681 ObjectScopeImpl(ScopeValue scopeData, JsScope.Type type, WipValueLoader valu eLoader) { | 712 ObjectScopeImpl(ScopeValue scopeData, JsScope.Type type, WipValueLoader valu eLoader) { |
| 682 this.jsValue = valueLoader.getValueBuilder().wrap(scopeData.object()); | 713 this.jsValue = valueLoader.getValueBuilder().wrap(scopeData.object()); |
| 683 this.type = type; | 714 this.type = type; |
| 684 } | 715 } |
| 685 | 716 |
| 686 @Override public Type getType() { | 717 @Override public Type getType() { |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 778 default: | 809 default: |
| 779 throw new RuntimeException(); | 810 throw new RuntimeException(); |
| 780 } | 811 } |
| 781 } | 812 } |
| 782 | 813 |
| 783 private static final ResumeParams RESUME_PARAMS = new ResumeParams(); | 814 private static final ResumeParams RESUME_PARAMS = new ResumeParams(); |
| 784 private static final StepIntoParams STEP_INTO_PARAMS = new StepIntoParams(); | 815 private static final StepIntoParams STEP_INTO_PARAMS = new StepIntoParams(); |
| 785 private static final StepOutParams STEP_OUT_PARAMS = new StepOutParams(); | 816 private static final StepOutParams STEP_OUT_PARAMS = new StepOutParams(); |
| 786 private static final StepOverParams STEP_OVER_PARAMS = new StepOverParams(); | 817 private static final StepOverParams STEP_OVER_PARAMS = new StepOverParams(); |
| 787 } | 818 } |
| OLD | NEW |