--- a/content/base/src/nsContentSink.cpp
+++ b/content/base/src/nsContentSink.cpp
@@ -844,34 +844,38 @@ nsContentSink::GetOfflineCacheSession(ns
}
nsresult
nsContentSink::AddOfflineResource(const nsAString &aHref)
{
PRBool match;
nsresult rv;
+ nsCOMPtr<nsIURI> innerURI = NS_GetInnermostURI(mDocumentURI);
+ if (!innerURI)
+ return NS_ERROR_FAILURE;
+
nsCAutoString ownerHost;
- rv = mDocumentURI->GetHostPort(ownerHost);
+ rv = innerURI->GetHostPort(ownerHost);
NS_ENSURE_SUCCESS(rv, rv);
nsCAutoString ownerSpec;
rv = mDocumentURI->GetSpec(ownerSpec);
NS_ENSURE_SUCCESS(rv, rv);
if (!mHaveOfflineResources) {
mHaveOfflineResources = PR_TRUE;
mSaveOfflineResources = PR_FALSE;
// only let http and https urls add offline resources
- nsresult rv = mDocumentURI->SchemeIs("http", &match);
+ nsresult rv = innerURI->SchemeIs("http", &match);
NS_ENSURE_SUCCESS(rv, rv);
if (!match) {
- rv = mDocumentURI->SchemeIs("https", &match);
+ rv = innerURI->SchemeIs("https", &match);
NS_ENSURE_SUCCESS(rv, rv);
if (!match)
return NS_OK;
}
nsCOMPtr<nsIOfflineCacheSession> session;
rv = GetOfflineCacheSession(getter_AddRefs(session));
NS_ENSURE_SUCCESS(rv, rv);
--- a/dom/public/idl/Makefile.in
+++ b/dom/public/idl/Makefile.in
@@ -52,16 +52,17 @@ DIRS = \
sidebar \
css \
traversal \
range \
xbl \
xpath \
ls \
xul \
- storage
+ storage \
+ offline
ifdef MOZ_SVG
DIRS += svg
endif
include $(topsrcdir)/config/rules.mk
--- a/dom/public/idl/base/nsIDOMClientInformation.idl
+++ b/dom/public/idl/base/nsIDOMClientInformation.idl
@@ -32,22 +32,26 @@
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "domstubs.idl"
-[scriptable, uuid(abbb51a4-be75-4d7f-bd4c-373fd7b52f85)]
+interface nsIDOMOfflineResourceList;
+
+[scriptable, uuid(609439fa-63e4-4f71-9512-904867f154e7)]
interface nsIDOMClientInformation : nsISupports
{
/**
* Web Applications 1.0 Browser State: registerContentHandler
* Allows web services to register themselves as handlers for certain content
* types.
* http://whatwg.org/specs/web-apps/current-work/
*/
void registerContentHandler(in DOMString mimeType, in DOMString uri, in DOMString title);
void registerProtocolHandler(in DOMString protocol, in DOMString uri, in DOMString title);
+
+ readonly attribute nsIDOMOfflineResourceList offlineResources;
};
new file mode 100644
--- /dev/null
+++ b/dom/public/idl/offline/Makefile.in
@@ -0,0 +1,53 @@
+#
+# ***** BEGIN LICENSE BLOCK *****
+# Version: MPL 1.1/GPL 2.0/LGPL 2.1
+#
+# The contents of this file are subject to the Mozilla Public License Version
+# 1.1 (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+# http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+# for the specific language governing rights and limitations under the
+# License.
+#
+# The Original Code is mozilla.org code.
+#
+# The Initial Developer of the Original Code is
+# Mozilla Corporation
+# Portions created by the Initial Developer are Copyright (C) 2006
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+#
+# Alternatively, the contents of this file may be used under the terms of
+# either of the GNU General Public License Version 2 or later (the "GPL"),
+# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+# in which case the provisions of the GPL or the LGPL are applicable instead
+# of those above. If you wish to allow use of your version of this file only
+# under the terms of either the GPL or the LGPL, and not to allow others to
+# use your version of this file under the terms of the MPL, indicate your
+# decision by deleting the provisions above and replace them with the notice
+# and other provisions required by the GPL or the LGPL. If you do not delete
+# the provisions above, a recipient may use your version of this file under
+# the terms of any one of the MPL, the GPL or the LGPL.
+#
+# ***** END LICENSE BLOCK *****
+
+DEPTH = ../../../..
+topsrcdir = @top_srcdir@
+srcdir = @srcdir@
+VPATH = @srcdir@
+
+include $(DEPTH)/config/autoconf.mk
+
+MODULE = dom
+XPIDL_MODULE = dom_offline
+GRE_MODULE = 1
+
+SDK_XPIDLSRCS = \
+ nsIDOMOfflineResourceList.idl \
+ $(NULL)
+
+include $(topsrcdir)/config/rules.mk
new file mode 100644
--- /dev/null
+++ b/dom/public/idl/offline/nsIDOMOfflineResourceList.idl
@@ -0,0 +1,53 @@
+/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is
+ * Mozilla Corporation
+ * Portions created by the Initial Developer are Copyright (C) 2007
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Dave Camp <dcamp@mozilla.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#include "domstubs.idl"
+
+[scriptable, uuid(8449bce2-0d8c-4c74-ab79-b41b8d81f1c4)]
+interface nsIDOMOfflineResourceList : nsISupports
+{
+ readonly attribute unsigned long length;
+ DOMString item(in unsigned long index);
+
+ void add(in DOMString uri);
+ void remove(in DOMString uri);
+ boolean has(in DOMString uri);
+ void clear();
+
+ void refresh();
+};
--- a/dom/public/nsDOMClassInfoID.h
+++ b/dom/public/nsDOMClassInfoID.h
@@ -387,16 +387,18 @@ enum nsDOMClassInfoID {
#if defined(MOZ_SVG) && defined(MOZ_SVG_FOREIGNOBJECT)
eDOMClassInfo_SVGForeignObjectElement_id,
#endif
eDOMClassInfo_XULCommandEvent_id,
eDOMClassInfo_CommandEvent_id,
+ eDOMClassInfo_OfflineResourceList_id,
+
// This one better be the last one in this list
eDOMClassInfoIDCount
};
/**
* nsIClassInfo helper macros
*/
--- a/dom/src/Makefile.in
+++ b/dom/src/Makefile.in
@@ -37,17 +37,17 @@
DEPTH = ../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
-DIRS = base jsurl events storage
+DIRS = base jsurl events storage offline
include $(topsrcdir)/config/rules.mk
_FILES = \
$(srcdir)/res/hiddenWindow.html \
$(NULL)
libs::
--- a/dom/src/base/Makefile.in
+++ b/dom/src/base/Makefile.in
@@ -56,16 +56,17 @@ REQUIRES = xpcom \
layout \
content \
caps \
docshell \
xpconnect \
pref \
oji \
necko \
+ nkcache \
mimetype \
java \
locale \
uriloader \
xuldoc \
webshell \
view \
uconv \
@@ -115,16 +116,17 @@ CPPSRCS = \
# we don't want the shared lib, but we want to force the creation of a
# static lib.
FORCE_STATIC_LIB = 1
LOCAL_INCLUDES = \
-I$(srcdir)/../events \
-I$(srcdir)/../storage \
+ -I$(srcdir)/../offline \
-I$(topsrcdir)/content/xbl/src \
-I$(topsrcdir)/content/xul/document/src \
-I$(topsrcdir)/content/events/src \
-I$(topsrcdir)/content/base/src \
$(NULL)
DEFINES += -D_IMPL_NS_LAYOUT
--- a/dom/src/base/nsDOMClassInfo.cpp
+++ b/dom/src/base/nsDOMClassInfo.cpp
@@ -1157,16 +1157,19 @@ static nsDOMClassInfoData sClassInfoData
ELEMENT_SCRIPTABLE_FLAGS)
#endif
NS_DEFINE_CLASSINFO_DATA(XULCommandEvent, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(CommandEvent, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
+
+ NS_DEFINE_CLASSINFO_DATA(OfflineResourceList, nsOfflineResourceListSH,
+ ARRAY_SCRIPTABLE_FLAGS)
};
// Objects that shuld be constructable through |new Name();|
struct nsContractIDMapData
{
PRInt32 mDOMClassInfoID;
const char *mContractID;
};
@@ -3163,16 +3166,20 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_UI_EVENT_MAP_ENTRIES
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(CommandEvent, nsIDOMCommandEvent)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMCommandEvent)
DOM_CLASSINFO_EVENT_MAP_ENTRIES
DOM_CLASSINFO_MAP_END
+ DOM_CLASSINFO_MAP_BEGIN(OfflineResourceList, nsIDOMOfflineResourceList)
+ DOM_CLASSINFO_MAP_ENTRY(nsIDOMOfflineResourceList)
+ DOM_CLASSINFO_MAP_END
+
#ifdef NS_DEBUG
{
PRUint32 i = NS_ARRAY_LENGTH(sClassInfoData);
if (i != eDOMClassInfoIDCount) {
NS_ERROR("The number of items in sClassInfoData doesn't match the "
"number of nsIDOMClassInfo ID's, this is bad! Fix it!");
@@ -10001,8 +10008,19 @@ nsNonDOMObjectSH::GetFlags(PRUint32 *aFl
NS_IMETHODIMP
nsAttributeSH::GetFlags(PRUint32 *aFlags)
{
// Just like nsNodeSH, but without CONTENT_NODE
*aFlags = DOMCLASSINFO_STANDARD_FLAGS;
return NS_OK;
}
+
+// nsOfflineResourceListSH
+nsresult
+nsOfflineResourceListSH::GetStringAt(nsISupports *aNative, PRInt32 aIndex,
+ nsAString& aResult)
+{
+ nsCOMPtr<nsIDOMOfflineResourceList> list(do_QueryInterface(aNative));
+ NS_ENSURE_TRUE(list, NS_ERROR_UNEXPECTED);
+
+ return list->Item(aIndex, aResult);
+}
--- a/dom/src/base/nsDOMClassInfo.h
+++ b/dom/src/base/nsDOMClassInfo.h
@@ -1574,12 +1574,35 @@ public:
NS_IMETHOD GetFlags(PRUint32 *aFlags);
static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
{
return new nsAttributeSH(aData);
}
};
+class nsOfflineResourceListSH : public nsStringArraySH
+{
+protected:
+ nsOfflineResourceListSH(nsDOMClassInfoData* aData) : nsStringArraySH(aData)
+ {
+ }
+
+ virtual ~nsOfflineResourceListSH()
+ {
+ }
+
+ virtual nsresult GetStringAt(nsISupports *aNative, PRInt32 aIndex,
+ nsAString& aResult);
+
+public:
+ static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
+ {
+ return new nsOfflineResourceListSH(aData);
+ }
+};
+
+
+
void InvalidateContextAndWrapperCache();
#endif /* nsDOMClassInfo_h___ */
--- a/dom/src/base/nsGlobalWindow.cpp
+++ b/dom/src/base/nsGlobalWindow.cpp
@@ -45,16 +45,17 @@
* ***** END LICENSE BLOCK ***** */
// Local Includes
#include "nsGlobalWindow.h"
#include "nsScreen.h"
#include "nsHistory.h"
#include "nsBarProps.h"
#include "nsDOMStorage.h"
+#include "nsDOMOfflineResourceList.h"
#include "nsDOMError.h"
// Helper Classes
#include "nsXPIDLString.h"
#include "nsJSUtils.h"
#include "prmem.h"
#include "jsapi.h" // for JSAutoRequest
#include "jsdbgapi.h" // for JS_ClearWatchPointsForObject
@@ -99,16 +100,17 @@
#include "nsIDOMElement.h"
#include "nsIDOMDocumentEvent.h"
#include "nsIDOMEvent.h"
#include "nsIDOMHTMLDocument.h"
#include "nsIDOMHTMLElement.h"
#include "nsIDOMKeyEvent.h"
#include "nsIDOMPopupBlockedEvent.h"
#include "nsIDOMPkcs11.h"
+#include "nsIDOMOfflineResourceList.h"
#include "nsDOMString.h"
#include "nsIEmbeddingSiteWindow2.h"
#include "nsThreadUtils.h"
#include "nsIEventStateManager.h"
#include "nsIHttpProtocolHandler.h"
#include "nsIJSContextStack.h"
#include "nsIJSRuntimeService.h"
#include "nsIMarkupDocumentViewer.h"
@@ -8410,16 +8412,17 @@ nsNavigator::Preference()
void
nsNavigator::LoadingNewDocument()
{
// Release these so that they will be recreated for the
// new document (if requested). The plugins or mime types
// arrays may have changed. See bug 150087.
mMimeTypes = nsnull;
mPlugins = nsnull;
+ mOfflineResources = nsnull;
}
nsresult
nsNavigator::RefreshMIMEArray()
{
nsresult rv = NS_OK;
if (mMimeTypes)
rv = mMimeTypes->Refresh();
@@ -8458,8 +8461,39 @@ nsNavigator::RegisterProtocolHandler(con
nsCOMPtr<nsIDOMWindow> contentDOMWindow(do_GetInterface(mDocShell));
if (contentDOMWindow)
return registrar->RegisterProtocolHandler(aProtocol, aURI, aTitle,
contentDOMWindow);
}
return NS_OK;
}
+
+NS_IMETHODIMP
+nsNavigator::GetOfflineResources(nsIDOMOfflineResourceList **aList)
+{
+ NS_ENSURE_ARG_POINTER(aList);
+
+ if (!mOfflineResources) {
+ nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(GetDocShell()));
+ if (!webNav) {
+ return NS_ERROR_FAILURE;
+ }
+
+ nsCOMPtr<nsIURI> uri;
+ nsresult rv = webNav->GetCurrentURI(getter_AddRefs(uri));
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ mOfflineResources = new nsDOMOfflineResourceList();
+ if (!mOfflineResources) return NS_ERROR_OUT_OF_MEMORY;
+
+ rv = mOfflineResources->Init(uri);
+ if (NS_FAILED(rv)) {
+ mOfflineResources = nsnull;
+ return rv;
+ }
+ }
+
+ NS_IF_ADDREF(*aList = mOfflineResources);
+
+ return NS_OK;
+}
+
--- a/dom/src/base/nsGlobalWindow.h
+++ b/dom/src/base/nsGlobalWindow.h
@@ -89,16 +89,17 @@
#include "nsIXPCScriptable.h"
#include "nsPoint.h"
#include "nsSize.h"
#include "mozFlushType.h"
#include "prclist.h"
#include "nsIDOMStorage.h"
#include "nsIDOMStorageList.h"
#include "nsIDOMStorageWindow.h"
+#include "nsIDOMOfflineResourceList.h"
#include "nsPIDOMEventTarget.h"
#define DEFAULT_HOME_PAGE "www.mozilla.org"
#define PREF_BROWSER_STARTUP_HOMEPAGE "browser.startup.homepage"
class nsIDOMBarProp;
class nsIDocument;
class nsIContent;
@@ -112,16 +113,18 @@ class nsLocation;
class nsNavigator;
class nsScreen;
class nsHistory;
class nsIDocShellLoadInfo;
class WindowStateHolder;
class nsGlobalWindowObserver;
class nsGlobalWindow;
+class nsDOMOfflineResourceList;
+
// permissible values for CheckOpenAllow
enum OpenAllowValue {
allowNot = 0, // the window opening is denied
allowNoAbuse, // allowed: not a popup
allowWhitelisted // allowed: it's whitelisted or popup blocking is disabled
};
extern nsresult
@@ -749,16 +752,17 @@ public:
}
void LoadingNewDocument();
nsresult RefreshMIMEArray();
protected:
nsRefPtr<nsMimeTypeArray> mMimeTypes;
nsRefPtr<nsPluginArray> mPlugins;
+ nsRefPtr<nsDOMOfflineResourceList> mOfflineResources;
nsIDocShell* mDocShell; // weak reference
static jsval sPrefInternal_id;
};
class nsIURI;
//*****************************************************************************
new file mode 100644
--- /dev/null
+++ b/dom/src/offline/Makefile.in
@@ -0,0 +1,76 @@
+#
+# ***** BEGIN LICENSE BLOCK *****
+# Version: MPL 1.1/GPL 2.0/LGPL 2.1
+#
+# The contents of this file are subject to the Mozilla Public License Version
+# 1.1 (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+# http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+# for the specific language governing rights and limitations under the
+# License.
+#
+# The Original Code is mozilla.org code.
+#
+# The Initial Developer of the Original Code is
+# Mozilla Corporation
+# Portions created by the Initial Developer are Copyright (C) 2007
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+#
+# Alternatively, the contents of this file may be used under the terms of
+# either of the GNU General Public License Version 2 or later (the "GPL"),
+# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+# in which case the provisions of the GPL or the LGPL are applicable instead
+# of those above. If you wish to allow use of your version of this file only
+# under the terms of either the GPL or the LGPL, and not to allow others to
+# use your version of this file under the terms of the MPL, indicate your
+# decision by deleting the provisions above and replace them with the notice
+# and other provisions required by the GPL or the LGPL. If you do not delete
+# the provisions above, a recipient may use your version of this file under
+# the terms of any one of the MPL, the GPL or the LGPL.
+#
+# ***** END LICENSE BLOCK *****
+
+DEPTH = ../../..
+topsrcdir = @top_srcdir@
+srcdir = @srcdir@
+VPATH = @srcdir@
+
+include $(DEPTH)/config/autoconf.mk
+
+MODULE = dom
+LIBRARY_NAME = jsdomoffline_s
+LIBXUL_LIBRARY = 1
+
+REQUIRES = xpcom \
+ string \
+ content \
+ caps \
+ js \
+ layout \
+ necko \
+ nkcache \
+ pref \
+ prefetch \
+ widget \
+ xpconnect \
+ $(NULL)
+
+CPPSRCS = \
+ nsDOMOfflineResourceList.cpp \
+ $(NULL)
+
+# we don't want the shared lib, but we want to force the creation of a static lib.
+FORCE_STATIC_LIB = 1
+
+LOCAL_INCLUDES = \
+ -I$(srcdir)/../base \
+ -I$(topsrcdir)/content/events/src
+
+DEFINES += -D_IMPL_NS_LAYOUT
+
+include $(topsrcdir)/config/rules.mk
new file mode 100644
--- /dev/null
+++ b/dom/src/offline/nsDOMOfflineResourceList.cpp
@@ -0,0 +1,310 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is
+ * Mozilla Corporation
+ * Portions created by the Initial Developer are Copyright (C) 2007
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Dave Camp <dcamp@mozilla.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#include "nsDOMOfflineResourceList.h"
+#include "nsDOMClassInfo.h"
+#include "nsDOMError.h"
+#include "nsIPrefetchService.h"
+#include "nsCPrefetchService.h"
+#include "nsNetUtil.h"
+#include "nsNetCID.h"
+#include "nsICacheSession.h"
+#include "nsICacheService.h"
+#include "nsIOfflineCacheSession.h"
+#include "nsAutoPtr.h"
+#include "nsContentUtils.h"
+
+// To prevent abuse of the resource list for data storage, the number
+// of offline urls and their length are limited.
+
+static const char kMaxEntriesPref[] = "offline.max_site_resources";
+#define DEFAULT_MAX_ENTRIES 100
+#define MAX_URI_LENGTH 2048
+
+static nsCAutoString gCachedHostPort;
+static char **gCachedKeys = nsnull;
+static PRUint32 gCachedKeysCount = 0;
+
+//
+// nsDOMOfflineResourceList
+//
+
+NS_INTERFACE_MAP_BEGIN(nsDOMOfflineResourceList)
+ NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMOfflineResourceList)
+ NS_INTERFACE_MAP_ENTRY(nsIDOMOfflineResourceList)
+ NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(OfflineResourceList)
+NS_INTERFACE_MAP_END
+
+NS_IMPL_ADDREF(nsDOMOfflineResourceList)
+NS_IMPL_RELEASE(nsDOMOfflineResourceList)
+
+nsDOMOfflineResourceList::nsDOMOfflineResourceList()
+{
+}
+
+nsDOMOfflineResourceList::~nsDOMOfflineResourceList()
+{
+}
+
+nsresult
+nsDOMOfflineResourceList::Init(nsIURI *aURI)
+{
+ mURI = aURI;
+
+ nsCOMPtr<nsIURI> innerURI = NS_GetInnermostURI(aURI);
+ if (!innerURI)
+ return NS_ERROR_FAILURE;
+
+ nsresult rv = innerURI->GetHostPort(mHostPort);
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ nsCOMPtr<nsICacheService> serv = do_GetService(NS_CACHESERVICE_CONTRACTID,
+ &rv);
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ nsCOMPtr<nsICacheSession> session;
+ rv = serv->CreateSession("HTTP-offline",
+ nsICache::STORE_OFFLINE,
+ nsICache::STREAM_BASED,
+ getter_AddRefs(session));
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ mCacheSession = do_QueryInterface(session, &rv);
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ return NS_OK;
+}
+
+//
+// nsDOMOfflineResourceList::nsIDOMOfflineResourceList
+//
+
+NS_IMETHODIMP
+nsDOMOfflineResourceList::GetLength(PRUint32 *aLength)
+{
+ nsresult rv = CacheKeys();
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ *aLength = gCachedKeysCount;
+ return NS_OK;
+}
+
+NS_IMETHODIMP
+nsDOMOfflineResourceList::Item(PRUint32 aIndex, nsAString& aURI)
+{
+ SetDOMStringToNull(aURI);
+
+ nsresult rv = CacheKeys();
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ if (aIndex >= gCachedKeysCount)
+ return NS_ERROR_NOT_AVAILABLE;
+
+ CopyUTF8toUTF16(gCachedKeys[aIndex], aURI);
+
+ return NS_OK;
+}
+
+NS_IMETHODIMP
+nsDOMOfflineResourceList::Add(const nsAString& aURI)
+{
+ if (aURI.Length() > MAX_URI_LENGTH) return NS_ERROR_DOM_BAD_URI;
+
+ // this will fail if the URI is not absolute
+ nsCOMPtr<nsIURI> requestedURI;
+ nsresult rv = NS_NewURI(getter_AddRefs(requestedURI), aURI);
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ // only http/https urls will work offline
+ PRBool match;
+ rv = requestedURI->SchemeIs("http", &match);
+ NS_ENSURE_SUCCESS(rv, rv);
+ if (!match) {
+ rv = requestedURI->SchemeIs("https", &match);
+ NS_ENSURE_SUCCESS(rv, rv);
+ if (!match) return NS_ERROR_DOM_BAD_URI;
+ }
+
+ PRUint32 length;
+ rv = GetLength(&length);
+ NS_ENSURE_SUCCESS(rv, rv);
+ PRUint32 maxEntries = nsContentUtils::GetIntPref(kMaxEntriesPref,
+ DEFAULT_MAX_ENTRIES);
+
+ if (length > maxEntries) return NS_ERROR_NOT_AVAILABLE;
+
+ ClearCachedKeys();
+
+ nsCAutoString key;
+ rv = GetCacheKey(requestedURI, key);
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ rv = mCacheSession->AddOwnedKey(mHostPort,
+ NS_LITERAL_CSTRING(""),
+ key);
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ nsCOMPtr<nsIPrefetchService> prefetchService =
+ do_GetService(NS_PREFETCHSERVICE_CONTRACTID, &rv);
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ return prefetchService->PrefetchURIForOfflineUse(requestedURI,
+ mURI,
+ PR_TRUE);
+}
+
+NS_IMETHODIMP
+nsDOMOfflineResourceList::Remove(const nsAString& aURI)
+{
+ nsCAutoString key;
+ nsresult rv = GetCacheKey(aURI, key);
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ ClearCachedKeys();
+
+ return mCacheSession->RemoveOwnedKey(mHostPort,
+ NS_LITERAL_CSTRING(""),
+ key);
+}
+
+NS_IMETHODIMP
+nsDOMOfflineResourceList::Has(const nsAString& aURI, PRBool *aExists)
+{
+ nsCAutoString key;
+ nsresult rv = GetCacheKey(aURI, key);
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ return mCacheSession->KeyIsOwned(mHostPort, NS_LITERAL_CSTRING(""),
+ key, aExists);
+}
+
+NS_IMETHODIMP
+nsDOMOfflineResourceList::Clear()
+{
+ ClearCachedKeys();
+
+ return mCacheSession->SetOwnedKeys(mHostPort,
+ NS_LITERAL_CSTRING(""),
+ 0, nsnull);
+}
+
+NS_IMETHODIMP
+nsDOMOfflineResourceList::Refresh()
+{
+ nsresult rv = CacheKeys();
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ // try to start fetching it now, but it's not fatal if it fails
+ nsCOMPtr<nsIPrefetchService> prefetchService =
+ do_GetService(NS_PREFETCHSERVICE_CONTRACTID, &rv);
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ for (PRUint32 i = 0; i < gCachedKeysCount; i++) {
+ // this will fail if the URI is not absolute
+ nsCOMPtr<nsIURI> requestedURI;
+ nsresult rv = NS_NewURI(getter_AddRefs(requestedURI), gCachedKeys[i]);
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ rv = prefetchService->PrefetchURIForOfflineUse(requestedURI,
+ mURI,
+ PR_TRUE);
+ NS_ENSURE_SUCCESS(rv, rv);
+ }
+
+ return NS_OK;
+}
+
+nsresult
+nsDOMOfflineResourceList::GetCacheKey(const nsAString &aURI, nsCString &aKey)
+{
+ nsCOMPtr<nsIURI> requestedURI;
+ nsresult rv = NS_NewURI(getter_AddRefs(requestedURI), aURI);
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ return GetCacheKey(requestedURI, aKey);
+}
+
+nsresult
+nsDOMOfflineResourceList::GetCacheKey(nsIURI *aURI, nsCString &aKey)
+{
+ nsresult rv = aURI->GetSpec(aKey);
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ // url fragments aren't used in cache keys
+ nsCAutoString::const_iterator specStart, specEnd;
+ aKey.BeginReading(specStart);
+ aKey.EndReading(specEnd);
+ if (FindCharInReadable('#', specStart, specEnd)) {
+ aKey.BeginReading(specEnd);
+ aKey = Substring(specEnd, specStart);
+ }
+
+ return NS_OK;
+}
+
+nsresult
+nsDOMOfflineResourceList::CacheKeys()
+{
+ if (gCachedKeys && mHostPort == gCachedHostPort)
+ return NS_OK;
+
+ ClearCachedKeys();
+
+ nsresult rv = mCacheSession->GetOwnedKeys(mHostPort, NS_LITERAL_CSTRING(""),
+ &gCachedKeysCount, &gCachedKeys);
+
+ if (NS_SUCCEEDED(rv))
+ gCachedHostPort = mHostPort;
+
+ return rv;
+}
+
+void
+nsDOMOfflineResourceList::ClearCachedKeys()
+{
+ if (gCachedKeys) {
+ NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(gCachedKeysCount, gCachedKeys);
+ gCachedKeys = nsnull;
+ gCachedKeysCount = 0;
+ }
+
+ gCachedHostPort = "";
+}
+
+
+
new file mode 100644
--- /dev/null
+++ b/dom/src/offline/nsDOMOfflineResourceList.h
@@ -0,0 +1,73 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is mozilla.org code.
+ *
+ * The Initial Developer of the Original Code is
+ * Mozilla Corporation
+ * Portions created by the Initial Developer are Copyright (C) 2007
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Dave Camp <dcamp@mozilla.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef nsDOMOfflineResourceList_h___
+#define nsDOMOfflineResourceList_h___
+
+#include "nscore.h"
+#include "nsIDOMOfflineResourceList.h"
+#include "nsIOfflineCacheSession.h"
+#include "nsTArray.h"
+#include "nsString.h"
+#include "nsIURI.h"
+#include "nsCOMPtr.h"
+
+class nsDOMOfflineResourceList : public nsIDOMOfflineResourceList
+{
+public:
+ NS_DECL_ISUPPORTS
+ NS_DECL_NSIDOMOFFLINERESOURCELIST
+
+ nsDOMOfflineResourceList();
+ virtual ~nsDOMOfflineResourceList();
+
+ nsresult Init(nsIURI *aURI);
+
+private:
+ nsresult GetCacheKey(const nsAString &aURI, nsCString &aKey);
+ nsresult GetCacheKey(nsIURI *aURI, nsCString &aKey);
+
+ nsresult CacheKeys();
+ void ClearCachedKeys();
+
+ nsCOMPtr<nsIURI> mURI;
+ nsCOMPtr<nsIOfflineCacheSession> mCacheSession;
+ nsCAutoString mHostPort;
+};
+
+#endif
--- a/dom/tests/mochitest/ajax/Makefile.in
+++ b/dom/tests/mochitest/ajax/Makefile.in
@@ -39,11 +39,12 @@ DEPTH = ../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
DIRS = lib \
prototype \
+ offline \
$(NULL)
include $(topsrcdir)/config/rules.mk
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/dom/tests/mochitest/ajax/offline/Makefile.in
@@ -0,0 +1,53 @@
+#
+# ***** BEGIN LICENSE BLOCK *****
+# Version: MPL 1.1/GPL 2.0/LGPL 2.1
+#
+# The contents of this file are subject to the Mozilla Public License Version
+# 1.1 (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+# http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+# for the specific language governing rights and limitations under the
+# License.
+#
+# The Original Code is mozilla.org code.
+#
+# The Initial Developer of the Original Code is
+# Mozilla Foundation.
+# Portions created by the Initial Developer are Copyright (C) 2007
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+#
+# Alternatively, the contents of this file may be used under the terms of
+# either of the GNU General Public License Version 2 or later (the "GPL"),
+# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+# in which case the provisions of the GPL or the LGPL are applicable instead
+# of those above. If you wish to allow use of your version of this file only
+# under the terms of either the GPL or the LGPL, and not to allow others to
+# use your version of this file under the terms of the MPL, indicate your
+# decision by deleting the provisions above and replace them with the notice
+# and other provisions required by the GPL or the LGPL. If you do not delete
+# the provisions above, a recipient may use your version of this file under
+# the terms of any one of the MPL, the GPL or the LGPL.
+#
+# ***** END LICENSE BLOCK *****
+
+DEPTH = ../../../../..
+topsrcdir = @top_srcdir@
+srcdir = @srcdir@
+VPATH = @srcdir@
+relativesrcdir = dom/tests/mochitest/ajax/offline
+
+include $(DEPTH)/config/autoconf.mk
+
+include $(topsrcdir)/config/rules.mk
+
+_TEST_FILES = \
+ test_offlineResources.html \
+ $(NULL)
+
+libs:: $(_TEST_FILES)
+ $(INSTALL) $^ $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/dom/tests/mochitest/ajax/offline/test_offlineResources.html
@@ -0,0 +1,150 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<title>navigator.offlineResources Test</title>
+<script type="text/javascript" src="/MochiKit/packed.js"></script>
+<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+
+<script type="text/javascript">
+
+netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+
+var nsICache = Components.interfaces.nsICache;
+var base = window.location.protocol + "//" + window.location.host;
+var packedURL = base + "/MochiKit/packed.js";
+var simpleTestURL = base + "/tests/SimpleTest/SimpleTest.js";
+var thisURL = base + window.location.pathname;
+
+function check_cache(url, expectEntry)
+{
+ var cacheService = Components.classes["@mozilla.org/network/cache-service;1"]
+ .getService(Components.interfaces.nsICacheService);
+ var cacheSession = cacheService.createSession("HTTP-offline",
+ nsICache.STORE_OFFLINE,
+ true);
+ try {
+ var entry = cacheSession.openCacheEntry(url, nsICache.ACCESS_READ, true);
+ ok(expectEntry == true, url + " should exist in the offline cache");
+ entry.close();
+ } catch (e) {
+ // this constant isn't in Components.results
+ const kNetBase = 2152398848; // 0x804B0000
+ var NS_ERROR_CACHE_KEY_NOT_FOUND = kNetBase + 61
+ if (e.result == NS_ERROR_CACHE_KEY_NOT_FOUND) {
+ ok(expectEntry == false, url + " should not exist in the offline cache");
+ } else {
+ throw e;
+ }
+ }
+}
+
+function check_list(array)
+{
+ var checkObj = {};
+ for (var i = 0; i < array.length; i++) {
+ checkObj[array[i]] = true;
+ }
+ for (var i = 0; i < navigator.offlineResources.length; i++) {
+ ok (navigator.offlineResources[i] in checkObj,
+ navigator.offlineResources[i] + " should not be in offlineResources");
+ delete checkObj[navigator.offlineResources[i]];
+ }
+
+ for (var key in checkObj) {
+ ok(false, key + " was not in navigator.offlineResources");
+ }
+}
+
+function run_eviction()
+{
+ var cacheService = Components.classes["@mozilla.org/network/cache-service;1"]
+ .getService(Components.interfaces.nsICacheService);
+ var cacheSession = cacheService.createSession("HTTP-offline",
+ nsICache.STORE_OFFLINE,
+ true)
+ .QueryInterface(Components.interfaces.nsIOfflineCacheSession);
+ cacheSession.evictUnownedEntries();
+}
+
+function clear_cache()
+{
+ var cacheService = Components.classes["@mozilla.org/network/cache-service;1"]
+ .getService(Components.interfaces.nsICacheService);
+
+ cacheService.evictEntries(nsICache.STORE_OFFLINE);
+}
+
+function load_done() {
+ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+ check_list([packedURL, simpleTestURL, thisURL]);
+
+ check_cache(packedURL, true);
+ check_cache(simpleTestURL, true);
+ check_cache(thisURL, true);
+
+ navigator.offlineResources.remove(packedURL);
+ run_eviction();
+
+ check_list([simpleTestURL, thisURL]);
+
+ // Make sure the removed entry was evicted but the others weren't
+ check_cache(packedURL, false);
+ check_cache(simpleTestURL, true);
+ check_cache(thisURL, true);
+
+ navigator.offlineResources.clear();
+ run_eviction();
+
+ check_list([]);
+
+ check_cache(packedURL, false);
+ check_cache(simpleTestURL, false);
+ check_cache(thisURL, false);
+
+ // Clear out the offline cache on the way out
+ clear_cache();
+ SimpleTest.finish();
+}
+
+function run_test()
+{
+ // Clear the offline cache to make sure we're the one adding to it
+ clear_cache();
+
+ // Check invalid urls
+ try {
+ navigator.offlineResources.add("/blah/blah");
+ ok(false, "relative URLs cannot be added");
+ } catch(e) {
+ ok(true, "relative URLs should throw an error");
+ }
+
+ try {
+ navigator.offlineResources.add("ftp://localhost/blah/blah");
+ ok(false, "urls must be http or https");
+ } catch(e) {
+ ok(true, "urls must be http or https");
+ }
+
+ // Add the correct resources
+ navigator.offlineResources.add(packedURL);
+ navigator.offlineResources.add(simpleTestURL);
+ navigator.offlineResources.add(thisURL);
+
+ // Give the offline resources some time to load; Once pendingOfflineLoads
+ // is implemented, we can use that instead.
+ setTimeout("load_done()", 1000);
+
+ SimpleTest.waitForExplicitFinish();
+}
+
+run_test();
+
+</script>
+
+</head>
+<body>
+
+
+
+</body>
+</html>
--- a/layout/build/Makefile.in
+++ b/layout/build/Makefile.in
@@ -143,16 +143,17 @@ SHARED_LIBRARY_LIBS = \
$(DEPTH)/content/xslt/src/xslt/$(LIB_PREFIX)txxslt_s.$(LIB_SUFFIX) \
$(DEPTH)/content/xbl/src/$(LIB_PREFIX)gkconxbl_s.$(LIB_SUFFIX) \
$(DEPTH)/content/xul/document/src/$(LIB_PREFIX)gkconxuldoc_s.$(LIB_SUFFIX) \
$(DEPTH)/view/src/$(LIB_PREFIX)gkview_s.$(LIB_SUFFIX) \
$(DEPTH)/dom/src/base/$(LIB_PREFIX)jsdombase_s.$(LIB_SUFFIX) \
$(DEPTH)/dom/src/events/$(LIB_PREFIX)jsdomevents_s.$(LIB_SUFFIX) \
$(DEPTH)/dom/src/jsurl/$(LIB_PREFIX)jsurl_s.$(LIB_SUFFIX) \
$(DEPTH)/dom/src/storage/$(LIB_PREFIX)jsdomstorage_s.$(LIB_SUFFIX) \
+ $(DEPTH)/dom/src/offline/$(LIB_PREFIX)jsdomoffline_s.$(LIB_SUFFIX) \
$(DEPTH)/editor/libeditor/text/$(LIB_PREFIX)texteditor_s.$(LIB_SUFFIX) \
$(DEPTH)/editor/libeditor/base/$(LIB_PREFIX)editorbase_s.$(LIB_SUFFIX) \
$(NULL)
ifdef NS_PRINTING
SHARED_LIBRARY_LIBS += \
../printing/$(LIB_PREFIX)gkprinting_s.$(LIB_SUFFIX) \
$(NULL)
@@ -273,16 +274,17 @@ LOCAL_INCLUDES += -I$(srcdir)/../base \
-I$(topsrcdir)/content/xul/document/src \
-I$(topsrcdir)/content/xul/templates/src \
-I$(topsrcdir)/content/events/src \
-I$(topsrcdir)/content/xbl/src \
-I$(topsrcdir)/view/src \
-I$(topsrcdir)/dom/src/base \
-I$(topsrcdir)/dom/src/jsurl \
-I$(topsrcdir)/dom/src/storage \
+ -I$(topsrcdir)/dom/src/offline \
-I. \
-I$(topsrcdir)/editor/libeditor/base \
-I$(topsrcdir)/editor/libeditor/text \
-I$(topsrcdir)/editor/libeditor/html \
-I$(topsrcdir)/editor/txtsvc/src \
-I$(topsrcdir)/editor/composer/src \
$(NULL)
--- a/uriloader/prefetch/nsPrefetchService.cpp
+++ b/uriloader/prefetch/nsPrefetchService.cpp
@@ -279,16 +279,17 @@ nsPrefetchListener::OnChannelRedirect(ns
//-----------------------------------------------------------------------------
// nsPrefetchService <public>
//-----------------------------------------------------------------------------
nsPrefetchService::nsPrefetchService()
: mQueueHead(nsnull)
, mQueueTail(nsnull)
, mStopCount(0)
+ , mHaveProcessed(PR_FALSE)
, mDisabled(PR_TRUE)
, mFetchedOffline(PR_FALSE)
{
}
nsPrefetchService::~nsPrefetchService()
{
// cannot reach destructor if prefetch in progress (listener owns reference
@@ -534,18 +535,20 @@ nsPrefetchService::StartPrefetching()
if (mStopCount > 0)
mStopCount--;
LOG(("StartPrefetching [stopcount=%d]\n", mStopCount));
// only start prefetching after we've received enough DOCUMENT
// STOP notifications. we do this inorder to defer prefetching
// until after all sub-frames have finished loading.
- if (mStopCount == 0 && !mCurrentChannel)
+ if (mStopCount == 0 && !mCurrentChannel) {
+ mHaveProcessed = PR_TRUE;
ProcessNextURI();
+ }
}
void
nsPrefetchService::StopPrefetching()
{
mStopCount++;
LOG(("StopPrefetching [stopcount=%d]\n", mStopCount));
@@ -711,17 +714,24 @@ nsPrefetchService::Prefetch(nsIURI *aURI
// make sure the node is placed in the offline cache
node->mOffline = PR_TRUE;
}
LOG(("rejected: URL is already on prefetch queue\n"));
return NS_ERROR_ABORT;
}
}
- return EnqueueURI(aURI, aReferrerURI, aOffline);
+ rv = EnqueueURI(aURI, aReferrerURI, aOffline);
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ // if there are no pages loading, kick off the request immediately
+ if (mStopCount == 0 && mHaveProcessed)
+ ProcessNextURI();
+
+ return NS_OK;
}
NS_IMETHODIMP
nsPrefetchService::PrefetchURI(nsIURI *aURI,
nsIURI *aReferrerURI,
PRBool aExplicit)
{
return Prefetch(aURI, aReferrerURI, aExplicit, PR_FALSE);
--- a/uriloader/prefetch/nsPrefetchService.h
+++ b/uriloader/prefetch/nsPrefetchService.h
@@ -97,16 +97,18 @@ private:
void StartPrefetching();
void StopPrefetching();
nsCOMPtr<nsIOfflineCacheSession> mOfflineCacheSession;
nsPrefetchNode *mQueueHead;
nsPrefetchNode *mQueueTail;
nsCOMPtr<nsIChannel> mCurrentChannel;
PRInt32 mStopCount;
+ // true if pending document loads have ever reached zero.
+ PRInt32 mHaveProcessed;
PRBool mDisabled;
PRBool mFetchedOffline;
};
//-----------------------------------------------------------------------------
// nsPrefetchListener
//-----------------------------------------------------------------------------