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

Side by Side Diff: WebCore/dom/ScriptExecutionContext.cpp

Issue 9572031: Don't be so CRASH happy in the bindings layer. (Closed) Base URL: http://svn.webkit.org/repository/webkit/trunk/Source/
Patch Set: Created 8 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 | « WebCore/dom/ScriptExecutionContext.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) 2008 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved.
3 * Copyright (C) 2012 Google Inc. All Rights Reserved.
3 * 4 *
4 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
6 * are met: 7 * are met:
7 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 11 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 12 * documentation and/or other materials provided with the distribution.
12 * 13 *
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 void ScriptExecutionContext::AddConsoleMessageTask::performTask(ScriptExecutionC ontext* context) 85 void ScriptExecutionContext::AddConsoleMessageTask::performTask(ScriptExecutionC ontext* context)
85 { 86 {
86 context->addConsoleMessage(m_source, m_type, m_level, m_message); 87 context->addConsoleMessage(m_source, m_type, m_level, m_message);
87 } 88 }
88 89
89 ScriptExecutionContext::ScriptExecutionContext() 90 ScriptExecutionContext::ScriptExecutionContext()
90 : m_iteratingActiveDOMObjects(false) 91 : m_iteratingActiveDOMObjects(false)
91 , m_inDestructor(false) 92 , m_inDestructor(false)
92 , m_inDispatchErrorEvent(false) 93 , m_inDispatchErrorEvent(false)
93 , m_activeDOMObjectsAreSuspended(false) 94 , m_activeDOMObjectsAreSuspended(false)
95 , m_reasonForSuspendingActiveDOMObjects(static_cast<ActiveDOMObject::ReasonF orSuspension>(0))
96 , m_activeDOMObjectsAreStopped(false)
94 { 97 {
95 } 98 }
96 99
97 ScriptExecutionContext::~ScriptExecutionContext() 100 ScriptExecutionContext::~ScriptExecutionContext()
98 { 101 {
99 m_inDestructor = true; 102 m_inDestructor = true;
100 for (HashSet<ContextDestructionObserver*>::iterator iter = m_destructionObse rvers.begin(); iter != m_destructionObservers.end(); iter = m_destructionObserve rs.begin()) { 103 for (HashSet<ContextDestructionObserver*>::iterator iter = m_destructionObse rvers.begin(); iter != m_destructionObservers.end(); iter = m_destructionObserve rs.begin()) {
101 ContextDestructionObserver* observer = *iter; 104 ContextDestructionObserver* observer = *iter;
102 m_destructionObservers.remove(observer); 105 m_destructionObservers.remove(observer);
103 ASSERT(observer->scriptExecutionContext() == this); 106 ASSERT(observer->scriptExecutionContext() == this);
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 for (HashMap<ActiveDOMObject*, void*>::iterator iter = m_activeDOMObjects.be gin(); iter != activeObjectsEnd; ++iter) { 210 for (HashMap<ActiveDOMObject*, void*>::iterator iter = m_activeDOMObjects.be gin(); iter != activeObjectsEnd; ++iter) {
208 ASSERT(iter->first->scriptExecutionContext() == this); 211 ASSERT(iter->first->scriptExecutionContext() == this);
209 ASSERT(iter->first->suspendIfNeededCalled()); 212 ASSERT(iter->first->suspendIfNeededCalled());
210 iter->first->resume(); 213 iter->first->resume();
211 } 214 }
212 m_iteratingActiveDOMObjects = false; 215 m_iteratingActiveDOMObjects = false;
213 } 216 }
214 217
215 void ScriptExecutionContext::stopActiveDOMObjects() 218 void ScriptExecutionContext::stopActiveDOMObjects()
216 { 219 {
220 m_activeDOMObjectsAreStopped = true;
217 // No protection against m_activeDOMObjects changing during iteration: stop( ) shouldn't execute arbitrary JS. 221 // No protection against m_activeDOMObjects changing during iteration: stop( ) shouldn't execute arbitrary JS.
218 m_iteratingActiveDOMObjects = true; 222 m_iteratingActiveDOMObjects = true;
219 HashMap<ActiveDOMObject*, void*>::iterator activeObjectsEnd = m_activeDOMObj ects.end(); 223 HashMap<ActiveDOMObject*, void*>::iterator activeObjectsEnd = m_activeDOMObj ects.end();
220 for (HashMap<ActiveDOMObject*, void*>::iterator iter = m_activeDOMObjects.be gin(); iter != activeObjectsEnd; ++iter) { 224 for (HashMap<ActiveDOMObject*, void*>::iterator iter = m_activeDOMObjects.be gin(); iter != activeObjectsEnd; ++iter) {
221 ASSERT(iter->first->scriptExecutionContext() == this); 225 ASSERT(iter->first->scriptExecutionContext() == this);
222 ASSERT(iter->first->suspendIfNeededCalled()); 226 ASSERT(iter->first->suspendIfNeededCalled());
223 iter->first->stop(); 227 iter->first->stop();
224 } 228 }
225 m_iteratingActiveDOMObjects = false; 229 m_iteratingActiveDOMObjects = false;
226 230
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 if (isWorkerContext()) 414 if (isWorkerContext())
411 return static_cast<WorkerContext*>(this)->script()->globalData(); 415 return static_cast<WorkerContext*>(this)->script()->globalData();
412 #endif 416 #endif
413 417
414 ASSERT_NOT_REACHED(); 418 ASSERT_NOT_REACHED();
415 return 0; 419 return 0;
416 } 420 }
417 #endif 421 #endif
418 422
419 } // namespace WebCore 423 } // namespace WebCore
OLDNEW
« no previous file with comments | « WebCore/dom/ScriptExecutionContext.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698