Пример #1
0
 void executeJSCall(
     const std::string& moduleName,
     const std::string& methodName,
     const std::vector<folly::dynamic>& arguments) {
   auto returnedJSON = m_jsExecutor->executeJSCall(moduleName, methodName, arguments);
   m_callback(parseMethodCalls(returnedJSON), true /* = isEndOfBatch */);
 }
Пример #2
0
 JSThreadState(const RefPtr<JSExecutorFactory>& jsExecutorFactory, Bridge::Callback&& callback) :
   m_callback(callback)
 {
   m_jsExecutor = jsExecutorFactory->createJSExecutor([this, callback] (std::string queueJSON) {
     m_callback(parseMethodCalls(queueJSON), false /* = isEndOfBatch */);
   });
 }
Пример #3
0
  void callNativeModules(
      JSExecutor& executor, folly::dynamic&& calls, bool isEndOfBatch) override {

    CHECK(m_registry || calls.empty()) <<
      "native module calls cannot be completed with no native modules";
    m_batchHadNativeModuleCalls = m_batchHadNativeModuleCalls || !calls.empty();

    // An exception anywhere in here stops processing of the batch.  This
    // was the behavior of the Android bridge, and since exception handling
    // terminates the whole bridge, there's not much point in continuing.
    for (auto& call : parseMethodCalls(std::move(calls))) {
      m_registry->callNativeMethod(call.moduleId, call.methodId, std::move(call.arguments), call.callId);
    }
    if (isEndOfBatch) {
      // onBatchComplete will be called on the native (module) queue, but
      // decrementPendingJSCalls will be called sync. Be aware that the bridge may still
      // be processing native calls when the birdge idle signaler fires.
      if (m_batchHadNativeModuleCalls) {
        m_callback->onBatchComplete();
        m_batchHadNativeModuleCalls = false;
      }
      m_callback->decrementPendingJSCalls();
    }
  }
Пример #4
0
 void invokeCallback(const double callbackId, const folly::dynamic& arguments) {
   auto returnedJSON = m_jsExecutor->invokeCallback(callbackId, arguments);
   m_callback(parseMethodCalls(returnedJSON), true /* = isEndOfBatch */);
 }
Пример #5
0
 void callFunction(const double moduleId, const double methodId, const folly::dynamic& arguments) {
   auto returnedJSON = m_jsExecutor->callFunction(moduleId, methodId, arguments);
   m_callback(parseMethodCalls(returnedJSON), true /* = isEndOfBatch */);
 }
Пример #6
0
 void flush() {
   auto returnedJSON = m_jsExecutor->flush();
   m_callback(parseMethodCalls(returnedJSON), true /* = isEndOfBatch */);
 }