Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
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/. */
6 #ifndef NS_ANDROIDHISTORY_H
7 #define NS_ANDROIDHISTORY_H
9 #include "IHistory.h"
10 #include "nsDataHashtable.h"
11 #include "nsTPriorityQueue.h"
12 #include "nsIRunnable.h"
14 #define NS_ANDROIDHISTORY_CID \
15 {0xCCAA4880, 0x44DD, 0x40A7, {0xA1, 0x3F, 0x61, 0x56, 0xFC, 0x88, 0x2C, 0x0B}}
17 // Max size of History::mRecentlyVisitedURIs
18 #define RECENTLY_VISITED_URI_SIZE 8
20 // Max size of History::mEmbedURIs
21 #define EMBED_URI_SIZE 128
23 class nsAndroidHistory : public mozilla::IHistory, public nsIRunnable
24 {
25 public:
26 NS_DECL_ISUPPORTS
27 NS_DECL_IHISTORY
28 NS_DECL_NSIRUNNABLE
30 /**
31 * Obtains a pointer that has had AddRef called on it. Used by the service
32 * manager only.
33 */
34 static nsAndroidHistory* GetSingleton();
36 nsAndroidHistory();
38 private:
39 static nsAndroidHistory* sHistory;
41 nsDataHashtable<nsStringHashKey, nsTArray<mozilla::dom::Link *> *> mListeners;
42 nsTPriorityQueue<nsString> mPendingURIs;
44 nsresult CanAddURI(nsIURI* aURI, bool* canAdd);
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;
55 void AppendToRecentlyVisitedURIs(nsIURI* aURI);
56 bool IsRecentlyVisitedURI(nsIURI* aURI);
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;
66 void AppendToEmbedURIs(nsIURI* aURI);
67 bool IsEmbedURI(nsIURI* aURI);
68 };
70 #endif