OLD | NEW |
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 * Copyright (C) 2012 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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 { | 130 { |
131 ASSERT(port); | 131 ASSERT(port); |
132 ASSERT((isDocument() && isMainThread()) | 132 ASSERT((isDocument() && isMainThread()) |
133 || (isWorkerGlobalScope() && toWorkerGlobalScope(this)->thread()->isCurr
entThread())); | 133 || (isWorkerGlobalScope() && toWorkerGlobalScope(this)->thread()->isCurr
entThread())); |
134 | 134 |
135 m_messagePorts.remove(port); | 135 m_messagePorts.remove(port); |
136 } | 136 } |
137 | 137 |
138 bool ExecutionContext::hasPendingActivity() | 138 bool ExecutionContext::hasPendingActivity() |
139 { | 139 { |
140 if (lifecycleNotifier()->hasPendingActivity()) | 140 if (lifecycleNotifier().hasPendingActivity()) |
141 return true; | 141 return true; |
142 | 142 |
143 HashSet<MessagePort*>::const_iterator messagePortsEnd = m_messagePorts.end()
; | 143 HashSet<MessagePort*>::const_iterator messagePortsEnd = m_messagePorts.end()
; |
144 for (HashSet<MessagePort*>::const_iterator iter = m_messagePorts.begin(); it
er != messagePortsEnd; ++iter) { | 144 for (HashSet<MessagePort*>::const_iterator iter = m_messagePorts.begin(); it
er != messagePortsEnd; ++iter) { |
145 if ((*iter)->hasPendingActivity()) | 145 if ((*iter)->hasPendingActivity()) |
146 return true; | 146 return true; |
147 } | 147 } |
148 | 148 |
149 return false; | 149 return false; |
150 } | 150 } |
151 | 151 |
152 void ExecutionContext::suspendActiveDOMObjects() | 152 void ExecutionContext::suspendActiveDOMObjects() |
153 { | 153 { |
154 lifecycleNotifier()->notifySuspendingActiveDOMObjects(); | 154 lifecycleNotifier().notifySuspendingActiveDOMObjects(); |
155 m_activeDOMObjectsAreSuspended = true; | 155 m_activeDOMObjectsAreSuspended = true; |
156 } | 156 } |
157 | 157 |
158 void ExecutionContext::resumeActiveDOMObjects() | 158 void ExecutionContext::resumeActiveDOMObjects() |
159 { | 159 { |
160 m_activeDOMObjectsAreSuspended = false; | 160 m_activeDOMObjectsAreSuspended = false; |
161 lifecycleNotifier()->notifyResumingActiveDOMObjects(); | 161 lifecycleNotifier().notifyResumingActiveDOMObjects(); |
162 } | 162 } |
163 | 163 |
164 void ExecutionContext::stopActiveDOMObjects() | 164 void ExecutionContext::stopActiveDOMObjects() |
165 { | 165 { |
166 m_activeDOMObjectsAreStopped = true; | 166 m_activeDOMObjectsAreStopped = true; |
167 lifecycleNotifier()->notifyStoppingActiveDOMObjects(); | 167 lifecycleNotifier().notifyStoppingActiveDOMObjects(); |
168 // Also close MessagePorts. If they were ActiveDOMObjects (they could be) th
en they could be stopped instead. | 168 // Also close MessagePorts. If they were ActiveDOMObjects (they could be) th
en they could be stopped instead. |
169 closeMessagePorts(); | 169 closeMessagePorts(); |
170 } | 170 } |
171 | 171 |
172 void ExecutionContext::suspendActiveDOMObjectIfNeeded(ActiveDOMObject* object) | 172 void ExecutionContext::suspendActiveDOMObjectIfNeeded(ActiveDOMObject* object) |
173 { | 173 { |
174 ASSERT(lifecycleNotifier()->contains(object)); | 174 ASSERT(lifecycleNotifier().contains(object)); |
175 // Ensure all ActiveDOMObjects are suspended also newly created ones. | 175 // Ensure all ActiveDOMObjects are suspended also newly created ones. |
176 if (m_activeDOMObjectsAreSuspended) | 176 if (m_activeDOMObjectsAreSuspended) |
177 object->suspend(); | 177 object->suspend(); |
178 } | 178 } |
179 | 179 |
180 void ExecutionContext::closeMessagePorts() | 180 void ExecutionContext::closeMessagePorts() |
181 { | 181 { |
182 HashSet<MessagePort*>::iterator messagePortsEnd = m_messagePorts.end(); | 182 HashSet<MessagePort*>::iterator messagePortsEnd = m_messagePorts.end(); |
183 for (HashSet<MessagePort*>::iterator iter = m_messagePorts.begin(); iter !=
messagePortsEnd; ++iter) { | 183 for (HashSet<MessagePort*>::iterator iter = m_messagePorts.begin(); iter !=
messagePortsEnd; ++iter) { |
184 ASSERT((*iter)->executionContext() == this); | 184 ASSERT((*iter)->executionContext() == this); |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 return; | 373 return; |
374 m_client->postTask(task); | 374 m_client->postTask(task); |
375 } | 375 } |
376 | 376 |
377 PassOwnPtr<LifecycleNotifier<ExecutionContext> > ExecutionContext::createLifecyc
leNotifier() | 377 PassOwnPtr<LifecycleNotifier<ExecutionContext> > ExecutionContext::createLifecyc
leNotifier() |
378 { | 378 { |
379 RELEASE_ASSERT(m_client); | 379 RELEASE_ASSERT(m_client); |
380 return m_client->createLifecycleNotifier(); | 380 return m_client->createLifecycleNotifier(); |
381 } | 381 } |
382 | 382 |
383 ContextLifecycleNotifier* ExecutionContext::lifecycleNotifier() | 383 ContextLifecycleNotifier& ExecutionContext::lifecycleNotifier() |
384 { | 384 { |
385 return static_cast<ContextLifecycleNotifier*>(LifecycleContext<ExecutionCont
ext>::lifecycleNotifier()); | 385 return static_cast<ContextLifecycleNotifier&>(LifecycleContext<ExecutionCont
ext>::lifecycleNotifier()); |
386 } | 386 } |
387 | 387 |
388 bool ExecutionContext::isIteratingOverObservers() const | 388 bool ExecutionContext::isIteratingOverObservers() const |
389 { | 389 { |
390 return m_lifecycleNotifier && m_lifecycleNotifier->isIteratingOverObservers(
); | 390 return m_lifecycleNotifier && m_lifecycleNotifier->isIteratingOverObservers(
); |
391 } | 391 } |
392 | 392 |
393 void ExecutionContext::enforceSandboxFlags(SandboxFlags mask) | 393 void ExecutionContext::enforceSandboxFlags(SandboxFlags mask) |
394 { | 394 { |
395 m_sandboxFlags |= mask; | 395 m_sandboxFlags |= mask; |
396 | 396 |
397 RELEASE_ASSERT(m_client); | 397 RELEASE_ASSERT(m_client); |
398 // The SandboxOrigin is stored redundantly in the security origin. | 398 // The SandboxOrigin is stored redundantly in the security origin. |
399 if (isSandboxed(SandboxOrigin) && m_client->securityContext().securityOrigin
() && !m_client->securityContext().securityOrigin()->isUnique()) { | 399 if (isSandboxed(SandboxOrigin) && m_client->securityContext().securityOrigin
() && !m_client->securityContext().securityOrigin()->isUnique()) { |
400 m_client->securityContext().setSecurityOrigin(SecurityOrigin::createUniq
ue()); | 400 m_client->securityContext().setSecurityOrigin(SecurityOrigin::createUniq
ue()); |
401 m_client->didUpdateSecurityOrigin(); | 401 m_client->didUpdateSecurityOrigin(); |
402 } | 402 } |
403 } | 403 } |
404 | 404 |
405 } // namespace WebCore | 405 } // namespace WebCore |
OLD | NEW |