Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dist/include/nsDOMOfflineResourceList.h
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
3
/* This Source Code Form is subject to the terms of the Mozilla Public
4
 * License, v. 2.0. If a copy of the MPL was not distributed with this
5
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7
#ifndef nsDOMOfflineResourceList_h___
8
#define nsDOMOfflineResourceList_h___
9
10
#include "nscore.h"
11
#include "nsIApplicationCache.h"
12
#include "nsIApplicationCacheContainer.h"
13
#include "nsIApplicationCacheService.h"
14
#include "nsIOfflineCacheUpdate.h"
15
#include "nsTArray.h"
16
#include "nsString.h"
17
#include "nsIURI.h"
18
#include "nsCOMPtr.h"
19
#include "nsWeakReference.h"
20
#include "nsCOMArray.h"
21
#include "nsIDOMEventListener.h"
22
#include "nsIObserver.h"
23
#include "nsIScriptContext.h"
24
#include "nsCycleCollectionParticipant.h"
25
#include "nsPIDOMWindow.h"
26
#include "mozilla/DOMEventTargetHelper.h"
27
#include "mozilla/ErrorResult.h"
28
29
namespace mozilla {
30
namespace dom {
31
class DOMStringList;
32
class Event;
33
} // namespace dom
34
} // namespace mozilla
35
36
class nsDOMOfflineResourceList final : public mozilla::DOMEventTargetHelper,
37
                                       public nsIObserver,
38
                                       public nsIOfflineCacheUpdateObserver,
39
                                       public nsSupportsWeakReference
40
{
41
  typedef mozilla::ErrorResult ErrorResult;
42
43
public:
44
  NS_DECL_ISUPPORTS_INHERITED
45
  NS_DECL_NSIOBSERVER
46
  NS_DECL_NSIOFFLINECACHEUPDATEOBSERVER
47
48
  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsDOMOfflineResourceList,
49
                                           mozilla::DOMEventTargetHelper)
50
51
  nsDOMOfflineResourceList(nsIURI* aManifestURI,
52
                           nsIURI* aDocumentURI,
53
                           nsIPrincipal* aLoadingPrincipal,
54
                           nsPIDOMWindowInner* aWindow);
55
56
  void FirePendingEvents();
57
  void Disconnect();
58
59
  nsresult Init();
60
61
  nsPIDOMWindowInner* GetParentObject() const
62
0
  {
63
0
    return GetOwner();
64
0
  }
65
  virtual JSObject*
66
  WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
67
68
  uint16_t GetStatus(ErrorResult& aRv);
69
70
  void Update(ErrorResult& aRv);
71
72
  void SwapCache(ErrorResult& aRv);
73
74
  IMPL_EVENT_HANDLER(checking)
75
  IMPL_EVENT_HANDLER(error)
76
  IMPL_EVENT_HANDLER(noupdate)
77
  IMPL_EVENT_HANDLER(downloading)
78
  IMPL_EVENT_HANDLER(progress)
79
  IMPL_EVENT_HANDLER(cached)
80
  IMPL_EVENT_HANDLER(updateready)
81
  IMPL_EVENT_HANDLER(obsolete)
82
83
  already_AddRefed<mozilla::dom::DOMStringList> GetMozItems(ErrorResult& aRv);
84
  bool MozHasItem(const nsAString& aURI, ErrorResult& aRv);
85
  uint32_t GetMozLength(ErrorResult& aRv);
86
  void MozItem(uint32_t aIndex, nsAString& aURI, ErrorResult& aRv);
87
  void IndexedGetter(uint32_t aIndex, bool& aFound, nsAString& aURI,
88
                     ErrorResult& aRv);
89
  uint32_t Length()
90
0
  {
91
0
    mozilla::IgnoredErrorResult rv;
92
0
    uint32_t length = GetMozLength(rv);
93
0
    return rv.Failed() ? 0 : length;
94
0
  }
95
  void MozAdd(const nsAString& aURI, ErrorResult& aRv);
96
  void MozRemove(const nsAString& aURI, ErrorResult& aRv);
97
98
protected:
99
  virtual ~nsDOMOfflineResourceList();
100
101
private:
102
  nsresult SendEvent(const nsAString &aEventName);
103
104
  nsresult UpdateAdded(nsIOfflineCacheUpdate *aUpdate);
105
  nsresult UpdateCompleted(nsIOfflineCacheUpdate *aUpdate);
106
107
  already_AddRefed<nsIApplicationCacheContainer> GetDocumentAppCacheContainer();
108
  already_AddRefed<nsIApplicationCache> GetDocumentAppCache();
109
110
  nsresult GetCacheKey(const nsAString &aURI, nsCString &aKey);
111
  nsresult GetCacheKey(nsIURI *aURI, nsCString &aKey);
112
113
  nsresult CacheKeys();
114
  void ClearCachedKeys();
115
116
  bool mInitialized;
117
118
  nsCOMPtr<nsIURI> mManifestURI;
119
  // AsciiSpec of mManifestURI
120
  nsCString mManifestSpec;
121
122
  nsCOMPtr<nsIURI> mDocumentURI;
123
  nsCOMPtr<nsIPrincipal> mLoadingPrincipal;
124
  nsCOMPtr<nsIApplicationCacheService> mApplicationCacheService;
125
  nsCOMPtr<nsIApplicationCache> mAvailableApplicationCache;
126
  nsCOMPtr<nsIOfflineCacheUpdate> mCacheUpdate;
127
  bool mExposeCacheUpdateStatus;
128
  uint16_t mStatus;
129
130
  // The set of dynamic keys for this application cache object.
131
  char **mCachedKeys;
132
  uint32_t mCachedKeysCount;
133
134
  nsCOMArray<mozilla::dom::Event> mPendingEvents;
135
};
136
137
#endif