diff options
Diffstat (limited to 'WebCore/loader/appcache/DOMApplicationCache.h')
-rw-r--r-- | WebCore/loader/appcache/DOMApplicationCache.h | 88 |
1 files changed, 42 insertions, 46 deletions
diff --git a/WebCore/loader/appcache/DOMApplicationCache.h b/WebCore/loader/appcache/DOMApplicationCache.h index 57b37bc..ade0fcf 100644 --- a/WebCore/loader/appcache/DOMApplicationCache.h +++ b/WebCore/loader/appcache/DOMApplicationCache.h @@ -28,6 +28,7 @@ #if ENABLE(OFFLINE_WEB_APPLICATIONS) +#include "ApplicationCacheHost.h" #include "AtomicStringHash.h" #include "EventTarget.h" #include "EventListener.h" @@ -38,41 +39,34 @@ namespace WebCore { -class ApplicationCache; class AtomicStringImpl; -class DOMStringList; class Frame; class KURL; class String; - + class DOMApplicationCache : public RefCounted<DOMApplicationCache>, public EventTarget { public: static PassRefPtr<DOMApplicationCache> create(Frame* frame) { return adoptRef(new DOMApplicationCache(frame)); } - void disconnectFrame(); + ~DOMApplicationCache() { ASSERT(!m_frame); } - enum Status { - UNCACHED = 0, - IDLE = 1, - CHECKING = 2, - DOWNLOADING = 3, - UPDATEREADY = 4, - OBSOLETE = 5 - }; + void disconnectFrame(); unsigned short status() const; - void update(ExceptionCode&); void swapCache(ExceptionCode&); - - PassRefPtr<DOMStringList> items(); - bool hasItem(const KURL&, ExceptionCode&); - void add(const KURL&, ExceptionCode&); - void remove(const KURL&, ExceptionCode&); + + // Event listener attributes by EventID + + void setAttributeEventListener(ApplicationCacheHost::EventID id, PassRefPtr<EventListener> eventListener) { m_attributeEventListeners[id] = eventListener; } + EventListener* getAttributeEventListener(ApplicationCacheHost::EventID id) const { return m_attributeEventListeners[id].get(); } + void clearAttributeEventListener(ApplicationCacheHost::EventID id) { m_attributeEventListeners[id] = 0; } + void callEventListener(ApplicationCacheHost::EventID id) { callListener(toEventType(id), getAttributeEventListener(id)); } + + // EventTarget impl virtual void addEventListener(const AtomicString& eventType, PassRefPtr<EventListener>, bool useCapture); virtual void removeEventListener(const AtomicString& eventType, EventListener*, bool useCapture); virtual bool dispatchEvent(PassRefPtr<Event>, ExceptionCode&); - typedef Vector<RefPtr<EventListener> > ListenerVector; typedef HashMap<AtomicString, ListenerVector> EventListenersMap; EventListenersMap& eventListeners() { return m_eventListeners; } @@ -80,33 +74,36 @@ public: using RefCounted<DOMApplicationCache>::ref; using RefCounted<DOMApplicationCache>::deref; - void setOnchecking(PassRefPtr<EventListener> eventListener) { m_onCheckingListener = eventListener; } - EventListener* onchecking() const { return m_onCheckingListener.get(); } + // Explicitly named attribute event listener helpers - void setOnerror(PassRefPtr<EventListener> eventListener) { m_onErrorListener = eventListener; } - EventListener* onerror() const { return m_onErrorListener.get(); } + void setOnchecking(PassRefPtr<EventListener> listener) { setAttributeEventListener(ApplicationCacheHost::CHECKING_EVENT, listener); } + EventListener* onchecking() const { return getAttributeEventListener(ApplicationCacheHost::CHECKING_EVENT); } - void setOnnoupdate(PassRefPtr<EventListener> eventListener) { m_onNoUpdateListener = eventListener; } - EventListener* onnoupdate() const { return m_onNoUpdateListener.get(); } + void setOnerror(PassRefPtr<EventListener> listener) { setAttributeEventListener(ApplicationCacheHost::ERROR_EVENT, listener);} + EventListener* onerror() const { return getAttributeEventListener(ApplicationCacheHost::ERROR_EVENT); } - void setOndownloading(PassRefPtr<EventListener> eventListener) { m_onDownloadingListener = eventListener; } - EventListener* ondownloading() const { return m_onDownloadingListener.get(); } - - void setOnprogress(PassRefPtr<EventListener> eventListener) { m_onProgressListener = eventListener; } - EventListener* onprogress() const { return m_onProgressListener.get(); } + void setOnnoupdate(PassRefPtr<EventListener> listener) { setAttributeEventListener(ApplicationCacheHost::NOUPDATE_EVENT, listener); } + EventListener* onnoupdate() const { return getAttributeEventListener(ApplicationCacheHost::NOUPDATE_EVENT); } + + void setOndownloading(PassRefPtr<EventListener> listener) { setAttributeEventListener(ApplicationCacheHost::DOWNLOADING_EVENT, listener); } + EventListener* ondownloading() const { return getAttributeEventListener(ApplicationCacheHost::DOWNLOADING_EVENT); } + + void setOnprogress(PassRefPtr<EventListener> listener) { setAttributeEventListener(ApplicationCacheHost::PROGRESS_EVENT, listener); } + EventListener* onprogress() const { return getAttributeEventListener(ApplicationCacheHost::PROGRESS_EVENT); } - void setOnupdateready(PassRefPtr<EventListener> eventListener) { m_onUpdateReadyListener = eventListener; } - EventListener* onupdateready() const { return m_onUpdateReadyListener.get(); } + void setOnupdateready(PassRefPtr<EventListener> listener) { setAttributeEventListener(ApplicationCacheHost::UPDATEREADY_EVENT, listener); } + EventListener* onupdateready() const { return getAttributeEventListener(ApplicationCacheHost::UPDATEREADY_EVENT); } - void setOncached(PassRefPtr<EventListener> eventListener) { m_onCachedListener = eventListener; } - EventListener* oncached() const { return m_onCachedListener.get(); } + void setOncached(PassRefPtr<EventListener> listener) { setAttributeEventListener(ApplicationCacheHost::CACHED_EVENT, listener); } + EventListener* oncached() const { return getAttributeEventListener(ApplicationCacheHost::CACHED_EVENT); } - void setOnobsolete(PassRefPtr<EventListener> eventListener) { m_onObsoleteListener = eventListener; } - EventListener* onobsolete() const { return m_onObsoleteListener.get(); } + void setOnobsolete(PassRefPtr<EventListener> listener) { setAttributeEventListener(ApplicationCacheHost::OBSOLETE_EVENT, listener); } + EventListener* onobsolete() const { return getAttributeEventListener(ApplicationCacheHost::OBSOLETE_EVENT); } virtual ScriptExecutionContext* scriptExecutionContext() const; DOMApplicationCache* toDOMApplicationCache() { return this; } +#ifdef MANUAL_MERGE_REQUIRED void callCheckingListener(); void callErrorListener(); void callNoUpdateListener(); @@ -122,29 +119,28 @@ public: void clearAttributeEventListener(const AtomicString& eventType); #endif +#else // MANUAL_MERGE_REQUIRED + static const AtomicString& toEventType(ApplicationCacheHost::EventID id); + static ApplicationCacheHost::EventID toEventID(const AtomicString& eventType); + +#endif // MANUAL_MERGE_REQUIRED private: DOMApplicationCache(Frame*); + void callListener(const AtomicString& eventType, EventListener*); virtual void refEventTarget() { ref(); } virtual void derefEventTarget() { deref(); } - ApplicationCache* associatedCache() const; + ApplicationCacheHost* applicationCacheHost() const; bool swapCache(); #if USE(V8) RefPtr<EventListener>* getAttributeEventListenerStorage(const AtomicString& eventType); #endif - RefPtr<EventListener> m_onCheckingListener; - RefPtr<EventListener> m_onErrorListener; - RefPtr<EventListener> m_onNoUpdateListener; - RefPtr<EventListener> m_onDownloadingListener; - RefPtr<EventListener> m_onProgressListener; - RefPtr<EventListener> m_onUpdateReadyListener; - RefPtr<EventListener> m_onCachedListener; - RefPtr<EventListener> m_onObsoleteListener; - + RefPtr<EventListener> m_attributeEventListeners[ApplicationCacheHost::OBSOLETE_EVENT + 1]; + EventListenersMap m_eventListeners; Frame* m_frame; |