2007-05-29 02:45:30 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-05-29 02:45:30 -07:00
|
|
|
|
|
|
|
#ifndef nsDOMOfflineResourceList_h___
|
|
|
|
#define nsDOMOfflineResourceList_h___
|
|
|
|
|
|
|
|
#include "nscore.h"
|
|
|
|
#include "nsIDOMOfflineResourceList.h"
|
2008-08-26 16:09:02 -07:00
|
|
|
#include "nsIApplicationCache.h"
|
|
|
|
#include "nsIApplicationCacheContainer.h"
|
|
|
|
#include "nsIApplicationCacheService.h"
|
2008-01-16 13:54:33 -08:00
|
|
|
#include "nsIOfflineCacheUpdate.h"
|
2007-05-29 02:45:30 -07:00
|
|
|
#include "nsTArray.h"
|
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsIURI.h"
|
|
|
|
#include "nsCOMPtr.h"
|
2008-01-16 13:54:33 -08:00
|
|
|
#include "nsWeakReference.h"
|
|
|
|
#include "nsCOMArray.h"
|
|
|
|
#include "nsIDOMEventListener.h"
|
|
|
|
#include "nsIObserver.h"
|
|
|
|
#include "nsIScriptContext.h"
|
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2009-06-15 01:27:29 -07:00
|
|
|
#include "nsPIDOMWindow.h"
|
2014-03-31 23:13:50 -07:00
|
|
|
#include "mozilla/DOMEventTargetHelper.h"
|
2013-05-31 23:53:44 -07:00
|
|
|
#include "mozilla/ErrorResult.h"
|
2007-05-29 02:45:30 -07:00
|
|
|
|
2008-01-16 13:54:33 -08:00
|
|
|
class nsIDOMWindow;
|
|
|
|
|
2013-07-09 10:54:21 -07:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
class DOMStringList;
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2014-11-25 10:56:07 -08:00
|
|
|
class nsDOMOfflineResourceList MOZ_FINAL : public mozilla::DOMEventTargetHelper,
|
|
|
|
public nsIDOMOfflineResourceList,
|
|
|
|
public nsIObserver,
|
|
|
|
public nsIOfflineCacheUpdateObserver,
|
|
|
|
public nsSupportsWeakReference
|
2007-05-29 02:45:30 -07:00
|
|
|
{
|
2013-05-31 23:53:44 -07:00
|
|
|
typedef mozilla::ErrorResult ErrorResult;
|
|
|
|
|
2007-05-29 02:45:30 -07:00
|
|
|
public:
|
2009-06-15 01:27:29 -07:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2007-05-29 02:45:30 -07:00
|
|
|
NS_DECL_NSIDOMOFFLINERESOURCELIST
|
2008-01-16 13:54:33 -08:00
|
|
|
NS_DECL_NSIOBSERVER
|
|
|
|
NS_DECL_NSIOFFLINECACHEUPDATEOBSERVER
|
|
|
|
|
2009-06-15 01:27:29 -07:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsDOMOfflineResourceList,
|
2014-03-31 23:13:50 -07:00
|
|
|
mozilla::DOMEventTargetHelper)
|
2007-05-29 02:45:30 -07:00
|
|
|
|
2008-11-05 16:01:07 -08:00
|
|
|
nsDOMOfflineResourceList(nsIURI* aManifestURI,
|
2008-01-16 13:54:33 -08:00
|
|
|
nsIURI* aDocumentURI,
|
2012-03-12 17:56:07 -07:00
|
|
|
nsPIDOMWindow* aWindow);
|
2007-05-29 02:45:30 -07:00
|
|
|
|
2008-01-16 13:54:33 -08:00
|
|
|
void FirePendingEvents();
|
|
|
|
void Disconnect();
|
|
|
|
|
2007-06-26 21:40:24 -07:00
|
|
|
nsresult Init();
|
|
|
|
|
2013-05-31 23:53:44 -07:00
|
|
|
nsPIDOMWindow* GetParentObject() const
|
|
|
|
{
|
|
|
|
return GetOwner();
|
|
|
|
}
|
|
|
|
virtual JSObject*
|
2014-04-08 15:27:18 -07:00
|
|
|
WrapObject(JSContext* aCx) MOZ_OVERRIDE;
|
2013-05-31 23:53:44 -07:00
|
|
|
|
|
|
|
uint16_t GetStatus(ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
uint16_t status = 0;
|
|
|
|
aRv = GetStatus(&status);
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
void Update(ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
aRv = Update();
|
|
|
|
}
|
|
|
|
void SwapCache(ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
aRv = SwapCache();
|
|
|
|
}
|
|
|
|
|
|
|
|
IMPL_EVENT_HANDLER(checking)
|
|
|
|
IMPL_EVENT_HANDLER(error)
|
|
|
|
IMPL_EVENT_HANDLER(noupdate)
|
|
|
|
IMPL_EVENT_HANDLER(downloading)
|
|
|
|
IMPL_EVENT_HANDLER(progress)
|
|
|
|
IMPL_EVENT_HANDLER(cached)
|
|
|
|
IMPL_EVENT_HANDLER(updateready)
|
|
|
|
IMPL_EVENT_HANDLER(obsolete)
|
|
|
|
|
2013-07-09 10:54:21 -07:00
|
|
|
already_AddRefed<mozilla::dom::DOMStringList> GetMozItems(ErrorResult& aRv);
|
2013-05-31 23:53:44 -07:00
|
|
|
bool MozHasItem(const nsAString& aURI, ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
bool hasItem = false;
|
|
|
|
aRv = MozHasItem(aURI, &hasItem);
|
|
|
|
return hasItem;
|
|
|
|
}
|
|
|
|
uint32_t GetMozLength(ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
uint32_t length = 0;
|
|
|
|
aRv = GetMozLength(&length);
|
|
|
|
return length;
|
|
|
|
}
|
|
|
|
void MozItem(uint32_t aIndex, nsAString& aURI, ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
aRv = MozItem(aIndex, aURI);
|
|
|
|
}
|
|
|
|
void IndexedGetter(uint32_t aIndex, bool& aFound, nsAString& aURI,
|
|
|
|
ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
MozItem(aIndex, aURI, aRv);
|
|
|
|
aFound = !aURI.IsVoid();
|
|
|
|
}
|
|
|
|
uint32_t Length()
|
|
|
|
{
|
|
|
|
ErrorResult rv;
|
|
|
|
uint32_t length = GetMozLength(rv);
|
|
|
|
return rv.Failed() ? 0 : length;
|
|
|
|
}
|
|
|
|
void MozAdd(const nsAString& aURI, ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
aRv = MozAdd(aURI);
|
|
|
|
}
|
|
|
|
void MozRemove(const nsAString& aURI, ErrorResult& aRv)
|
|
|
|
{
|
|
|
|
aRv = MozRemove(aURI);
|
|
|
|
}
|
|
|
|
|
2014-07-08 14:23:17 -07:00
|
|
|
protected:
|
|
|
|
virtual ~nsDOMOfflineResourceList();
|
|
|
|
|
2009-06-15 01:27:29 -07:00
|
|
|
private:
|
|
|
|
nsresult SendEvent(const nsAString &aEventName);
|
2008-01-16 13:54:33 -08:00
|
|
|
|
|
|
|
nsresult UpdateAdded(nsIOfflineCacheUpdate *aUpdate);
|
|
|
|
nsresult UpdateCompleted(nsIOfflineCacheUpdate *aUpdate);
|
|
|
|
|
2008-08-26 16:09:02 -07:00
|
|
|
already_AddRefed<nsIApplicationCacheContainer> GetDocumentAppCacheContainer();
|
|
|
|
already_AddRefed<nsIApplicationCache> GetDocumentAppCache();
|
|
|
|
|
2007-05-29 02:45:30 -07:00
|
|
|
nsresult GetCacheKey(const nsAString &aURI, nsCString &aKey);
|
|
|
|
nsresult GetCacheKey(nsIURI *aURI, nsCString &aKey);
|
|
|
|
|
|
|
|
nsresult CacheKeys();
|
|
|
|
void ClearCachedKeys();
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mInitialized;
|
2008-08-26 16:09:02 -07:00
|
|
|
|
2008-01-16 13:54:33 -08:00
|
|
|
nsCOMPtr<nsIURI> mManifestURI;
|
2008-08-26 16:09:02 -07:00
|
|
|
// AsciiSpec of mManifestURI
|
|
|
|
nsCString mManifestSpec;
|
|
|
|
|
2008-01-16 13:54:33 -08:00
|
|
|
nsCOMPtr<nsIURI> mDocumentURI;
|
2008-08-26 16:09:02 -07:00
|
|
|
nsCOMPtr<nsIApplicationCacheService> mApplicationCacheService;
|
2010-10-20 10:12:32 -07:00
|
|
|
nsCOMPtr<nsIApplicationCache> mAvailableApplicationCache;
|
2008-01-16 13:54:33 -08:00
|
|
|
nsCOMPtr<nsIOfflineCacheUpdate> mCacheUpdate;
|
2010-10-20 10:12:32 -07:00
|
|
|
bool mExposeCacheUpdateStatus;
|
2012-08-22 08:56:38 -07:00
|
|
|
uint16_t mStatus;
|
2008-01-16 13:54:33 -08:00
|
|
|
|
2008-08-26 13:31:48 -07:00
|
|
|
// The set of dynamic keys for this application cache object.
|
|
|
|
char **mCachedKeys;
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mCachedKeysCount;
|
2008-08-26 13:31:48 -07:00
|
|
|
|
2009-06-15 01:27:29 -07:00
|
|
|
nsCOMArray<nsIDOMEvent> mPendingEvents;
|
2007-05-29 02:45:30 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|