dom/src/offline/nsDOMOfflineResourceList.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/src/offline/nsDOMOfflineResourceList.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,168 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef nsDOMOfflineResourceList_h___
    1.10 +#define nsDOMOfflineResourceList_h___
    1.11 +
    1.12 +#include "nscore.h"
    1.13 +#include "nsIDOMOfflineResourceList.h"
    1.14 +#include "nsIApplicationCache.h"
    1.15 +#include "nsIApplicationCacheContainer.h"
    1.16 +#include "nsIApplicationCacheService.h"
    1.17 +#include "nsIOfflineCacheUpdate.h"
    1.18 +#include "nsTArray.h"
    1.19 +#include "nsString.h"
    1.20 +#include "nsIURI.h"
    1.21 +#include "nsCOMPtr.h"
    1.22 +#include "nsWeakReference.h"
    1.23 +#include "nsCOMArray.h"
    1.24 +#include "nsIDOMEventListener.h"
    1.25 +#include "nsIObserver.h"
    1.26 +#include "nsIScriptContext.h"
    1.27 +#include "nsCycleCollectionParticipant.h"
    1.28 +#include "nsPIDOMWindow.h"
    1.29 +#include "mozilla/DOMEventTargetHelper.h"
    1.30 +#include "mozilla/ErrorResult.h"
    1.31 +
    1.32 +class nsIDOMWindow;
    1.33 +
    1.34 +namespace mozilla {
    1.35 +namespace dom {
    1.36 +class DOMStringList;
    1.37 +} // namespace dom
    1.38 +} // namespace mozilla
    1.39 +
    1.40 +class nsDOMOfflineResourceList : public mozilla::DOMEventTargetHelper,
    1.41 +                                 public nsIDOMOfflineResourceList,
    1.42 +                                 public nsIObserver,
    1.43 +                                 public nsIOfflineCacheUpdateObserver,
    1.44 +                                 public nsSupportsWeakReference
    1.45 +{
    1.46 +  typedef mozilla::ErrorResult ErrorResult;
    1.47 +
    1.48 +public:
    1.49 +  NS_DECL_ISUPPORTS_INHERITED
    1.50 +  NS_DECL_NSIDOMOFFLINERESOURCELIST
    1.51 +  NS_DECL_NSIOBSERVER
    1.52 +  NS_DECL_NSIOFFLINECACHEUPDATEOBSERVER
    1.53 +
    1.54 +  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsDOMOfflineResourceList,
    1.55 +                                           mozilla::DOMEventTargetHelper)
    1.56 +
    1.57 +  nsDOMOfflineResourceList(nsIURI* aManifestURI,
    1.58 +                           nsIURI* aDocumentURI,
    1.59 +                           nsPIDOMWindow* aWindow);
    1.60 +  virtual ~nsDOMOfflineResourceList();
    1.61 +
    1.62 +  void FirePendingEvents();
    1.63 +  void Disconnect();
    1.64 +
    1.65 +  nsresult Init();
    1.66 +
    1.67 +  nsPIDOMWindow* GetParentObject() const
    1.68 +  {
    1.69 +    return GetOwner();
    1.70 +  }
    1.71 +  virtual JSObject*
    1.72 +  WrapObject(JSContext* aCx) MOZ_OVERRIDE;
    1.73 +
    1.74 +  uint16_t GetStatus(ErrorResult& aRv)
    1.75 +  {
    1.76 +    uint16_t status = 0;
    1.77 +    aRv = GetStatus(&status);
    1.78 +    return status;
    1.79 +  }
    1.80 +  void Update(ErrorResult& aRv)
    1.81 +  {
    1.82 +    aRv = Update();
    1.83 +  }
    1.84 +  void SwapCache(ErrorResult& aRv)
    1.85 +  {
    1.86 +    aRv = SwapCache();
    1.87 +  }
    1.88 +
    1.89 +  IMPL_EVENT_HANDLER(checking)
    1.90 +  IMPL_EVENT_HANDLER(error)
    1.91 +  IMPL_EVENT_HANDLER(noupdate)
    1.92 +  IMPL_EVENT_HANDLER(downloading)
    1.93 +  IMPL_EVENT_HANDLER(progress)
    1.94 +  IMPL_EVENT_HANDLER(cached)
    1.95 +  IMPL_EVENT_HANDLER(updateready)
    1.96 +  IMPL_EVENT_HANDLER(obsolete)
    1.97 +
    1.98 +  already_AddRefed<mozilla::dom::DOMStringList> GetMozItems(ErrorResult& aRv);
    1.99 +  bool MozHasItem(const nsAString& aURI, ErrorResult& aRv)
   1.100 +  {
   1.101 +    bool hasItem = false;
   1.102 +    aRv = MozHasItem(aURI, &hasItem);
   1.103 +    return hasItem;
   1.104 +  }
   1.105 +  uint32_t GetMozLength(ErrorResult& aRv)
   1.106 +  {
   1.107 +    uint32_t length = 0;
   1.108 +    aRv = GetMozLength(&length);
   1.109 +    return length;
   1.110 +  }
   1.111 +  void MozItem(uint32_t aIndex, nsAString& aURI, ErrorResult& aRv)
   1.112 +  {
   1.113 +    aRv = MozItem(aIndex, aURI);
   1.114 +  }
   1.115 +  void IndexedGetter(uint32_t aIndex, bool& aFound, nsAString& aURI,
   1.116 +                     ErrorResult& aRv)
   1.117 +  {
   1.118 +    MozItem(aIndex, aURI, aRv);
   1.119 +    aFound = !aURI.IsVoid();
   1.120 +  }
   1.121 +  uint32_t Length()
   1.122 +  {
   1.123 +    ErrorResult rv;
   1.124 +    uint32_t length = GetMozLength(rv);
   1.125 +    return rv.Failed() ? 0 : length;
   1.126 +  }
   1.127 +  void MozAdd(const nsAString& aURI, ErrorResult& aRv)
   1.128 +  {
   1.129 +    aRv = MozAdd(aURI);
   1.130 +  }
   1.131 +  void MozRemove(const nsAString& aURI, ErrorResult& aRv)
   1.132 +  {
   1.133 +    aRv = MozRemove(aURI);
   1.134 +  }
   1.135 +
   1.136 +private:
   1.137 +  nsresult SendEvent(const nsAString &aEventName);
   1.138 +
   1.139 +  nsresult UpdateAdded(nsIOfflineCacheUpdate *aUpdate);
   1.140 +  nsresult UpdateCompleted(nsIOfflineCacheUpdate *aUpdate);
   1.141 +
   1.142 +  already_AddRefed<nsIApplicationCacheContainer> GetDocumentAppCacheContainer();
   1.143 +  already_AddRefed<nsIApplicationCache> GetDocumentAppCache();
   1.144 +
   1.145 +  nsresult GetCacheKey(const nsAString &aURI, nsCString &aKey);
   1.146 +  nsresult GetCacheKey(nsIURI *aURI, nsCString &aKey);
   1.147 +
   1.148 +  nsresult CacheKeys();
   1.149 +  void ClearCachedKeys();
   1.150 +
   1.151 +  bool mInitialized;
   1.152 +
   1.153 +  nsCOMPtr<nsIURI> mManifestURI;
   1.154 +  // AsciiSpec of mManifestURI
   1.155 +  nsCString mManifestSpec;
   1.156 +
   1.157 +  nsCOMPtr<nsIURI> mDocumentURI;
   1.158 +  nsCOMPtr<nsIApplicationCacheService> mApplicationCacheService;
   1.159 +  nsCOMPtr<nsIApplicationCache> mAvailableApplicationCache;
   1.160 +  nsCOMPtr<nsIOfflineCacheUpdate> mCacheUpdate;
   1.161 +  bool mExposeCacheUpdateStatus;
   1.162 +  uint16_t mStatus;
   1.163 +
   1.164 +  // The set of dynamic keys for this application cache object.
   1.165 +  char **mCachedKeys;
   1.166 +  uint32_t mCachedKeysCount;
   1.167 +
   1.168 +  nsCOMArray<nsIDOMEvent> mPendingEvents;
   1.169 +};
   1.170 +
   1.171 +#endif

mercurial