diff options
Diffstat (limited to 'chromium/third_party/WebKit/Source/modules/serviceworkers/ServiceWorker.h')
-rw-r--r-- | chromium/third_party/WebKit/Source/modules/serviceworkers/ServiceWorker.h | 63 |
1 files changed, 48 insertions, 15 deletions
diff --git a/chromium/third_party/WebKit/Source/modules/serviceworkers/ServiceWorker.h b/chromium/third_party/WebKit/Source/modules/serviceworkers/ServiceWorker.h index ff1e8491584..ecd0a1befea 100644 --- a/chromium/third_party/WebKit/Source/modules/serviceworkers/ServiceWorker.h +++ b/chromium/third_party/WebKit/Source/modules/serviceworkers/ServiceWorker.h @@ -31,38 +31,71 @@ #ifndef ServiceWorker_h #define ServiceWorker_h +#include "bindings/v8/ScriptPromise.h" +#include "bindings/v8/ScriptWrappable.h" +#include "bindings/v8/SerializedScriptValue.h" +#include "core/workers/AbstractWorker.h" #include "public/platform/WebServiceWorker.h" +#include "public/platform/WebServiceWorkerProxy.h" #include "wtf/OwnPtr.h" #include "wtf/PassOwnPtr.h" #include "wtf/PassRefPtr.h" #include "wtf/RefCounted.h" -namespace blink { -class WebServiceWorker; -} - namespace WebCore { -class ServiceWorker : public RefCounted<ServiceWorker> { +class ScriptState; +class ScriptPromiseResolverWithContext; + +class ServiceWorker + : public AbstractWorker + , public ScriptWrappable + , public blink::WebServiceWorkerProxy { public: - static PassRefPtr<ServiceWorker> create(PassOwnPtr<blink::WebServiceWorker> worker) - { - return adoptRef(new ServiceWorker(worker)); - } + virtual ~ServiceWorker() { } // For CallbackPromiseAdapter typedef blink::WebServiceWorker WebType; - static PassRefPtr<ServiceWorker> from(WebType* worker) - { - return create(adoptPtr(worker)); - } + static PassRefPtr<ServiceWorker> from(ScriptPromiseResolverWithContext*, WebType* worker); + + static PassRefPtr<ServiceWorker> from(ExecutionContext*, WebType*); + + void postMessage(PassRefPtr<SerializedScriptValue> message, const MessagePortArray*, ExceptionState&); + + String scope() const; + String url() const; + const AtomicString& state() const; + DEFINE_ATTRIBUTE_EVENT_LISTENER(statechange); - ~ServiceWorker() { } + // WebServiceWorkerProxy overrides. + virtual bool isReady() OVERRIDE; + virtual void dispatchStateChangeEvent() OVERRIDE; + + // AbstractWorker overrides. + virtual const AtomicString& interfaceName() const OVERRIDE; private: - explicit ServiceWorker(PassOwnPtr<blink::WebServiceWorker>); + class ThenFunction; + + enum ProxyState { + Initial, + RegisterPromisePending, + Ready, + ContextStopped + }; + + static PassRefPtr<ServiceWorker> create(ExecutionContext*, PassOwnPtr<blink::WebServiceWorker>); + ServiceWorker(ExecutionContext*, PassOwnPtr<blink::WebServiceWorker>); + void setProxyState(ProxyState); + void onPromiseResolved(); + void waitOnPromise(ScriptPromise); + + // ActiveDOMObject overrides. + virtual bool hasPendingActivity() const OVERRIDE; + virtual void stop() OVERRIDE; OwnPtr<blink::WebServiceWorker> m_outerWorker; + ProxyState m_proxyState; }; } // namespace WebCore |