Package org.chromium.sdk

Examples of org.chromium.sdk.CallbackSemaphore


      }

      if (direction == null) {
        return;
      }
      final CallbackSemaphore callbackSemaphore = new CallbackSemaphore();
      BreakpointSynchronizer.Callback callback = new BreakpointSynchronizer.Callback() {
        public void onDone(IStatus status) {
          callbackSemaphore.callbackDone(null);
        }
      };
      workspaceBridge.getBreakpointSynchronizer().syncBreakpoints(direction, callback);
      RelayOk relayOk = SYNCHRONIZER_MUST_RELAY_OK;
      checkIsCanceled(monitor);

      BreakpointsWorkPlan.ANALYZE.finish(monitor);

      BreakpointsWorkPlan.REMOTE_CHANGES.start(monitor);
      callbackSemaphore.tryAcquireDefault(relayOk);
      BreakpointsWorkPlan.REMOTE_CHANGES.finish(monitor);

    } finally {
      monitor.done();
    }
View Full Code Here


        synchronized T get() {
          return res;
        }
      }
      CallbackImpl callback = new CallbackImpl();
      CallbackSemaphore callbackSemaphore = new CallbackSemaphore();
      RelayOk relayOk = getAsync(callback, callbackSemaphore);
      callbackSemaphore.acquireDefault(relayOk);
      return callback.get();
    }
View Full Code Here

  @Override
  public void getScripts(final ScriptsCallback callback)
      throws MethodIsBlockingException {

    final CallbackSemaphore callbackSemaphore = new CallbackSemaphore();

    GenericCallback<Collection<Script>> innerCallback;
    if (callback == null) {
      innerCallback = null;
    } else {
      innerCallback = new GenericCallback<Collection<Script>>() {
        @Override public void success(Collection<Script> value) {
          callback.success(value);
        }
        @Override public void failure(Exception exception) {
          callback.failure(exception.getMessage());
        }
      };
    }

    RelayOk relayOk = scriptManager.getScripts(innerCallback, callbackSemaphore);

    callbackSemaphore.acquireDefault(relayOk);
  }
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

          };
        }
      }
    };

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

    monitor.done();

    return input[0];
  }
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

    {
      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

public abstract class JsEvaluateContextBase implements JsEvaluateContext {
  @Override
  public void evaluateSync(String expression, Map<String, String> 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("Timeout");
    }
  }
View Full Code Here

  @Override
  public void getScripts(final ScriptsCallback callback)
      throws MethodIsBlockingException {

    final CallbackSemaphore callbackSemaphore = new CallbackSemaphore();

    GenericCallback<Collection<Script>> innerCallback;
    if (callback == null) {
      innerCallback = null;
    } else {
      innerCallback = new GenericCallback<Collection<Script>>() {
        @Override public void success(Collection<Script> value) {
          callback.success(value);
        }
        @Override public void failure(Exception exception) {
          callback.failure(exception.getMessage());
        }
      };
    }

    RelayOk relayOk = scriptManager.getScripts(innerCallback, callbackSemaphore);

    callbackSemaphore.acquireDefault(relayOk);
  }
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.