2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04: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 13:45:30 +04:00
|
|
|
|
|
|
|
#ifndef nsDOMOfflineResourceList_h___
|
|
|
|
#define nsDOMOfflineResourceList_h___
|
|
|
|
|
|
|
|
#include "nscore.h"
|
|
|
|
#include "nsIDOMOfflineResourceList.h"
|
2008-08-27 03:09:02 +04:00
|
|
|
#include "nsIApplicationCache.h"
|
|
|
|
#include "nsIApplicationCacheContainer.h"
|
|
|
|
#include "nsIApplicationCacheService.h"
|
2008-01-17 00:54:33 +03:00
|
|
|
#include "nsIOfflineCacheUpdate.h"
|
2007-05-29 13:45:30 +04:00
|
|
|
#include "nsTArray.h"
|
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsIURI.h"
|
|
|
|
#include "nsCOMPtr.h"
|
2008-01-17 00:54:33 +03:00
|
|
|
#include "nsWeakReference.h"
|
|
|
|
#include "nsCOMArray.h"
|
|
|
|
#include "nsIDOMEventListener.h"
|
|
|
|
#include "nsIObserver.h"
|
|
|
|
#include "nsIScriptContext.h"
|
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2009-06-15 12:27:29 +04:00
|
|
|
#include "nsPIDOMWindow.h"
|
2014-04-01 10:13:50 +04:00
|
|
|
#include "mozilla/DOMEventTargetHelper.h"
|
2013-06-01 10:53:44 +04:00
|
|
|
#include "mozilla/ErrorResult.h"
|
2007-05-29 13:45:30 +04:00
|
|
|
|
2013-07-09 21:54:21 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
class DOMStringList;
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class nsDOMOfflineResourceList final : public mozilla::DOMEventTargetHelper,
|
2015-03-27 21:52:19 +03:00
|
|
|
public nsIDOMOfflineResourceList,
|
|
|
|
public nsIObserver,
|
|
|
|
public nsIOfflineCacheUpdateObserver,
|
|
|
|
public nsSupportsWeakReference
|
2007-05-29 13:45:30 +04:00
|
|
|
{
|
2013-06-01 10:53:44 +04:00
|
|
|
typedef mozilla::ErrorResult ErrorResult;
|
|
|
|
|
2007-05-29 13:45:30 +04:00
|
|
|
public:
|
2009-06-15 12:27:29 +04:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2007-05-29 13:45:30 +04:00
|
|
|
NS_DECL_NSIDOMOFFLINERESOURCELIST
|
2008-01-17 00:54:33 +03:00
|
|
|
NS_DECL_NSIOBSERVER
|
|
|
|
NS_DECL_NSIOFFLINECACHEUPDATEOBSERVER
|
|
|
|
|
2009-06-15 12:27:29 +04:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsDOMOfflineResourceList,
|
2014-04-01 10:13:50 +04:00
|
|
|
mozilla::DOMEventTargetHelper)
|
2007-05-29 13:45:30 +04:00
|
|
|
|
2008-11-06 03:01:07 +03:00
|
|
|
nsDOMOfflineResourceList(nsIURI* aManifestURI,
|
2008-01-17 00:54:33 +03:00
|
|
|
nsIURI* aDocumentURI,
|
2015-10-02 19:10:02 +03:00
|
|
|
nsIPrincipal* aLoadingPrincipal,
|
2016-01-30 20:05:36 +03:00
|
|
|
nsPIDOMWindowInner* aWindow);
|
2007-05-29 13:45:30 +04:00
|
|
|
|
2008-01-17 00:54:33 +03:00
|
|
|
void FirePendingEvents();
|
|
|
|
void Disconnect();
|
|
|
|
|
2007-06-27 08:40:24 +04:00
|
|
|
nsresult Init();
|
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
nsPIDOMWindowInner* GetParentObject() const
|
2013-06-01 10:53:44 +04:00
|
|
|
{
|
|
|
|
return GetOwner();
|
|
|
|
}
|
|
|
|
virtual JSObject*
|
2015-03-21 19:28:04 +03:00
|
|
|
WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
2013-06-01 10:53:44 +04: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 21:54:21 +04:00
|
|
|
already_AddRefed<mozilla::dom::DOMStringList> GetMozItems(ErrorResult& aRv);
|
2013-06-01 10:53:44 +04: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()
|
|
|
|
{
|
2016-03-15 16:59:03 +03:00
|
|
|
mozilla::IgnoredErrorResult rv;
|
2013-06-01 10:53:44 +04:00
|
|
|
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-09 01:23:17 +04:00
|
|
|
protected:
|
|
|
|
virtual ~nsDOMOfflineResourceList();
|
|
|
|
|
2009-06-15 12:27:29 +04:00
|
|
|
private:
|
|
|
|
nsresult SendEvent(const nsAString &aEventName);
|
2008-01-17 00:54:33 +03:00
|
|
|
|
|
|
|
nsresult UpdateAdded(nsIOfflineCacheUpdate *aUpdate);
|
|
|
|
nsresult UpdateCompleted(nsIOfflineCacheUpdate *aUpdate);
|
|
|
|
|
2008-08-27 03:09:02 +04:00
|
|
|
already_AddRefed<nsIApplicationCacheContainer> GetDocumentAppCacheContainer();
|
|
|
|
already_AddRefed<nsIApplicationCache> GetDocumentAppCache();
|
|
|
|
|
2007-05-29 13:45:30 +04:00
|
|
|
nsresult GetCacheKey(const nsAString &aURI, nsCString &aKey);
|
|
|
|
nsresult GetCacheKey(nsIURI *aURI, nsCString &aKey);
|
|
|
|
|
|
|
|
nsresult CacheKeys();
|
|
|
|
void ClearCachedKeys();
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool mInitialized;
|
2008-08-27 03:09:02 +04:00
|
|
|
|
2008-01-17 00:54:33 +03:00
|
|
|
nsCOMPtr<nsIURI> mManifestURI;
|
2008-08-27 03:09:02 +04:00
|
|
|
// AsciiSpec of mManifestURI
|
|
|
|
nsCString mManifestSpec;
|
|
|
|
|
2008-01-17 00:54:33 +03:00
|
|
|
nsCOMPtr<nsIURI> mDocumentURI;
|
2015-10-02 19:10:02 +03:00
|
|
|
nsCOMPtr<nsIPrincipal> mLoadingPrincipal;
|
2008-08-27 03:09:02 +04:00
|
|
|
nsCOMPtr<nsIApplicationCacheService> mApplicationCacheService;
|
2010-10-20 21:12:32 +04:00
|
|
|
nsCOMPtr<nsIApplicationCache> mAvailableApplicationCache;
|
2008-01-17 00:54:33 +03:00
|
|
|
nsCOMPtr<nsIOfflineCacheUpdate> mCacheUpdate;
|
2010-10-20 21:12:32 +04:00
|
|
|
bool mExposeCacheUpdateStatus;
|
2012-08-22 19:56:38 +04:00
|
|
|
uint16_t mStatus;
|
2008-01-17 00:54:33 +03:00
|
|
|
|
2008-08-27 00:31:48 +04:00
|
|
|
// The set of dynamic keys for this application cache object.
|
|
|
|
char **mCachedKeys;
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t mCachedKeysCount;
|
2008-08-27 00:31:48 +04:00
|
|
|
|
2009-06-15 12:27:29 +04:00
|
|
|
nsCOMArray<nsIDOMEvent> mPendingEvents;
|
2007-05-29 13:45:30 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|