Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/extensions/spellcheck/hunspell/glue/RemoteSpellCheckEngineChild.cpp
Line
Count
Source (jump to first uncovered line)
1
/* This Source Code Form is subject to the terms of the Mozilla Public
2
 * License, v. 2.0. If a copy of the MPL was not distributed with this
3
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5
#include "mozilla/UniquePtr.h"
6
#include "RemoteSpellCheckEngineChild.h"
7
8
namespace mozilla {
9
10
RemoteSpellcheckEngineChild::RemoteSpellcheckEngineChild(mozSpellChecker *aOwner)
11
  : mOwner(aOwner)
12
0
{
13
0
}
14
15
RemoteSpellcheckEngineChild::~RemoteSpellcheckEngineChild()
16
0
{
17
0
  // null out the owner's SpellcheckEngineChild to prevent state corruption
18
0
  // during shutdown
19
0
  mOwner->DeleteRemoteEngine();
20
0
}
21
22
RefPtr<GenericPromise>
23
RemoteSpellcheckEngineChild::SetCurrentDictionaryFromList(
24
  const nsTArray<nsString>& aList)
25
0
{
26
0
  MozPromiseHolder<GenericPromise>* promiseHolder =
27
0
    new MozPromiseHolder<GenericPromise>();
28
0
  RefPtr<GenericPromise> promise = promiseHolder->Ensure(__func__);
29
0
  RefPtr<mozSpellChecker> spellChecker = mOwner;
30
0
31
0
  SendSetDictionaryFromList(aList)->Then(
32
0
    GetMainThreadSerialEventTarget(),
33
0
    __func__,
34
0
    [spellChecker, promiseHolder](const Tuple<bool, nsString>& aParam) {
35
0
      UniquePtr<MozPromiseHolder<GenericPromise>> holder(promiseHolder);
36
0
      if (!Get<0>(aParam)) {
37
0
        spellChecker->mCurrentDictionary.Truncate();
38
0
        holder->Reject(NS_ERROR_NOT_AVAILABLE, __func__);
39
0
        return;
40
0
      }
41
0
      spellChecker->mCurrentDictionary = Get<1>(aParam);
42
0
      holder->Resolve(true, __func__);
43
0
    },
44
0
    [spellChecker, promiseHolder](ResponseRejectReason aReason) {
45
0
      UniquePtr<MozPromiseHolder<GenericPromise>> holder(promiseHolder);
46
0
      spellChecker->mCurrentDictionary.Truncate();
47
0
      holder->Reject(NS_ERROR_NOT_AVAILABLE, __func__);
48
0
    });
49
0
  return promise;
50
0
}
51
52
} //namespace mozilla