|
1 /* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*- |
|
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/. */ |
|
5 |
|
6 #ifndef NS_ANDROIDHISTORY_H |
|
7 #define NS_ANDROIDHISTORY_H |
|
8 |
|
9 #include "IHistory.h" |
|
10 #include "nsDataHashtable.h" |
|
11 #include "nsTPriorityQueue.h" |
|
12 #include "nsIRunnable.h" |
|
13 |
|
14 #define NS_ANDROIDHISTORY_CID \ |
|
15 {0xCCAA4880, 0x44DD, 0x40A7, {0xA1, 0x3F, 0x61, 0x56, 0xFC, 0x88, 0x2C, 0x0B}} |
|
16 |
|
17 // Max size of History::mRecentlyVisitedURIs |
|
18 #define RECENTLY_VISITED_URI_SIZE 8 |
|
19 |
|
20 // Max size of History::mEmbedURIs |
|
21 #define EMBED_URI_SIZE 128 |
|
22 |
|
23 class nsAndroidHistory : public mozilla::IHistory, public nsIRunnable |
|
24 { |
|
25 public: |
|
26 NS_DECL_ISUPPORTS |
|
27 NS_DECL_IHISTORY |
|
28 NS_DECL_NSIRUNNABLE |
|
29 |
|
30 /** |
|
31 * Obtains a pointer that has had AddRef called on it. Used by the service |
|
32 * manager only. |
|
33 */ |
|
34 static nsAndroidHistory* GetSingleton(); |
|
35 |
|
36 nsAndroidHistory(); |
|
37 |
|
38 private: |
|
39 static nsAndroidHistory* sHistory; |
|
40 |
|
41 nsDataHashtable<nsStringHashKey, nsTArray<mozilla::dom::Link *> *> mListeners; |
|
42 nsTPriorityQueue<nsString> mPendingURIs; |
|
43 |
|
44 nsresult CanAddURI(nsIURI* aURI, bool* canAdd); |
|
45 |
|
46 /** |
|
47 * mRecentlyVisitedURIs remembers URIs which are recently added to the DB, |
|
48 * to avoid saving these locations repeatedly in a short period. |
|
49 */ |
|
50 typedef nsAutoTArray<nsCOMPtr<nsIURI>, RECENTLY_VISITED_URI_SIZE> |
|
51 RecentlyVisitedArray; |
|
52 RecentlyVisitedArray mRecentlyVisitedURIs; |
|
53 RecentlyVisitedArray::index_type mRecentlyVisitedURIsNextIndex; |
|
54 |
|
55 void AppendToRecentlyVisitedURIs(nsIURI* aURI); |
|
56 bool IsRecentlyVisitedURI(nsIURI* aURI); |
|
57 |
|
58 /** |
|
59 * mEmbedURIs remembers URIs which are explicitly not added to the DB, |
|
60 * to avoid wasting time on these locations. |
|
61 */ |
|
62 typedef nsAutoTArray<nsCOMPtr<nsIURI>, EMBED_URI_SIZE> EmbedArray; |
|
63 EmbedArray::index_type mEmbedURIsNextIndex; |
|
64 EmbedArray mEmbedURIs; |
|
65 |
|
66 void AppendToEmbedURIs(nsIURI* aURI); |
|
67 bool IsEmbedURI(nsIURI* aURI); |
|
68 }; |
|
69 |
|
70 #endif |