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