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

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

Issue 733983002: Service Worker: FetchEvent.preventDefault() results in a network error (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: sync 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
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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 { 67 {
68 return new RespondWithObserver(context, eventID, requestMode, frameType); 68 return new RespondWithObserver(context, eventID, requestMode, frameType);
69 } 69 }
70 70
71 void RespondWithObserver::contextDestroyed() 71 void RespondWithObserver::contextDestroyed()
72 { 72 {
73 ContextLifecycleObserver::contextDestroyed(); 73 ContextLifecycleObserver::contextDestroyed();
74 m_state = Done; 74 m_state = Done;
75 } 75 }
76 76
77 void RespondWithObserver::didDispatchEvent() 77 void RespondWithObserver::didDispatchEvent(bool defaultPrevented)
78 { 78 {
79 ASSERT(executionContext()); 79 ASSERT(executionContext());
80 if (m_state != Initial) 80 if (m_state != Initial)
81 return; 81 return;
82
83 if (defaultPrevented) {
84 responseWasRejected();
85 return;
86 }
87
82 ServiceWorkerGlobalScopeClient::from(executionContext())->didHandleFetchEven t(m_eventID); 88 ServiceWorkerGlobalScopeClient::from(executionContext())->didHandleFetchEven t(m_eventID);
83 m_state = Done; 89 m_state = Done;
84 } 90 }
85 91
86 void RespondWithObserver::respondWith(ScriptState* scriptState, const ScriptValu e& value, ExceptionState& exceptionState) 92 void RespondWithObserver::respondWith(ScriptState* scriptState, const ScriptValu e& value, ExceptionState& exceptionState)
87 { 93 {
88 ASSERT(RuntimeEnabledFeatures::serviceWorkerOnFetchEnabled()); 94 ASSERT(RuntimeEnabledFeatures::serviceWorkerOnFetchEnabled());
89 if (m_state != Initial) { 95 if (m_state != Initial) {
90 exceptionState.throwDOMException(InvalidStateError, "The fetch event has already been responded to."); 96 exceptionState.throwDOMException(InvalidStateError, "The fetch event has already been responded to.");
91 return; 97 return;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 RespondWithObserver::RespondWithObserver(ExecutionContext* context, int eventID, WebURLRequest::FetchRequestMode requestMode, WebURLRequest::FrameType frameType ) 142 RespondWithObserver::RespondWithObserver(ExecutionContext* context, int eventID, WebURLRequest::FetchRequestMode requestMode, WebURLRequest::FrameType frameType )
137 : ContextLifecycleObserver(context) 143 : ContextLifecycleObserver(context)
138 , m_eventID(eventID) 144 , m_eventID(eventID)
139 , m_requestMode(requestMode) 145 , m_requestMode(requestMode)
140 , m_frameType(frameType) 146 , m_frameType(frameType)
141 , m_state(Initial) 147 , m_state(Initial)
142 { 148 {
143 } 149 }
144 150
145 } // namespace blink 151 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/serviceworkers/RespondWithObserver.h ('k') | Source/web/ServiceWorkerGlobalScopeProxy.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698