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 13 matching lines...) Expand all Loading... |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #ifndef ServiceWorker_h | 31 #ifndef ServiceWorker_h |
32 #define ServiceWorker_h | 32 #define ServiceWorker_h |
33 | 33 |
| 34 #include "bindings/v8/ScriptPromise.h" |
34 #include "bindings/v8/ScriptWrappable.h" | 35 #include "bindings/v8/ScriptWrappable.h" |
35 #include "bindings/v8/SerializedScriptValue.h" | 36 #include "bindings/v8/SerializedScriptValue.h" |
36 #include "core/workers/AbstractWorker.h" | 37 #include "core/workers/AbstractWorker.h" |
37 #include "public/platform/WebServiceWorker.h" | 38 #include "public/platform/WebServiceWorker.h" |
38 #include "public/platform/WebServiceWorkerProxy.h" | 39 #include "public/platform/WebServiceWorkerProxy.h" |
39 #include "wtf/OwnPtr.h" | 40 #include "wtf/OwnPtr.h" |
40 #include "wtf/PassOwnPtr.h" | 41 #include "wtf/PassOwnPtr.h" |
41 #include "wtf/PassRefPtr.h" | 42 #include "wtf/PassRefPtr.h" |
42 #include "wtf/RefCounted.h" | 43 #include "wtf/RefCounted.h" |
43 | 44 |
44 namespace blink { | 45 namespace blink { |
45 class WebServiceWorker; | 46 class WebServiceWorker; |
46 } | 47 } |
47 | 48 |
48 namespace WebCore { | 49 namespace WebCore { |
49 | 50 |
50 class NewScriptState; | 51 class NewScriptState; |
| 52 class ScriptPromiseResolverWithContext; |
51 | 53 |
52 class ServiceWorker | 54 class ServiceWorker |
53 : public AbstractWorker | 55 : public AbstractWorker |
54 , public ScriptWrappable | 56 , public ScriptWrappable |
55 , public blink::WebServiceWorkerProxy { | 57 , public blink::WebServiceWorkerProxy { |
56 public: | 58 public: |
57 static PassRefPtr<ServiceWorker> create(ExecutionContext*, PassOwnPtr<blink:
:WebServiceWorker>); | 59 static PassRefPtr<ServiceWorker> create(ExecutionContext*, PassOwnPtr<blink:
:WebServiceWorker>); |
58 | 60 |
59 virtual ~ServiceWorker() { } | 61 virtual ~ServiceWorker() { } |
60 | 62 |
61 // For CallbackPromiseAdapter | 63 // For CallbackPromiseAdapter |
62 typedef blink::WebServiceWorker WebType; | 64 typedef blink::WebServiceWorker WebType; |
63 static PassRefPtr<ServiceWorker> from(NewScriptState*, WebType* worker); | 65 static PassRefPtr<ServiceWorker> from(ScriptPromiseResolverWithContext*, Web
Type* worker); |
64 | 66 |
65 void postMessage(PassRefPtr<SerializedScriptValue> message, const MessagePor
tArray*, ExceptionState&); | 67 void postMessage(PassRefPtr<SerializedScriptValue> message, const MessagePor
tArray*, ExceptionState&); |
66 | 68 |
67 const AtomicString& state() const; | 69 const AtomicString& state() const; |
68 DEFINE_ATTRIBUTE_EVENT_LISTENER(statechange); | 70 DEFINE_ATTRIBUTE_EVENT_LISTENER(statechange); |
69 | 71 |
70 // WebServiceWorkerProxy overrides. | 72 // WebServiceWorkerProxy overrides. |
| 73 virtual void onStateChanged(blink::WebServiceWorkerState) OVERRIDE; |
71 virtual void dispatchStateChangeEvent() OVERRIDE; | 74 virtual void dispatchStateChangeEvent() OVERRIDE; |
72 | 75 |
73 // AbstractWorker overrides. | 76 // AbstractWorker overrides. |
74 virtual const AtomicString& interfaceName() const OVERRIDE; | 77 virtual const AtomicString& interfaceName() const OVERRIDE; |
75 | 78 |
76 private: | 79 private: |
| 80 class ThenFunction; |
| 81 |
77 ServiceWorker(ExecutionContext*, PassOwnPtr<blink::WebServiceWorker>); | 82 ServiceWorker(ExecutionContext*, PassOwnPtr<blink::WebServiceWorker>); |
| 83 void onPromiseResolved(); |
| 84 void waitOnPromise(ScriptPromise); |
| 85 void changeState(blink::WebServiceWorkerState); |
78 | 86 |
79 OwnPtr<blink::WebServiceWorker> m_outerWorker; | 87 OwnPtr<blink::WebServiceWorker> m_outerWorker; |
| 88 bool m_isPromisePending; |
| 89 Vector<blink::WebServiceWorkerState> m_queuedStates; |
80 }; | 90 }; |
81 | 91 |
82 } // namespace WebCore | 92 } // namespace WebCore |
83 | 93 |
84 #endif // ServiceWorker_h | 94 #endif // ServiceWorker_h |
OLD | NEW |