| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 #include "bindings/v8/ScriptWrappable.h" | 35 #include "bindings/v8/ScriptWrappable.h" |
| 36 #include "bindings/v8/SerializedScriptValue.h" | 36 #include "bindings/v8/SerializedScriptValue.h" |
| 37 #include "core/workers/AbstractWorker.h" | 37 #include "core/workers/AbstractWorker.h" |
| 38 #include "public/platform/WebServiceWorker.h" | 38 #include "public/platform/WebServiceWorker.h" |
| 39 #include "public/platform/WebServiceWorkerProxy.h" | 39 #include "public/platform/WebServiceWorkerProxy.h" |
| 40 #include "wtf/OwnPtr.h" | 40 #include "wtf/OwnPtr.h" |
| 41 #include "wtf/PassOwnPtr.h" | 41 #include "wtf/PassOwnPtr.h" |
| 42 #include "wtf/PassRefPtr.h" | 42 #include "wtf/PassRefPtr.h" |
| 43 #include "wtf/RefCounted.h" | 43 #include "wtf/RefCounted.h" |
| 44 | 44 |
| 45 namespace blink { | |
| 46 class WebServiceWorker; | |
| 47 } | |
| 48 | |
| 49 namespace WebCore { | 45 namespace WebCore { |
| 50 | 46 |
| 51 class ScriptState; | 47 class ScriptState; |
| 52 class ScriptPromiseResolverWithContext; | 48 class ScriptPromiseResolverWithContext; |
| 53 | 49 |
| 54 class ServiceWorker | 50 class ServiceWorker |
| 55 : public AbstractWorker | 51 : public AbstractWorker |
| 56 , public ScriptWrappable | 52 , public ScriptWrappable |
| 57 , public blink::WebServiceWorkerProxy { | 53 , public blink::WebServiceWorkerProxy { |
| 58 public: | 54 public: |
| 59 static PassRefPtr<ServiceWorker> create(ExecutionContext*, PassOwnPtr<blink:
:WebServiceWorker>); | 55 static PassRefPtr<ServiceWorker> create(ExecutionContext*, PassOwnPtr<blink:
:WebServiceWorker>); |
| 60 | 56 |
| 61 virtual ~ServiceWorker() { } | 57 virtual ~ServiceWorker() { } |
| 62 | 58 |
| 63 // For CallbackPromiseAdapter | 59 // For CallbackPromiseAdapter |
| 64 typedef blink::WebServiceWorker WebType; | 60 typedef blink::WebServiceWorker WebType; |
| 65 static PassRefPtr<ServiceWorker> from(ScriptPromiseResolverWithContext*, Web
Type* worker); | 61 static PassRefPtr<ServiceWorker> from(ScriptPromiseResolverWithContext*, Web
Type* worker); |
| 66 | 62 |
| 63 static PassRefPtr<ServiceWorker> from(ScriptState*, WebType*); |
| 64 |
| 67 void postMessage(PassRefPtr<SerializedScriptValue> message, const MessagePor
tArray*, ExceptionState&); | 65 void postMessage(PassRefPtr<SerializedScriptValue> message, const MessagePor
tArray*, ExceptionState&); |
| 68 | 66 |
| 69 String scope() const; | 67 String scope() const; |
| 70 String url() const; | 68 String url() const; |
| 71 const AtomicString& state() const; | 69 const AtomicString& state() const; |
| 72 DEFINE_ATTRIBUTE_EVENT_LISTENER(statechange); | 70 DEFINE_ATTRIBUTE_EVENT_LISTENER(statechange); |
| 73 | 71 |
| 74 // WebServiceWorkerProxy overrides. | 72 // WebServiceWorkerProxy overrides. |
| 75 virtual bool isReady() OVERRIDE; | 73 virtual bool isReady() OVERRIDE; |
| 76 virtual void dispatchStateChangeEvent() OVERRIDE; | 74 virtual void dispatchStateChangeEvent() OVERRIDE; |
| 77 | 75 |
| 78 // AbstractWorker overrides. | 76 // AbstractWorker overrides. |
| 79 virtual const AtomicString& interfaceName() const OVERRIDE; | 77 virtual const AtomicString& interfaceName() const OVERRIDE; |
| 80 | 78 |
| 81 private: | 79 private: |
| 82 class ThenFunction; | 80 class ThenFunction; |
| 83 | 81 |
| 84 ServiceWorker(ExecutionContext*, PassOwnPtr<blink::WebServiceWorker>); | 82 ServiceWorker(ExecutionContext*, PassOwnPtr<blink::WebServiceWorker>); |
| 85 void onPromiseResolved(); | 83 void onPromiseResolved(); |
| 86 void waitOnPromise(ScriptPromise); | 84 void waitOnPromise(ScriptPromise); |
| 87 | 85 |
| 88 OwnPtr<blink::WebServiceWorker> m_outerWorker; | 86 OwnPtr<blink::WebServiceWorker> m_outerWorker; |
| 89 bool m_isPromisePending; | 87 bool m_isPromisePending; |
| 90 }; | 88 }; |
| 91 | 89 |
| 92 } // namespace WebCore | 90 } // namespace WebCore |
| 93 | 91 |
| 94 #endif // ServiceWorker_h | 92 #endif // ServiceWorker_h |
| OLD | NEW |