1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef mozPersonalDictionary_h__
7 #define mozPersonalDictionary_h__
11 #include "mozIPersonalDictionary.h"
12 #include "nsIObserver.h"
13 #include "nsWeakReference.h"
14 #include "nsTHashSet.h"
16 #include "nsCycleCollectionParticipant.h"
17 #include "nsHashKeys.h"
18 #include <mozilla/Monitor.h>
20 #define MOZ_PERSONALDICTIONARY_CONTRACTID \
21 "@mozilla.org/spellchecker/personaldictionary;1"
22 #define MOZ_PERSONALDICTIONARY_CID \
23 { /* 7EF52EAF-B7E1-462B-87E2-5D1DBACA9048 */ \
24 0X7EF52EAF, 0XB7E1, 0X462B, { \
25 0X87, 0XE2, 0X5D, 0X1D, 0XBA, 0XCA, 0X90, 0X48 \
29 class mozPersonalDictionaryLoader
;
30 class mozPersonalDictionarySave
;
32 class mozPersonalDictionary final
: public mozIPersonalDictionary
,
34 public nsSupportsWeakReference
{
37 NS_DECL_MOZIPERSONALDICTIONARY
40 mozPersonalDictionary();
45 virtual ~mozPersonalDictionary();
47 /* true if the dictionary has been loaded from disk */
50 /* true if a dictionary save is pending */
53 nsCOMPtr
<nsIFile
> mFile
;
54 mozilla::Monitor mMonitor MOZ_UNANNOTATED
;
55 mozilla::Monitor mMonitorSave MOZ_UNANNOTATED
;
56 nsTHashSet
<nsString
> mDictionaryTable
;
57 nsTHashSet
<nsString
> mIgnoreTable
;
60 /* wait for the asynchronous load of the dictionary to be completed */
63 /* enter the monitor before starting a synchronous load off the main-thread */
66 /* launch an asynchrounous load of the dictionary from the main-thread
67 * after successfully initializing mFile with the path of the dictionary */
68 nsresult
LoadInternal();
70 /* perform a synchronous load of the dictionary from disk */
71 void SyncLoadInternal();
73 /* wait for the asynchronous save of the dictionary to be completed */
76 friend class mozPersonalDictionaryLoader
;
77 friend class mozPersonalDictionarySave
;