michael@0: /* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*- michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef NS_ANDROIDHISTORY_H michael@0: #define NS_ANDROIDHISTORY_H michael@0: michael@0: #include "IHistory.h" michael@0: #include "nsDataHashtable.h" michael@0: #include "nsTPriorityQueue.h" michael@0: #include "nsIRunnable.h" michael@0: michael@0: #define NS_ANDROIDHISTORY_CID \ michael@0: {0xCCAA4880, 0x44DD, 0x40A7, {0xA1, 0x3F, 0x61, 0x56, 0xFC, 0x88, 0x2C, 0x0B}} michael@0: michael@0: // Max size of History::mRecentlyVisitedURIs michael@0: #define RECENTLY_VISITED_URI_SIZE 8 michael@0: michael@0: // Max size of History::mEmbedURIs michael@0: #define EMBED_URI_SIZE 128 michael@0: michael@0: class nsAndroidHistory : public mozilla::IHistory, public nsIRunnable michael@0: { michael@0: public: michael@0: NS_DECL_ISUPPORTS michael@0: NS_DECL_IHISTORY michael@0: NS_DECL_NSIRUNNABLE michael@0: michael@0: /** michael@0: * Obtains a pointer that has had AddRef called on it. Used by the service michael@0: * manager only. michael@0: */ michael@0: static nsAndroidHistory* GetSingleton(); michael@0: michael@0: nsAndroidHistory(); michael@0: michael@0: private: michael@0: static nsAndroidHistory* sHistory; michael@0: michael@0: nsDataHashtable *> mListeners; michael@0: nsTPriorityQueue mPendingURIs; michael@0: michael@0: nsresult CanAddURI(nsIURI* aURI, bool* canAdd); michael@0: michael@0: /** michael@0: * mRecentlyVisitedURIs remembers URIs which are recently added to the DB, michael@0: * to avoid saving these locations repeatedly in a short period. michael@0: */ michael@0: typedef nsAutoTArray, RECENTLY_VISITED_URI_SIZE> michael@0: RecentlyVisitedArray; michael@0: RecentlyVisitedArray mRecentlyVisitedURIs; michael@0: RecentlyVisitedArray::index_type mRecentlyVisitedURIsNextIndex; michael@0: michael@0: void AppendToRecentlyVisitedURIs(nsIURI* aURI); michael@0: bool IsRecentlyVisitedURI(nsIURI* aURI); michael@0: michael@0: /** michael@0: * mEmbedURIs remembers URIs which are explicitly not added to the DB, michael@0: * to avoid wasting time on these locations. michael@0: */ michael@0: typedef nsAutoTArray, EMBED_URI_SIZE> EmbedArray; michael@0: EmbedArray::index_type mEmbedURIsNextIndex; michael@0: EmbedArray mEmbedURIs; michael@0: michael@0: void AppendToEmbedURIs(nsIURI* aURI); michael@0: bool IsEmbedURI(nsIURI* aURI); michael@0: }; michael@0: michael@0: #endif