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

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

Issue 804163002: Revert 186849 "Bind Window focus ability to the ExecutionContext..." (Closed) Base URL: svn://svn.chromium.org/blink/branches/chromium/2250/
Patch Set: Created 6 years 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/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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 m_eventDispatched = true; 81 m_eventDispatched = true;
82 } 82 }
83 83
84 void WaitUntilObserver::waitUntil(ScriptState* scriptState, const ScriptValue& v alue, ExceptionState& exceptionState) 84 void WaitUntilObserver::waitUntil(ScriptState* scriptState, const ScriptValue& v alue, ExceptionState& exceptionState)
85 { 85 {
86 if (m_eventDispatched) { 86 if (m_eventDispatched) {
87 exceptionState.throwDOMException(InvalidStateError, "The event handler i s already finished."); 87 exceptionState.throwDOMException(InvalidStateError, "The event handler i s already finished.");
88 return; 88 return;
89 } 89 }
90 90
91 if (!executionContext())
92 return;
93
94 // When handling a notificationclick event, we want to allow one window to
95 // be focused. Regardless of whether one window was focused,
96 // |consumeWindowFocus| will be called when all the pending activities will
97 // be resolved.
98 if (m_type == NotificationClick)
99 executionContext()->allowWindowFocus();
100
101 incrementPendingActivity(); 91 incrementPendingActivity();
102 ScriptPromise::cast(scriptState, value).then( 92 ScriptPromise::cast(scriptState, value).then(
103 ThenFunction::createFunction(scriptState, this, ThenFunction::Fulfilled) , 93 ThenFunction::createFunction(scriptState, this, ThenFunction::Fulfilled) ,
104 ThenFunction::createFunction(scriptState, this, ThenFunction::Rejected)) ; 94 ThenFunction::createFunction(scriptState, this, ThenFunction::Rejected)) ;
105 } 95 }
106 96
107 WaitUntilObserver::WaitUntilObserver(ExecutionContext* context, EventType type, int eventID) 97 WaitUntilObserver::WaitUntilObserver(ExecutionContext* context, EventType type, int eventID)
108 : ContextLifecycleObserver(context) 98 : ContextLifecycleObserver(context)
109 , m_type(type) 99 , m_type(type)
110 , m_eventID(eventID) 100 , m_eventID(eventID)
(...skipping 26 matching lines...) Expand all
137 WebServiceWorkerEventResult result = m_hasError ? WebServiceWorkerEventResul tRejected : WebServiceWorkerEventResultCompleted; 127 WebServiceWorkerEventResult result = m_hasError ? WebServiceWorkerEventResul tRejected : WebServiceWorkerEventResultCompleted;
138 switch (m_type) { 128 switch (m_type) {
139 case Activate: 129 case Activate:
140 client->didHandleActivateEvent(m_eventID, result); 130 client->didHandleActivateEvent(m_eventID, result);
141 break; 131 break;
142 case Install: 132 case Install:
143 client->didHandleInstallEvent(m_eventID, result); 133 client->didHandleInstallEvent(m_eventID, result);
144 break; 134 break;
145 case NotificationClick: 135 case NotificationClick:
146 client->didHandleNotificationClickEvent(m_eventID, result); 136 client->didHandleNotificationClickEvent(m_eventID, result);
147 executionContext()->consumeWindowFocus();
148 break; 137 break;
149 case Push: 138 case Push:
150 client->didHandlePushEvent(m_eventID, result); 139 client->didHandlePushEvent(m_eventID, result);
151 break; 140 break;
152 } 141 }
153 observeContext(0); 142 observeContext(0);
154 } 143 }
155 144
156 } // namespace blink 145 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/serviceworkers/ServiceWorkerClient.cpp ('k') | Source/web/WebScopedWindowFocusAllowedIndicator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698