OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 #include "modules/serviceworkers/WaitUntilObserver.h" | 6 #include "modules/serviceworkers/WaitUntilObserver.h" |
7 | 7 |
8 #include "bindings/core/v8/ScriptFunction.h" | 8 #include "bindings/core/v8/ScriptFunction.h" |
9 #include "bindings/core/v8/ScriptPromise.h" | 9 #include "bindings/core/v8/ScriptPromise.h" |
10 #include "bindings/core/v8/ScriptValue.h" | 10 #include "bindings/core/v8/ScriptValue.h" |
11 #include "bindings/core/v8/V8Binding.h" | 11 #include "bindings/core/v8/V8Binding.h" |
12 #include "core/dom/ExecutionContext.h" | 12 #include "core/dom/ExecutionContext.h" |
13 #include "platform/NotImplemented.h" | 13 #include "platform/NotImplemented.h" |
14 #include "public/platform/WebServiceWorkerEventResult.h" | 14 #include "public/platform/WebServiceWorkerEventResult.h" |
15 #include "wtf/Assertions.h" | 15 #include "wtf/Assertions.h" |
16 #include "wtf/RefCounted.h" | 16 #include "wtf/RefCounted.h" |
17 #include "wtf/RefPtr.h" | 17 #include "wtf/RefPtr.h" |
18 #include <v8.h> | 18 #include <v8.h> |
19 | 19 |
20 namespace blink { | 20 namespace blink { |
21 | 21 |
22 class WaitUntilObserver::ThenFunction FINAL : public ScriptFunction { | 22 class WaitUntilObserver::ThenFunction final : public ScriptFunction { |
23 public: | 23 public: |
24 enum ResolveType { | 24 enum ResolveType { |
25 Fulfilled, | 25 Fulfilled, |
26 Rejected, | 26 Rejected, |
27 }; | 27 }; |
28 | 28 |
29 static v8::Handle<v8::Function> createFunction(ScriptState* scriptState, Wai
tUntilObserver* observer, ResolveType type) | 29 static v8::Handle<v8::Function> createFunction(ScriptState* scriptState, Wai
tUntilObserver* observer, ResolveType type) |
30 { | 30 { |
31 ThenFunction* self = new ThenFunction(scriptState, observer, type); | 31 ThenFunction* self = new ThenFunction(scriptState, observer, type); |
32 return self->bindToV8Function(); | 32 return self->bindToV8Function(); |
33 } | 33 } |
34 | 34 |
35 virtual void trace(Visitor* visitor) OVERRIDE | 35 virtual void trace(Visitor* visitor) override |
36 { | 36 { |
37 visitor->trace(m_observer); | 37 visitor->trace(m_observer); |
38 ScriptFunction::trace(visitor); | 38 ScriptFunction::trace(visitor); |
39 } | 39 } |
40 | 40 |
41 private: | 41 private: |
42 ThenFunction(ScriptState* scriptState, WaitUntilObserver* observer, ResolveT
ype type) | 42 ThenFunction(ScriptState* scriptState, WaitUntilObserver* observer, ResolveT
ype type) |
43 : ScriptFunction(scriptState) | 43 : ScriptFunction(scriptState) |
44 , m_observer(observer) | 44 , m_observer(observer) |
45 , m_resolveType(type) | 45 , m_resolveType(type) |
46 { | 46 { |
47 } | 47 } |
48 | 48 |
49 virtual ScriptValue call(ScriptValue value) OVERRIDE | 49 virtual ScriptValue call(ScriptValue value) override |
50 { | 50 { |
51 ASSERT(m_observer); | 51 ASSERT(m_observer); |
52 ASSERT(m_resolveType == Fulfilled || m_resolveType == Rejected); | 52 ASSERT(m_resolveType == Fulfilled || m_resolveType == Rejected); |
53 if (m_resolveType == Rejected) | 53 if (m_resolveType == Rejected) |
54 m_observer->reportError(value); | 54 m_observer->reportError(value); |
55 m_observer->decrementPendingActivity(); | 55 m_observer->decrementPendingActivity(); |
56 m_observer = nullptr; | 56 m_observer = nullptr; |
57 return value; | 57 return value; |
58 } | 58 } |
59 | 59 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 client->didHandleActivateEvent(m_eventID, result); | 119 client->didHandleActivateEvent(m_eventID, result); |
120 break; | 120 break; |
121 case Install: | 121 case Install: |
122 client->didHandleInstallEvent(m_eventID, result); | 122 client->didHandleInstallEvent(m_eventID, result); |
123 break; | 123 break; |
124 } | 124 } |
125 observeContext(0); | 125 observeContext(0); |
126 } | 126 } |
127 | 127 |
128 } // namespace blink | 128 } // namespace blink |
OLD | NEW |