mozilla::ipc::IPCResult RemoteSpellcheckEngineParent::RecvSetDictionaryFromList(
    nsTArray<nsString>&& aList, SetDictionaryFromListResolver&& aResolve) {
  for (auto& dictionary : aList) {
    nsresult rv = mSpellChecker->SetCurrentDictionary(dictionary);
    if (NS_SUCCEEDED(rv)) {
      aResolve(Tuple<const bool&, const nsString&>(true, dictionary));
      return IPC_OK();
    }
  }
  aResolve(Tuple<const bool&, const nsString&>(false, EmptyString()));
  return IPC_OK();
}
mozilla::ipc::IPCResult RemoteSpellcheckEngineParent::RecvCheckAsync(
    nsTArray<nsString>&& aWords, CheckAsyncResolver&& aResolve) {
  nsTArray<bool> misspells;
  misspells.SetCapacity(aWords.Length());
  for (auto& word : aWords) {
    bool misspelled;
    nsresult rv = mSpellChecker->CheckWord(word, &misspelled, nullptr);
    // If CheckWord failed, we can't tell whether the word is correctly spelled
    if (NS_FAILED(rv)) {
      misspelled = false;
    }
    misspells.AppendElement(misspelled);
  }
  aResolve(std::move(misspells));
  return IPC_OK();
}
Example #3
0
mozilla::ipc::IPCResult
TestAsyncReturnsChild::RecvPing(PingResolver&& aResolve)
{
  SendPong()->Then(MessageLoop::current()->SerialEventTarget(), __func__,
                   [aResolve](const Tuple<uint32_t, uint32_t>& aParam) {
                     if (Get<0>(aParam) == sMagic1 && Get<1>(aParam) == sMagic2) {
                       passed("take two arguments");
                     } else {
                       fail("get two argument but has wrong value");
                     }
                     aResolve(true);
                   },
                   [](PromiseRejectReason aReason) {
                     fail("sending Pong");
                   });
  return IPC_OK();
}
Example #4
0
mozilla::ipc::IPCResult
TestAsyncReturnsParent::RecvPong(PongResolver&& aResolve)
{
  aResolve(MakeTuple(sMagic1, sMagic2));
  return IPC_OK();
}