Package org.chromium.sdk

Examples of org.chromium.sdk.CallbackSemaphore


          };
        }
      }
    };

    CallbackSemaphore syncCallback = new CallbackSemaphore();
    RelayOk relayOk = changesPlan.execute(false, callback, syncCallback);
    syncCallback.acquireDefault(relayOk);

    monitor.done();

    return input[0];
  }
View Full Code Here


    JsValue.ReloadBiggerCallback callback = new JsValue.ReloadBiggerCallback() {
      public void done() {
        reloadResult[0] = true;
      }
    };
    CallbackSemaphore semaphore = new CallbackSemaphore();
    RelayOk relayOk = value.reloadHeavyValue(callback, semaphore);
    semaphore.acquireDefault(relayOk);
    assertTrue(reloadResult[0]);

    String reloadedValue = value.getValueString();

    assertTrue(shortValue.length() < reloadedValue.length());
View Full Code Here

  public static <MESSAGE, RES, EX extends Exception> RES callV8Sync(
      V8CommandSender<MESSAGE, EX> commandSender,
      MESSAGE message, final V8BlockingCallback<RES> callback, long timeoutMs)
      throws EX, MethodIsBlockingException {
    CallbackSemaphore syncCallback = new CallbackSemaphore();
    final Exception [] exBuff = { null };
    // A long way of creating buffer for generic type without warnings.
    final List<RES> resBuff = new ArrayList<RES>(Collections.nCopies(1, (RES)null));
    V8CommandProcessor.V8HandlerCallback callbackWrapper =
        new V8CommandProcessor.V8HandlerCallback() {
      @Override
      public void failure(String message) {
        exBuff[0] = new Exception("Failure: " + message);
      }

      @Override
      public void messageReceived(CommandResponse response) {
        RES result = callback.messageReceived(response);
        resBuff.set(0, result);
      }
    };
    commandSender.sendV8CommandAsync(message, true, callbackWrapper, syncCallback);

    boolean waitRes;
    try {
      waitRes = syncCallback.tryAcquire(timeoutMs, TimeUnit.MILLISECONDS);
    } catch (RuntimeException e) {
      throw new CallbackException(e);
    }

    if (!waitRes) {
View Full Code Here

public abstract class JsEvaluateContextBase implements JsEvaluateContext {
  @Override
  public void evaluateSync(String expression, Map<String, ? extends JsValue> additionalContext,
      EvaluateCallback evaluateCallback)
      throws MethodIsBlockingException {
    CallbackSemaphore callbackSemaphore = new CallbackSemaphore();
    RelayOk relayOk =
        evaluateAsync(expression, additionalContext, evaluateCallback, callbackSemaphore);
    boolean res = callbackSemaphore.tryAcquireDefault(relayOk);
    if (!res) {
      evaluateCallback.failure(new Exception("Timeout"));
    }
  }
View Full Code Here

    if (breakLine == -1) {
      throw new SmokeException("Failed to find mark in script");
    }

    // Setting a breakpoint.
    CallbackSemaphore callbackSemaphore = new CallbackSemaphore();
    Breakpoint.Target breakpointTarget = new Breakpoint.Target.ScriptName(scriptOne.getName());
    RelayOk relayOk = vm.setBreakpoint(breakpointTarget, breakLine, 0, true, null,
        null, callbackSemaphore);
    callbackSemaphore.acquireDefault(relayOk);

    // First time just suspend on breakpoint and go on.
    {
      DebugContext context = stateManager.expectEvent(EXPECT_SUSPENDED_VISITOR);
      context.continueVm(DebugContext.StepAction.CONTINUE, 0, null);
View Full Code Here

      Exception problem = null;
      Collection<? extends Breakpoint> result = null;
    }

    CallbackImpl callback = new CallbackImpl();
    CallbackSemaphore callbackSemaphore = new CallbackSemaphore();

    RelayOk relayOk = javascriptVm.listBreakpoints(callback, callbackSemaphore);
    boolean res = callbackSemaphore.tryAcquireDefault(relayOk);
    if (!res) {
      throw new RuntimeException("Timeout"); //$NON-NLS-1$
    }

    return callback.getResult();
View Full Code Here

  }

  // TODO: make sure we do not return those scripts that are reported compiled but not loaded yet.
  @Override
  public void getScripts(ScriptsCallback callback) throws MethodIsBlockingException {
    CallbackSemaphore callbackSemaphore = new CallbackSemaphore();
    RelayOk relayOk =
        getDebugSession().getScriptManagerProxy().getAllScripts(callback, callbackSemaphore);

    boolean res = callbackSemaphore.tryAcquireDefault(relayOk);
    if (!res) {
      callback.failure("Timeout");
    }
  }
View Full Code Here

    {
      boolean ownProperties = true;
      request = new GetPropertiesParams(objectId, ownProperties);
    }

    CallbackSemaphore callbackSemaphore = new CallbackSemaphore();
    RelayOk relayOk =
        tabImpl.getCommandProcessor().send(request, callback, callbackSemaphore);
    callbackSemaphore.acquireDefault(relayOk);

    return result[0];
  }
View Full Code Here

        valueBase = new ValueBase.ErrorMessageValue(evaluateContext,
            "Failed to evaluate property value: " + cause.getMessage());
      }
    }
    Callback callback = new Callback();
    CallbackSemaphore callbackSemaphore = new CallbackSemaphore();
    RelayOk relayOk = property.evaluateGet(callback, callbackSemaphore);
    callbackSemaphore.acquireDefault(relayOk);
    return callback.valueBase;
  }
View Full Code Here

      if (changer == null) {
        throw new UnsupportedOperationException();
      }

      ValueChanger.Callback callback = new ValueChanger.Callback();
      CallbackSemaphore syncCallback = new CallbackSemaphore();

      RelayOk relayOk = changer.setValue(newValue, callback, syncCallback);

      syncCallback.acquireDefault(relayOk);

      if (!callback.successful) {
        Status status;
        if (callback.exception == null) {
          status = new Status(IStatus.ERROR, ChromiumDebugPlugin.PLUGIN_ID,
View Full Code Here

TOP

Related Classes of org.chromium.sdk.CallbackSemaphore

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.