| 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 void ExecutionContext::stopActiveDOMObjects() | 85 void ExecutionContext::stopActiveDOMObjects() |
| 86 { | 86 { |
| 87 m_activeDOMObjectsAreStopped = true; | 87 m_activeDOMObjectsAreStopped = true; |
| 88 notifyStoppingActiveDOMObjects(); | 88 notifyStoppingActiveDOMObjects(); |
| 89 } | 89 } |
| 90 | 90 |
| 91 void ExecutionContext::postSuspendableTask(PassOwnPtr<SuspendableTask> task) | 91 void ExecutionContext::postSuspendableTask(PassOwnPtr<SuspendableTask> task) |
| 92 { | 92 { |
| 93 m_suspendedTasks.append(std::move(task)); | 93 m_suspendedTasks.append(std::move(task)); |
| 94 if (!m_activeDOMObjectsAreSuspended) | 94 if (!m_activeDOMObjectsAreSuspended) |
| 95 postTask(BLINK_FROM_HERE, createSameThreadTask(&ExecutionContext::runSus
pendableTasks, this)); | 95 postTask(BLINK_FROM_HERE, createSameThreadTask(&ExecutionContext::runSus
pendableTasks, wrapCrossThreadPersistent(this))); |
| 96 } | 96 } |
| 97 | 97 |
| 98 void ExecutionContext::notifyContextDestroyed() | 98 void ExecutionContext::notifyContextDestroyed() |
| 99 { | 99 { |
| 100 Deque<OwnPtr<SuspendableTask>> suspendedTasks; | 100 Deque<OwnPtr<SuspendableTask>> suspendedTasks; |
| 101 suspendedTasks.swap(m_suspendedTasks); | 101 suspendedTasks.swap(m_suspendedTasks); |
| 102 for (Deque<OwnPtr<SuspendableTask>>::iterator it = suspendedTasks.begin(); i
t != suspendedTasks.end(); ++it) | 102 for (Deque<OwnPtr<SuspendableTask>>::iterator it = suspendedTasks.begin(); i
t != suspendedTasks.end(); ++it) |
| 103 (*it)->contextDestroyed(); | 103 (*it)->contextDestroyed(); |
| 104 ContextLifecycleNotifier::notifyContextDestroyed(); | 104 ContextLifecycleNotifier::notifyContextDestroyed(); |
| 105 } | 105 } |
| 106 | 106 |
| 107 void ExecutionContext::suspendScheduledTasks() | 107 void ExecutionContext::suspendScheduledTasks() |
| 108 { | 108 { |
| 109 suspendActiveDOMObjects(); | 109 suspendActiveDOMObjects(); |
| 110 tasksWereSuspended(); | 110 tasksWereSuspended(); |
| 111 } | 111 } |
| 112 | 112 |
| 113 void ExecutionContext::resumeScheduledTasks() | 113 void ExecutionContext::resumeScheduledTasks() |
| 114 { | 114 { |
| 115 resumeActiveDOMObjects(); | 115 resumeActiveDOMObjects(); |
| 116 tasksWereResumed(); | 116 tasksWereResumed(); |
| 117 // We need finish stack unwiding before running next task because it can sus
pend this context. | 117 // We need finish stack unwiding before running next task because it can sus
pend this context. |
| 118 if (m_isRunSuspendableTasksScheduled) | 118 if (m_isRunSuspendableTasksScheduled) |
| 119 return; | 119 return; |
| 120 m_isRunSuspendableTasksScheduled = true; | 120 m_isRunSuspendableTasksScheduled = true; |
| 121 postTask(BLINK_FROM_HERE, createSameThreadTask(&ExecutionContext::runSuspend
ableTasks, this)); | 121 postTask(BLINK_FROM_HERE, createSameThreadTask(&ExecutionContext::runSuspend
ableTasks, wrapCrossThreadPersistent(this))); |
| 122 } | 122 } |
| 123 | 123 |
| 124 void ExecutionContext::suspendActiveDOMObjectIfNeeded(ActiveDOMObject* object) | 124 void ExecutionContext::suspendActiveDOMObjectIfNeeded(ActiveDOMObject* object) |
| 125 { | 125 { |
| 126 #if DCHECK_IS_ON() | 126 #if DCHECK_IS_ON() |
| 127 DCHECK(contains(object)); | 127 DCHECK(contains(object)); |
| 128 #endif | 128 #endif |
| 129 // Ensure all ActiveDOMObjects are suspended also newly created ones. | 129 // Ensure all ActiveDOMObjects are suspended also newly created ones. |
| 130 if (m_activeDOMObjectsAreSuspended) | 130 if (m_activeDOMObjectsAreSuspended) |
| 131 object->suspend(); | 131 object->suspend(); |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 } | 266 } |
| 267 | 267 |
| 268 DEFINE_TRACE(ExecutionContext) | 268 DEFINE_TRACE(ExecutionContext) |
| 269 { | 269 { |
| 270 visitor->trace(m_publicURLManager); | 270 visitor->trace(m_publicURLManager); |
| 271 ContextLifecycleNotifier::trace(visitor); | 271 ContextLifecycleNotifier::trace(visitor); |
| 272 Supplementable<ExecutionContext>::trace(visitor); | 272 Supplementable<ExecutionContext>::trace(visitor); |
| 273 } | 273 } |
| 274 | 274 |
| 275 } // namespace blink | 275 } // namespace blink |
| OLD | NEW |