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

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

Issue 723063002: Service Worker: Add a test for calling respondWith() asynchronously. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: actualyl upload Created 6 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « LayoutTests/http/tests/serviceworker/resources/fetch-event-async-respond-with-worker.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/RespondWithObserver.h" 6 #include "modules/serviceworkers/RespondWithObserver.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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 if (m_state != Initial) 80 if (m_state != Initial)
81 return; 81 return;
82 ServiceWorkerGlobalScopeClient::from(executionContext())->didHandleFetchEven t(m_eventID); 82 ServiceWorkerGlobalScopeClient::from(executionContext())->didHandleFetchEven t(m_eventID);
83 m_state = Done; 83 m_state = Done;
84 } 84 }
85 85
86 void RespondWithObserver::respondWith(ScriptState* scriptState, const ScriptValu e& value, ExceptionState& exceptionState) 86 void RespondWithObserver::respondWith(ScriptState* scriptState, const ScriptValu e& value, ExceptionState& exceptionState)
87 { 87 {
88 ASSERT(RuntimeEnabledFeatures::serviceWorkerOnFetchEnabled()); 88 ASSERT(RuntimeEnabledFeatures::serviceWorkerOnFetchEnabled());
89 if (m_state != Initial) { 89 if (m_state != Initial) {
90 exceptionState.throwDOMException(InvalidStateError, "respondWith is alre ady called."); 90 exceptionState.throwDOMException(InvalidStateError, "The fetch event has already been responded to.");
91 return; 91 return;
92 } 92 }
93 93
94 m_state = Pending; 94 m_state = Pending;
95 ScriptPromise::cast(scriptState, value).then( 95 ScriptPromise::cast(scriptState, value).then(
96 ThenFunction::createFunction(scriptState, this, ThenFunction::Fulfilled) , 96 ThenFunction::createFunction(scriptState, this, ThenFunction::Fulfilled) ,
97 ThenFunction::createFunction(scriptState, this, ThenFunction::Rejected)) ; 97 ThenFunction::createFunction(scriptState, this, ThenFunction::Rejected)) ;
98 } 98 }
99 99
100 void RespondWithObserver::responseWasRejected() 100 void RespondWithObserver::responseWasRejected()
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 RespondWithObserver::RespondWithObserver(ExecutionContext* context, int eventID, WebURLRequest::FetchRequestMode requestMode, WebURLRequest::FrameType frameType ) 136 RespondWithObserver::RespondWithObserver(ExecutionContext* context, int eventID, WebURLRequest::FetchRequestMode requestMode, WebURLRequest::FrameType frameType )
137 : ContextLifecycleObserver(context) 137 : ContextLifecycleObserver(context)
138 , m_eventID(eventID) 138 , m_eventID(eventID)
139 , m_requestMode(requestMode) 139 , m_requestMode(requestMode)
140 , m_frameType(frameType) 140 , m_frameType(frameType)
141 , m_state(Initial) 141 , m_state(Initial)
142 { 142 {
143 } 143 }
144 144
145 } // namespace blink 145 } // namespace blink
OLDNEW
« no previous file with comments | « LayoutTests/http/tests/serviceworker/resources/fetch-event-async-respond-with-worker.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698