Bug 1502661 - Part 1. Add async IPC to check word by spellchecker. r=masayuki
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Sat, 17 Nov 2018 23:37:11 +0900
changeset 511371 ae2e40fee31665a104031f3ddd239919a6c9ab61
parent 511333 24f969298ec5c1a7cbc444bfc8f3d77b07f46bbe
child 511372 77ec2b95a66441cd1fa3d6a173d4ab6159407774
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmasayuki
bugs1502661
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1502661 - Part 1. Add async IPC to check word by spellchecker. r=masayuki Actually we have no async IPC for spellchecker, so I would like to add async IPC to check word. When using full check, spellchecker requests a lot of words to check word. New async IPC should allow multiple words per IPC to reduce IPC call. Differential Revision: https://phabricator.services.mozilla.com/D14835
extensions/spellcheck/hunspell/glue/PRemoteSpellcheckEngine.ipdl
extensions/spellcheck/hunspell/glue/RemoteSpellCheckEngineParent.cpp
extensions/spellcheck/hunspell/glue/RemoteSpellCheckEngineParent.h
--- a/extensions/spellcheck/hunspell/glue/PRemoteSpellcheckEngine.ipdl
+++ b/extensions/spellcheck/hunspell/glue/PRemoteSpellcheckEngine.ipdl
@@ -8,16 +8,17 @@ namespace mozilla {
 
 sync protocol PRemoteSpellcheckEngine {
   manager PContent;
 
 parent:
   async __delete__();
 
   sync Check(nsString aWord) returns (bool aIsMisspelled);
+  async CheckAsync(nsString[] aWord) returns (bool[] aIsMisspelled);
 
   sync CheckAndSuggest(nsString aWord) returns (bool aIsMisspelled, nsString[] aSuggestions);
 
   sync SetDictionary(nsString aDictionary) returns (bool success);
 
   /*
    * Set current dictionary from list of dictionary name.
    *
--- a/extensions/spellcheck/hunspell/glue/RemoteSpellCheckEngineParent.cpp
+++ b/extensions/spellcheck/hunspell/glue/RemoteSpellCheckEngineParent.cpp
@@ -40,16 +40,33 @@ mozilla::ipc::IPCResult RemoteSpellcheck
     const nsString& aWord, bool* aIsMisspelled) {
   nsresult rv = mSpellChecker->CheckWord(aWord, aIsMisspelled, nullptr);
 
   // If CheckWord failed, we can't tell whether the word is correctly spelled.
   if (NS_FAILED(rv)) *aIsMisspelled = false;
   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();
+}
+
 mozilla::ipc::IPCResult RemoteSpellcheckEngineParent::RecvCheckAndSuggest(
     const nsString& aWord, bool* aIsMisspelled,
     InfallibleTArray<nsString>* aSuggestions) {
   nsresult rv = mSpellChecker->CheckWord(aWord, aIsMisspelled, aSuggestions);
   if (NS_FAILED(rv)) {
     aSuggestions->Clear();
     *aIsMisspelled = false;
   }
--- a/extensions/spellcheck/hunspell/glue/RemoteSpellCheckEngineParent.h
+++ b/extensions/spellcheck/hunspell/glue/RemoteSpellCheckEngineParent.h
@@ -25,16 +25,19 @@ class RemoteSpellcheckEngineParent : pub
 
   virtual mozilla::ipc::IPCResult RecvSetDictionaryFromList(
       nsTArray<nsString>&& aList,
       SetDictionaryFromListResolver&& aResolve) override;
 
   virtual mozilla::ipc::IPCResult RecvCheck(const nsString& aWord,
                                             bool* aIsMisspelled) override;
 
+  virtual mozilla::ipc::IPCResult RecvCheckAsync(
+      nsTArray<nsString>&& aWord, CheckAsyncResolver&& aResolve) override;
+
   virtual mozilla::ipc::IPCResult RecvCheckAndSuggest(
       const nsString& aWord, bool* aIsMisspelled,
       InfallibleTArray<nsString>* aSuggestions) override;
 
  private:
   RefPtr<mozSpellChecker> mSpellChecker;
 };