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

Side by Side Diff: third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerGlobalScope.cpp

Issue 2734783002: Fix oninstall-script tests for service worker (Closed)
Patch Set: delete tests Created 3 years, 9 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
« no previous file with comments | « third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerGlobalScope.h ('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 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 double timeOrigin, 97 double timeOrigin,
98 std::unique_ptr<SecurityOrigin::PrivilegeData> starterOriginPrivilegeData, 98 std::unique_ptr<SecurityOrigin::PrivilegeData> starterOriginPrivilegeData,
99 WorkerClients* workerClients) 99 WorkerClients* workerClients)
100 : WorkerGlobalScope(url, 100 : WorkerGlobalScope(url,
101 userAgent, 101 userAgent,
102 thread, 102 thread,
103 timeOrigin, 103 timeOrigin,
104 std::move(starterOriginPrivilegeData), 104 std::move(starterOriginPrivilegeData),
105 workerClients), 105 workerClients),
106 m_didEvaluateScript(false), 106 m_didEvaluateScript(false),
107 m_hadErrorInTopLevelEventHandler(false),
108 m_eventNestingLevel(0),
109 m_scriptCount(0), 107 m_scriptCount(0),
110 m_scriptTotalSize(0), 108 m_scriptTotalSize(0),
111 m_scriptCachedMetadataTotalSize(0) {} 109 m_scriptCachedMetadataTotalSize(0) {}
112 110
113 ServiceWorkerGlobalScope::~ServiceWorkerGlobalScope() {} 111 ServiceWorkerGlobalScope::~ServiceWorkerGlobalScope() {}
114 112
115 void ServiceWorkerGlobalScope::countScript(size_t scriptSize, 113 void ServiceWorkerGlobalScope::countScript(size_t scriptSize,
116 size_t cachedMetadataSize) { 114 size_t cachedMetadataSize) {
117 ++m_scriptCount; 115 ++m_scriptCount;
118 m_scriptTotalSize += scriptSize; 116 m_scriptTotalSize += scriptSize;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 return WorkerGlobalScope::addEventListenerInternal(eventType, listener, 193 return WorkerGlobalScope::addEventListenerInternal(eventType, listener,
196 options); 194 options);
197 } 195 }
198 196
199 const AtomicString& ServiceWorkerGlobalScope::interfaceName() const { 197 const AtomicString& ServiceWorkerGlobalScope::interfaceName() const {
200 return EventTargetNames::ServiceWorkerGlobalScope; 198 return EventTargetNames::ServiceWorkerGlobalScope;
201 } 199 }
202 200
203 DispatchEventResult ServiceWorkerGlobalScope::dispatchEventInternal( 201 DispatchEventResult ServiceWorkerGlobalScope::dispatchEventInternal(
204 Event* event) { 202 Event* event) {
205 m_eventNestingLevel++; 203 return WorkerGlobalScope::dispatchEventInternal(event);
falken 2017/03/21 04:27:37 Since it's now just calling the superclass's funct
yiyix 2017/03/21 05:44:27 Good call. Removed.
206 DispatchEventResult dispatchResult =
207 WorkerGlobalScope::dispatchEventInternal(event);
208 if (event->interfaceName() == EventNames::ErrorEvent &&
209 m_eventNestingLevel == 2)
210 m_hadErrorInTopLevelEventHandler = true;
211 m_eventNestingLevel--;
212 return dispatchResult;
213 } 204 }
214 205
215 void ServiceWorkerGlobalScope::dispatchExtendableEvent( 206 void ServiceWorkerGlobalScope::dispatchExtendableEvent(
216 Event* event, 207 Event* event,
217 WaitUntilObserver* observer) { 208 WaitUntilObserver* observer) {
218 ASSERT(m_eventNestingLevel == 0);
219 m_hadErrorInTopLevelEventHandler = false;
220
221 observer->willDispatchEvent(); 209 observer->willDispatchEvent();
222 dispatchEvent(event); 210 dispatchEvent(event);
223 211
224 // Check if the worker thread is forcibly terminated during the event 212 // Check if the worker thread is forcibly terminated during the event
225 // because of timeout etc. 213 // because of timeout etc.
226 if (thread()->isForciblyTerminated()) 214 observer->didDispatchEvent(thread()->isForciblyTerminated());
falken 2017/03/21 04:27:37 Note for future reference: we could probably revis
yiyix 2017/03/21 05:44:27 Would it be preferable to add a TODO?
falken 2017/03/21 05:52:15 Hm, I think it's OK without it. The code will prob
227 m_hadErrorInTopLevelEventHandler = true;
228
229 observer->didDispatchEvent(m_hadErrorInTopLevelEventHandler);
230 } 215 }
231 216
232 DEFINE_TRACE(ServiceWorkerGlobalScope) { 217 DEFINE_TRACE(ServiceWorkerGlobalScope) {
233 visitor->trace(m_clients); 218 visitor->trace(m_clients);
234 visitor->trace(m_registration); 219 visitor->trace(m_registration);
235 WorkerGlobalScope::trace(visitor); 220 WorkerGlobalScope::trace(visitor);
236 } 221 }
237 222
238 void ServiceWorkerGlobalScope::importScripts(const Vector<String>& urls, 223 void ServiceWorkerGlobalScope::importScripts(const Vector<String>& urls,
239 ExceptionState& exceptionState) { 224 ExceptionState& exceptionState) {
(...skipping 14 matching lines...) Expand all
254 } 239 }
255 240
256 void ServiceWorkerGlobalScope::exceptionThrown(ErrorEvent* event) { 241 void ServiceWorkerGlobalScope::exceptionThrown(ErrorEvent* event) {
257 WorkerGlobalScope::exceptionThrown(event); 242 WorkerGlobalScope::exceptionThrown(event);
258 if (WorkerThreadDebugger* debugger = 243 if (WorkerThreadDebugger* debugger =
259 WorkerThreadDebugger::from(thread()->isolate())) 244 WorkerThreadDebugger::from(thread()->isolate()))
260 debugger->exceptionThrown(thread(), event); 245 debugger->exceptionThrown(thread(), event);
261 } 246 }
262 247
263 } // namespace blink 248 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerGlobalScope.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698