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

Side by Side Diff: Source/modules/serviceworkers/WaitUntilObserver.cpp

Issue 1256133002: Service Worker: Correct Web IDL of ExtendableEvent.waitUntil method. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Address comment: add/delete headers. Created 5 years, 4 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 unified diff | Download patch
OLDNEW
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"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 } 100 }
101 101
102 void WaitUntilObserver::didDispatchEvent(bool errorOccurred) 102 void WaitUntilObserver::didDispatchEvent(bool errorOccurred)
103 { 103 {
104 if (errorOccurred) 104 if (errorOccurred)
105 m_hasError = true; 105 m_hasError = true;
106 decrementPendingActivity(); 106 decrementPendingActivity();
107 m_eventDispatched = true; 107 m_eventDispatched = true;
108 } 108 }
109 109
110 void WaitUntilObserver::waitUntil(ScriptState* scriptState, const ScriptValue& v alue, ExceptionState& exceptionState) 110 void WaitUntilObserver::waitUntil(ScriptState* scriptState, ScriptPromise script Promise, ExceptionState& exceptionState)
111 { 111 {
112 if (m_eventDispatched) { 112 if (m_eventDispatched) {
113 exceptionState.throwDOMException(InvalidStateError, "The event handler i s already finished."); 113 exceptionState.throwDOMException(InvalidStateError, "The event handler i s already finished.");
114 return; 114 return;
115 } 115 }
116 116
117 if (!executionContext()) 117 if (!executionContext())
118 return; 118 return;
119 119
120 // When handling a notificationclick event, we want to allow one window to 120 // When handling a notificationclick event, we want to allow one window to
121 // be focused or opened. See comments in ::willDispatchEvent(). When 121 // be focused or opened. See comments in ::willDispatchEvent(). When
122 // waitUntil() is being used, opening or closing a window must happen in a 122 // waitUntil() is being used, opening or closing a window must happen in a
123 // timeframe specified by windowInteractionTimeout(), otherwise the calls 123 // timeframe specified by windowInteractionTimeout(), otherwise the calls
124 // will fail. 124 // will fail.
125 if (m_type == NotificationClick) 125 if (m_type == NotificationClick)
126 m_consumeWindowInteractionTimer.startOneShot(windowInteractionTimeout(), FROM_HERE); 126 m_consumeWindowInteractionTimer.startOneShot(windowInteractionTimeout(), FROM_HERE);
127 127
128 incrementPendingActivity(); 128 incrementPendingActivity();
129 ScriptPromise::cast(scriptState, value).then( 129 scriptPromise.then(
130 ThenFunction::createFunction(scriptState, this, ThenFunction::Fulfilled) , 130 ThenFunction::createFunction(scriptState, this, ThenFunction::Fulfilled) ,
131 ThenFunction::createFunction(scriptState, this, ThenFunction::Rejected)) ; 131 ThenFunction::createFunction(scriptState, this, ThenFunction::Rejected)) ;
132 } 132 }
133 133
134 WaitUntilObserver::WaitUntilObserver(ExecutionContext* context, EventType type, int eventID) 134 WaitUntilObserver::WaitUntilObserver(ExecutionContext* context, EventType type, int eventID)
135 : ContextLifecycleObserver(context) 135 : ContextLifecycleObserver(context)
136 , m_type(type) 136 , m_type(type)
137 , m_eventID(eventID) 137 , m_eventID(eventID)
138 , m_pendingActivity(0) 138 , m_pendingActivity(0)
139 , m_hasError(false) 139 , m_hasError(false)
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 return; 191 return;
192 executionContext()->consumeWindowInteraction(); 192 executionContext()->consumeWindowInteraction();
193 } 193 }
194 194
195 DEFINE_TRACE(WaitUntilObserver) 195 DEFINE_TRACE(WaitUntilObserver)
196 { 196 {
197 ContextLifecycleObserver::trace(visitor); 197 ContextLifecycleObserver::trace(visitor);
198 } 198 }
199 199
200 } // namespace blink 200 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698