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

Side by Side Diff: Source/core/workers/WorkerGlobalScope.cpp

Issue 203393002: Revert of Explicit notification and removal of lifecycle observers. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 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 | « Source/core/workers/WorkerGlobalScope.h ('k') | Source/core/workers/WorkerThread.cpp » ('j') | 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) 2008 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved.
3 * Copyright (C) 2009, 2011 Google Inc. All Rights Reserved. 3 * Copyright (C) 2009, 2011 Google Inc. All Rights Reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 , m_timeOrigin(timeOrigin) 86 , m_timeOrigin(timeOrigin)
87 { 87 {
88 ScriptWrappable::init(this); 88 ScriptWrappable::init(this);
89 setClient(this); 89 setClient(this);
90 setSecurityOrigin(SecurityOrigin::create(url)); 90 setSecurityOrigin(SecurityOrigin::create(url));
91 m_workerClients->reattachThread(); 91 m_workerClients->reattachThread();
92 } 92 }
93 93
94 WorkerGlobalScope::~WorkerGlobalScope() 94 WorkerGlobalScope::~WorkerGlobalScope()
95 { 95 {
96 #if !ENABLE(OILPAN)
97 dispose();
98 #endif
96 } 99 }
97 100
98 void WorkerGlobalScope::applyContentSecurityPolicyFromString(const String& polic y, ContentSecurityPolicyHeaderType contentSecurityPolicyType) 101 void WorkerGlobalScope::applyContentSecurityPolicyFromString(const String& polic y, ContentSecurityPolicyHeaderType contentSecurityPolicyType)
99 { 102 {
100 setContentSecurityPolicy(ContentSecurityPolicy::create(this)); 103 setContentSecurityPolicy(ContentSecurityPolicy::create(this));
101 contentSecurityPolicy()->didReceiveHeader(policy, contentSecurityPolicyType, ContentSecurityPolicyHeaderSourceHTTP); 104 contentSecurityPolicy()->didReceiveHeader(policy, contentSecurityPolicyType, ContentSecurityPolicyHeaderSourceHTTP);
102 } 105 }
103 106
104 ExecutionContext* WorkerGlobalScope::executionContext() const 107 ExecutionContext* WorkerGlobalScope::executionContext() const
105 { 108 {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 189
187 void WorkerGlobalScope::willStopActiveDOMObjects() 190 void WorkerGlobalScope::willStopActiveDOMObjects()
188 { 191 {
189 lifecycleNotifier().notifyWillStopActiveDOMObjects(); 192 lifecycleNotifier().notifyWillStopActiveDOMObjects();
190 } 193 }
191 194
192 void WorkerGlobalScope::dispose() 195 void WorkerGlobalScope::dispose()
193 { 196 {
194 ASSERT(thread()->isCurrentThread()); 197 ASSERT(thread()->isCurrentThread());
195 198
199 // Notify proxy that we are going away. This can free the WorkerThread objec t, so do not access it after this.
200 thread()->workerReportingProxy().workerGlobalScopeDestroyed();
201
196 clearScript(); 202 clearScript();
197 clearInspector(); 203 clearInspector();
198 setClient(0); 204 setClient(0);
199 205
200 // Observers must not access the context of a disposed WorkerGlobalScope 206 // The thread reference isn't currently cleared, as the execution
201 // lacking a thread object. 207 // context's thread is accessed by GCed lifetime objects when
202 // 208 // they're finalized.
203 // Notify them now that the context has been destroyed and explicitly remove 209 // FIXME: oilpan: avoid by explicitly removing the WorkerGlobalScope
204 // them as observers. If this is delayed until the LifecycleNotifier of the 210 // as an observable context right here.
205 // WorkerGlobalScope is garbage collected and destructed, some observers
206 // may have access to the disposed object (it all depends on the order
207 // the garbage collector finalizes these objects.) Prevent that situation fr om
208 // arising here.
209 removeAllLifecycleObservers();
210 clearThread();
211 } 211 }
212 212
213 void WorkerGlobalScope::importScripts(const Vector<String>& urls, ExceptionState & exceptionState) 213 void WorkerGlobalScope::importScripts(const Vector<String>& urls, ExceptionState & exceptionState)
214 { 214 {
215 ASSERT(contentSecurityPolicy()); 215 ASSERT(contentSecurityPolicy());
216 Vector<String>::const_iterator urlsEnd = urls.end(); 216 Vector<String>::const_iterator urlsEnd = urls.end();
217 Vector<KURL> completedURLs; 217 Vector<KURL> completedURLs;
218 for (Vector<String>::const_iterator it = urls.begin(); it != urlsEnd; ++it) { 218 for (Vector<String>::const_iterator it = urls.begin(); it != urlsEnd; ++it) {
219 const KURL& url = executionContext()->completeURL(*it); 219 const KURL& url = executionContext()->completeURL(*it);
220 if (!url.isValid()) { 220 if (!url.isValid()) {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 { 305 {
306 visitor->trace(m_console); 306 visitor->trace(m_console);
307 visitor->trace(m_location); 307 visitor->trace(m_location);
308 visitor->trace(m_navigator); 308 visitor->trace(m_navigator);
309 #if ENABLE(OILPAN) 309 #if ENABLE(OILPAN)
310 HeapSupplementable<WorkerGlobalScope>::trace(visitor); 310 HeapSupplementable<WorkerGlobalScope>::trace(visitor);
311 #endif 311 #endif
312 } 312 }
313 313
314 } // namespace WebCore 314 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/workers/WorkerGlobalScope.h ('k') | Source/core/workers/WorkerThread.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698