Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(398)

Side by Side Diff: plugins/org.chromium.sdk.wipbackend.dev/src/org/chromium/sdk/internal/wip/WipContextBuilder.java

Issue 12300043: Move setValue operation into a separate JsDeclarativeVariable interface (Closed) Base URL: https://chromedevtools.googlecode.com/svn/trunk
Patch Set: fcr Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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;
11 import java.util.Collections; 11 import java.util.Collections;
12 import java.util.HashMap; 12 import java.util.HashMap;
13 import java.util.HashSet; 13 import java.util.HashSet;
14 import java.util.List; 14 import java.util.List;
15 import java.util.Map; 15 import java.util.Map;
16 import java.util.Set; 16 import java.util.Set;
17 import java.util.concurrent.atomic.AtomicReference; 17 import java.util.concurrent.atomic.AtomicReference;
18 import java.util.logging.Level; 18 import java.util.logging.Level;
19 import java.util.logging.Logger; 19 import java.util.logging.Logger;
20 20
21 import org.chromium.sdk.Breakpoint; 21 import org.chromium.sdk.Breakpoint;
22 import org.chromium.sdk.CallFrame; 22 import org.chromium.sdk.CallFrame;
23 import org.chromium.sdk.DebugContext; 23 import org.chromium.sdk.DebugContext;
24 import org.chromium.sdk.DebugContext.StepAction; 24 import org.chromium.sdk.DebugContext.StepAction;
25 import org.chromium.sdk.ExceptionData; 25 import org.chromium.sdk.ExceptionData;
26 import org.chromium.sdk.JavascriptVm; 26 import org.chromium.sdk.JavascriptVm;
27 import org.chromium.sdk.JsDeclarativeVariable;
27 import org.chromium.sdk.JsEvaluateContext; 28 import org.chromium.sdk.JsEvaluateContext;
28 import org.chromium.sdk.JsObject; 29 import org.chromium.sdk.JsObject;
29 import org.chromium.sdk.JsScope; 30 import org.chromium.sdk.JsScope;
30 import org.chromium.sdk.JsValue; 31 import org.chromium.sdk.JsValue;
31 import org.chromium.sdk.JsVariable; 32 import org.chromium.sdk.JsVariable;
32 import org.chromium.sdk.RelayOk; 33 import org.chromium.sdk.RelayOk;
33 import org.chromium.sdk.RemoteValueMapping; 34 import org.chromium.sdk.RemoteValueMapping;
34 import org.chromium.sdk.RestartFrameExtension; 35 import org.chromium.sdk.RestartFrameExtension;
35 import org.chromium.sdk.SyncCallback; 36 import org.chromium.sdk.SyncCallback;
36 import org.chromium.sdk.TextStreamPosition; 37 import org.chromium.sdk.TextStreamPosition;
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 public String getFunctionName() { 406 public String getFunctionName() {
406 return functionName; 407 return functionName;
407 } 408 }
408 409
409 @Override 410 @Override
410 public JsEvaluateContext getEvaluateContext() { 411 public JsEvaluateContext getEvaluateContext() {
411 return evaluateContext; 412 return evaluateContext;
412 } 413 }
413 414
414 private JsVariable createSimpleNameVariable(String name, RemoteObjectValue thisObjectData) { 415 private JsVariable createSimpleNameVariable(String name, RemoteObjectValue thisObjectData) {
415 return valueLoader.getValueBuilder().createVariable(thisObjectData, name , null); 416 return valueLoader.getValueBuilder().createVariable(thisObjectData, name );
416 } 417 }
417 418
418 private final WipEvaluateContextBase<?> evaluateContext = 419 private final WipEvaluateContextBase<?> evaluateContext =
419 new WipEvaluateContextBase<EvaluateOnCallFrameData>(getValueLoader()) { 420 new WipEvaluateContextBase<EvaluateOnCallFrameData>(getValueLoader()) {
420 @Override 421 @Override
421 protected WipParamsWithResponse<EvaluateOnCallFrameData> createRequestPa rams( 422 protected WipParamsWithResponse<EvaluateOnCallFrameData> createRequestPa rams(
422 String expression, WipValueLoader destinationValueLoader) { 423 String expression, WipValueLoader destinationValueLoader) {
423 return new EvaluateOnCallFrameParams(id, expression, 424 return new EvaluateOnCallFrameParams(id, expression,
424 destinationValueLoader.getObjectGroupId(), false, null, false, nul l); 425 destinationValueLoader.getObjectGroupId(), false, null, false, nul l);
425 } 426 }
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 606
606 @Override public ObjectBased asObjectBased() { 607 @Override public ObjectBased asObjectBased() {
607 return null; 608 return null;
608 } 609 }
609 610
610 @Override public <R> R accept(Visitor<R> visitor) { 611 @Override public <R> R accept(Visitor<R> visitor) {
611 return visitor.visitDeclarative(this); 612 return visitor.visitDeclarative(this);
612 } 613 }
613 614
614 @Override 615 @Override
615 public List<? extends JsVariable> getVariables() throws MethodIsBlockingExce ption { 616 public List<? extends JsDeclarativeVariable> getVariables() throws MethodIsB lockingException {
616 int currentCacheState = valueLoader.getCacheState(); 617 int currentCacheState = valueLoader.getCacheState();
617 if (propertiesRef.isInitialized()) { 618 if (propertiesRef.isInitialized()) {
618 ScopeVariables result = propertiesRef.getSync().get(); 619 ScopeVariables result = propertiesRef.getSync().get();
619 if (result.cacheState == currentCacheState) { 620 if (result.cacheState == currentCacheState) {
620 return result.variables; 621 return result.variables;
621 } 622 }
622 startLoadOperation(true, currentCacheState); 623 startLoadOperation(true, currentCacheState);
623 } else { 624 } else {
624 startLoadOperation(false, currentCacheState); 625 startLoadOperation(false, currentCacheState);
625 } 626 }
626 627
627 // This is blocking. 628 // This is blocking.
628 return propertiesRef.getSync().get().variables; 629 return propertiesRef.getSync().get().variables;
629 } 630 }
630 631
631 /** 632 /**
632 * Starts load operation that works synchronously, i.e. it may block the cal ling method. 633 * Starts load operation that works synchronously, i.e. it may block the cal ling method.
633 * This is done because some thread must take post-processing anyway and it shouldn't 634 * This is done because some thread must take post-processing anyway and it shouldn't
634 * be the Dispatch thread. 635 * be the Dispatch thread.
635 * The method may not be blocking, if another thread is already doing the sa me operation. 636 * The method may not be blocking, if another thread is already doing the sa me operation.
636 */ 637 */
637 private void startLoadOperation(boolean reload, int currentCacheState) 638 private void startLoadOperation(boolean reload, int currentCacheState)
638 throws MethodIsBlockingException { 639 throws MethodIsBlockingException {
639 WipValueLoader.LoadPostprocessor<Getter<ScopeVariables>> processor = 640 WipValueLoader.LoadPostprocessor<Getter<ScopeVariables>> processor =
640 new WipValueLoader.LoadPostprocessor<Getter<ScopeVariables>>() { 641 new WipValueLoader.LoadPostprocessor<Getter<ScopeVariables>>() {
641 @Override 642 @Override
642 public Getter<ScopeVariables> process(List<? extends PropertyDescriptorV alue> propertyList, 643 public Getter<ScopeVariables> process(List<? extends PropertyDescriptorV alue> propertyList,
643 List<? extends InternalPropertyDescriptorValue> internalPropertyList , 644 List<? extends InternalPropertyDescriptorValue> internalPropertyList ,
644 int currentCacheState) { 645 int currentCacheState) {
645 final List<JsVariable> properties = new ArrayList<JsVariable>(property List.size()); 646 final List<JsDeclarativeVariable> properties =
647 new ArrayList<JsDeclarativeVariable>(propertyList.size());
646 648
647 WipValueBuilder valueBuilder = valueLoader.getValueBuilder(); 649 WipValueBuilder valueBuilder = valueLoader.getValueBuilder();
648 for (PropertyDescriptorValue property : propertyList) { 650 for (PropertyDescriptorValue property : propertyList) {
649 final String name = property.name(); 651 final String name = property.name();
650 652
651 JsVariable variable = valueBuilder.createVariable(property.value(), name, scopeParams); 653 JsDeclarativeVariable variable =
654 valueBuilder.createDeclarativeVariable(property.value(), name, s copeParams);
652 properties.add(variable); 655 properties.add(variable);
653 } 656 }
654 final ScopeVariables scopeVariables = new ScopeVariables(properties, c urrentCacheState); 657 final ScopeVariables scopeVariables = new ScopeVariables(properties, c urrentCacheState);
655 return new Getter<ScopeVariables>() { 658 return new Getter<ScopeVariables>() {
656 @Override 659 @Override
657 ScopeVariables get() { 660 ScopeVariables get() {
658 return scopeVariables; 661 return scopeVariables;
659 } 662 }
660 }; 663 };
661 } 664 }
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
769 WIP_TO_SDK_SCOPE_TYPE.put(ScopeValue.Type.GLOBAL, JsScope.Type.GLOBAL); 772 WIP_TO_SDK_SCOPE_TYPE.put(ScopeValue.Type.GLOBAL, JsScope.Type.GLOBAL);
770 WIP_TO_SDK_SCOPE_TYPE.put(ScopeValue.Type.LOCAL, JsScope.Type.LOCAL); 773 WIP_TO_SDK_SCOPE_TYPE.put(ScopeValue.Type.LOCAL, JsScope.Type.LOCAL);
771 WIP_TO_SDK_SCOPE_TYPE.put(ScopeValue.Type.WITH, JsScope.Type.WITH); 774 WIP_TO_SDK_SCOPE_TYPE.put(ScopeValue.Type.WITH, JsScope.Type.WITH);
772 WIP_TO_SDK_SCOPE_TYPE.put(ScopeValue.Type.CLOSURE, JsScope.Type.CLOSURE); 775 WIP_TO_SDK_SCOPE_TYPE.put(ScopeValue.Type.CLOSURE, JsScope.Type.CLOSURE);
773 WIP_TO_SDK_SCOPE_TYPE.put(ScopeValue.Type.CATCH, JsScope.Type.CATCH); 776 WIP_TO_SDK_SCOPE_TYPE.put(ScopeValue.Type.CATCH, JsScope.Type.CATCH);
774 777
775 assert WIP_TO_SDK_SCOPE_TYPE.size() == ScopeValue.Type.values().length; 778 assert WIP_TO_SDK_SCOPE_TYPE.size() == ScopeValue.Type.values().length;
776 } 779 }
777 780
778 private static class ScopeVariables { 781 private static class ScopeVariables {
779 final List<JsVariable> variables; 782 final List<JsDeclarativeVariable> variables;
780 final int cacheState; 783 final int cacheState;
781 784
782 ScopeVariables(List<JsVariable> variables, int cacheState) { 785 ScopeVariables(List<JsDeclarativeVariable> variables, int cacheState) {
783 this.variables = variables; 786 this.variables = variables;
784 this.cacheState = cacheState; 787 this.cacheState = cacheState;
785 } 788 }
786 } 789 }
787 790
788 private static final Getter<ScopeVariables> EMPTY_SCOPE_VARIABLES_OPTIONAL = 791 private static final Getter<ScopeVariables> EMPTY_SCOPE_VARIABLES_OPTIONAL =
789 new Getter<ScopeVariables>() { 792 new Getter<ScopeVariables>() {
790 private final ScopeVariables value = 793 private final ScopeVariables value =
791 new ScopeVariables(Collections.<JsVariable>emptyList(), Integer.MAX_VA LUE); 794 new ScopeVariables(Collections.<JsDeclarativeVariable>emptyList(), Int eger.MAX_VALUE);
792 795
793 @Override ScopeVariables get() { 796 @Override ScopeVariables get() {
794 return value; 797 return value;
795 } 798 }
796 }; 799 };
797 800
798 801
799 private WipParams sdkStepToProtocolStep(StepAction stepAction) { 802 private WipParams sdkStepToProtocolStep(StepAction stepAction) {
800 switch (stepAction) { 803 switch (stepAction) {
801 case CONTINUE: 804 case CONTINUE:
802 return RESUME_PARAMS; 805 return RESUME_PARAMS;
803 case IN: 806 case IN:
804 return STEP_INTO_PARAMS; 807 return STEP_INTO_PARAMS;
805 case OUT: 808 case OUT:
806 return STEP_OUT_PARAMS; 809 return STEP_OUT_PARAMS;
807 case OVER: 810 case OVER:
808 return STEP_OVER_PARAMS; 811 return STEP_OVER_PARAMS;
809 default: 812 default:
810 throw new RuntimeException(); 813 throw new RuntimeException();
811 } 814 }
812 } 815 }
813 816
814 private static final ResumeParams RESUME_PARAMS = new ResumeParams(); 817 private static final ResumeParams RESUME_PARAMS = new ResumeParams();
815 private static final StepIntoParams STEP_INTO_PARAMS = new StepIntoParams(); 818 private static final StepIntoParams STEP_INTO_PARAMS = new StepIntoParams();
816 private static final StepOutParams STEP_OUT_PARAMS = new StepOutParams(); 819 private static final StepOutParams STEP_OUT_PARAMS = new StepOutParams();
817 private static final StepOverParams STEP_OVER_PARAMS = new StepOverParams(); 820 private static final StepOverParams STEP_OVER_PARAMS = new StepOverParams();
818 } 821 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698