Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(593)

Unified Diff: loader/appcache2/DOMApplicationCache.h

Issue 113554: For local review prior to sending to webkit (Closed) Base URL: http://svn.webkit.org/repository/webkit/trunk/WebCore/
Patch Set: '' Created 11 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « loader/appcache2/ApplicationCacheFrontend.cpp ('k') | loader/appcache2/DOMApplicationCache.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: loader/appcache2/DOMApplicationCache.h
===================================================================
--- loader/appcache2/DOMApplicationCache.h (revision 0)
+++ loader/appcache2/DOMApplicationCache.h (working copy)
@@ -26,8 +26,10 @@
#ifndef DOMApplicationCache_h
#define DOMApplicationCache_h
-#if ENABLE(OFFLINE_WEB_APPLICATIONS)
+#if ENABLE(APPLICATION_CACHE)
+#include "ApplicationCacheCommon.h"
+#include "ApplicationCacheFrontend.h"
#include "AtomicStringHash.h"
#include "EventTarget.h"
#include "EventListener.h"
@@ -38,7 +40,6 @@
namespace WebCore {
-class ApplicationCache;
class AtomicStringImpl;
class DOMStringList;
class Frame;
@@ -47,32 +48,33 @@
class DOMApplicationCache : public RefCounted<DOMApplicationCache>, public EventTarget {
public:
+ // FIXME: integrate with workers
static PassRefPtr<DOMApplicationCache> create(Frame* frame) { return adoptRef(new DOMApplicationCache(frame)); }
void disconnectFrame();
enum Status {
- UNCACHED = 0,
- IDLE = 1,
- CHECKING = 2,
- DOWNLOADING = 3,
- UPDATEREADY = 4,
- OBSOLETE = 5
+ UNCACHED = APPCACHE_UNCACHED,
+ IDLE = APPCACHE_IDLE,
+ CHECKING = APPCACHE_CHECKING,
+ DOWNLOADING = APPCACHE_DOWNLOADING,
+ UPDATEREADY = APPCACHE_UPDATEREADY,
+ OBSOLETE = APPCACHE_OBSOLETE
};
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&);
- virtual void addEventListener(const AtomicString& eventType, PassRefPtr<EventListener>, bool useCapture);
- virtual void removeEventListener(const AtomicString& eventType, EventListener*, bool useCapture);
+ // Event attributes
+ void setAttributeEventListener(ApplicationCacheEventType type, PassRefPtr<EventListener> eventListener) { m_attributeEventListeners[type] = eventListener; }
+ EventListener* getAttributeEventListener(ApplicationCacheEventType type) const { return m_attributeEventListeners[type].get(); }
+ void clearAttributeEventListener(ApplicationCacheEventType type) { m_attributeEventListeners[type] = 0; }
+ void callEventListener(ApplicationCacheEventType type) { callListener(toEventName(type), getAttributeEventListener(type)); }
+
+ // EventTarget impl
+ virtual void addEventListener(const AtomicString& eventName, PassRefPtr<EventListener>, bool useCapture);
+ virtual void removeEventListener(const AtomicString& eventName, 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,68 +82,59 @@
using RefCounted<DOMApplicationCache>::ref;
using RefCounted<DOMApplicationCache>::deref;
- void setOnchecking(PassRefPtr<EventListener> eventListener) { m_onCheckingListener = eventListener; }
- EventListener* onchecking() const { return m_onCheckingListener.get(); }
-
- void setOnerror(PassRefPtr<EventListener> eventListener) { m_onErrorListener = eventListener; }
- EventListener* onerror() const { return m_onErrorListener.get(); }
-
- void setOnnoupdate(PassRefPtr<EventListener> eventListener) { m_onNoUpdateListener = eventListener; }
- EventListener* onnoupdate() const { return m_onNoUpdateListener.get(); }
-
- 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 setOnupdateready(PassRefPtr<EventListener> eventListener) { m_onUpdateReadyListener = eventListener; }
- EventListener* onupdateready() const { return m_onUpdateReadyListener.get(); }
-
- void setOncached(PassRefPtr<EventListener> eventListener) { m_onCachedListener = eventListener; }
- EventListener* oncached() const { return m_onCachedListener.get(); }
-
- void setOnobsolete(PassRefPtr<EventListener> eventListener) { m_onObsoleteListener = eventListener; }
- EventListener* onobsolete() const { return m_onObsoleteListener.get(); }
-
virtual ScriptExecutionContext* scriptExecutionContext() const;
DOMApplicationCache* toDOMApplicationCache() { return this; }
- void callCheckingListener();
- void callErrorListener();
- void callNoUpdateListener();
- void callDownloadingListener();
- void callProgressListener();
- void callUpdateReadyListener();
- void callCachedListener();
- void callObsoleteListener();
-
+ // Explicitly named attribute event listener helpers
+ void setOnchecking(PassRefPtr<EventListener> listener) { setAttributeEventListener(APPCACHE_CHECKING_EVENT, listener); }
+ void setOnerror(PassRefPtr<EventListener> listener) { setAttributeEventListener(APPCACHE_ERROR_EVENT, listener);}
+ void setOnnoupdate(PassRefPtr<EventListener> listener) { setAttributeEventListener(APPCACHE_NOUPDATE_EVENT, listener); }
+ void setOndownloading(PassRefPtr<EventListener> listener) { setAttributeEventListener(APPCACHE_DOWNLOADING_EVENT, listener); }
+ void setOnprogress(PassRefPtr<EventListener> listener) { setAttributeEventListener(APPCACHE_PROGRESS_EVENT, listener); }
+ void setOnupdateready(PassRefPtr<EventListener> listener) { setAttributeEventListener(APPCACHE_UPDATEREADY_EVENT, listener); }
+ void setOncached(PassRefPtr<EventListener> listener) { setAttributeEventListener(APPCACHE_CACHED_EVENT, listener); }
+ void setOnobsolete(PassRefPtr<EventListener> listener) { setAttributeEventListener(APPCACHE_OBSOLETE_EVENT, listener); }
+ EventListener* onchecking() const { return getAttributeEventListener(APPCACHE_CHECKING_EVENT); }
+ EventListener* onerror() const { return getAttributeEventListener(APPCACHE_ERROR_EVENT); }
+ EventListener* onnoupdate() const { return getAttributeEventListener(APPCACHE_NOUPDATE_EVENT); }
+ EventListener* ondownloading() const { return getAttributeEventListener(APPCACHE_DOWNLOADING_EVENT); }
+ EventListener* onprogress() const { return getAttributeEventListener(APPCACHE_PROGRESS_EVENT); }
+ EventListener* onupdateready() const { return getAttributeEventListener(APPCACHE_UPDATEREADY_EVENT); }
+ EventListener* oncached() const { return getAttributeEventListener(APPCACHE_CACHED_EVENT); }
+ EventListener* onobsolete() const { return getAttributeEventListener(APPCACHE_OBSOLETE_EVENT); }
+ void callCheckingListener() { callEventListener(APPCACHE_CHECKING_EVENT); }
+ void callErrorListener() { callEventListener(APPCACHE_ERROR_EVENT); }
+ void callNoUpdateListener() { callEventListener(APPCACHE_NOUPDATE_EVENT); }
+ void callDownloadingListener() { callEventListener(APPCACHE_DOWNLOADING_EVENT); }
+ void callProgressListener() { callEventListener(APPCACHE_PROGRESS_EVENT); }
+ void callUpdateReadyListener() { callEventListener(APPCACHE_UPDATEREADY_EVENT); }
+ void callCachedListener() { callEventListener(APPCACHE_CACHED_EVENT); }
+ void callObsoleteListener() { callEventListener(APPCACHE_OBSOLETE_EVENT); }
+
+ static const AtomicString& toEventName(ApplicationCacheEventType eventType);
+ static ApplicationCacheEventType toEventType(const AtomicString& eventName);
+
private:
DOMApplicationCache(Frame*);
+
void callListener(const AtomicString& eventType, EventListener*);
virtual void refEventTarget() { ref(); }
virtual void derefEventTarget() { deref(); }
- ApplicationCache* associatedCache() const;
+ ApplicationCacheFrontend* appcacheFrontend() const { return m_appcacheFrontend; }
bool swapCache();
- 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[NUMBER_OF_APPCACHE_EVENT_TYPES];
EventListenersMap m_eventListeners;
Frame* m_frame;
+ ApplicationCacheFrontend* m_appcacheFrontend;
+
};
} // namespace WebCore
-#endif // ENABLE(OFFLINE_WEB_APPLICATIONS)
+#endif // ENABLE(APPLICATION_CACHE)
#endif // DOMApplicationCache_h
« no previous file with comments | « loader/appcache2/ApplicationCacheFrontend.cpp ('k') | loader/appcache2/DOMApplicationCache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698