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

Side by Side Diff: third_party/WebKit/Source/core/dom/ExecutionContext.cpp

Issue 1916283003: [K6] Replace bind() + GCed pointers with retainedRef() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Kuroneko_5c
Patch Set: Rebase Created 4 years, 7 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
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 * 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 void ExecutionContext::stopActiveDOMObjects() 93 void ExecutionContext::stopActiveDOMObjects()
94 { 94 {
95 m_activeDOMObjectsAreStopped = true; 95 m_activeDOMObjectsAreStopped = true;
96 notifyStoppingActiveDOMObjects(); 96 notifyStoppingActiveDOMObjects();
97 } 97 }
98 98
99 void ExecutionContext::postSuspendableTask(PassOwnPtr<SuspendableTask> task) 99 void ExecutionContext::postSuspendableTask(PassOwnPtr<SuspendableTask> task)
100 { 100 {
101 m_suspendedTasks.append(std::move(task)); 101 m_suspendedTasks.append(std::move(task));
102 if (!m_activeDOMObjectsAreSuspended) 102 if (!m_activeDOMObjectsAreSuspended)
103 postTask(BLINK_FROM_HERE, createSameThreadTask(&ExecutionContext::runSus pendableTasks, this)); 103 postTask(BLINK_FROM_HERE, createSameThreadTask(&ExecutionContext::runSus pendableTasks, retainedRef(this)));
104 } 104 }
105 105
106 void ExecutionContext::notifyContextDestroyed() 106 void ExecutionContext::notifyContextDestroyed()
107 { 107 {
108 Deque<OwnPtr<SuspendableTask>> suspendedTasks; 108 Deque<OwnPtr<SuspendableTask>> suspendedTasks;
109 suspendedTasks.swap(m_suspendedTasks); 109 suspendedTasks.swap(m_suspendedTasks);
110 for (Deque<OwnPtr<SuspendableTask>>::iterator it = suspendedTasks.begin(); i t != suspendedTasks.end(); ++it) 110 for (Deque<OwnPtr<SuspendableTask>>::iterator it = suspendedTasks.begin(); i t != suspendedTasks.end(); ++it)
111 (*it)->contextDestroyed(); 111 (*it)->contextDestroyed();
112 ContextLifecycleNotifier::notifyContextDestroyed(); 112 ContextLifecycleNotifier::notifyContextDestroyed();
113 } 113 }
114 114
115 void ExecutionContext::suspendScheduledTasks() 115 void ExecutionContext::suspendScheduledTasks()
116 { 116 {
117 suspendActiveDOMObjects(); 117 suspendActiveDOMObjects();
118 tasksWereSuspended(); 118 tasksWereSuspended();
119 } 119 }
120 120
121 void ExecutionContext::resumeScheduledTasks() 121 void ExecutionContext::resumeScheduledTasks()
122 { 122 {
123 resumeActiveDOMObjects(); 123 resumeActiveDOMObjects();
124 tasksWereResumed(); 124 tasksWereResumed();
125 // We need finish stack unwiding before running next task because it can sus pend this context. 125 // We need finish stack unwiding before running next task because it can sus pend this context.
126 if (m_isRunSuspendableTasksScheduled) 126 if (m_isRunSuspendableTasksScheduled)
127 return; 127 return;
128 m_isRunSuspendableTasksScheduled = true; 128 m_isRunSuspendableTasksScheduled = true;
129 postTask(BLINK_FROM_HERE, createSameThreadTask(&ExecutionContext::runSuspend ableTasks, this)); 129 postTask(BLINK_FROM_HERE, createSameThreadTask(&ExecutionContext::runSuspend ableTasks, retainedRef(this)));
130 } 130 }
131 131
132 void ExecutionContext::suspendActiveDOMObjectIfNeeded(ActiveDOMObject* object) 132 void ExecutionContext::suspendActiveDOMObjectIfNeeded(ActiveDOMObject* object)
133 { 133 {
134 #if DCHECK_IS_ON() 134 #if DCHECK_IS_ON()
135 DCHECK(contains(object)); 135 DCHECK(contains(object));
136 #endif 136 #endif
137 // Ensure all ActiveDOMObjects are suspended also newly created ones. 137 // Ensure all ActiveDOMObjects are suspended also newly created ones.
138 if (m_activeDOMObjectsAreSuspended) 138 if (m_activeDOMObjectsAreSuspended)
139 object->suspend(); 139 object->suspend();
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 } 274 }
275 275
276 DEFINE_TRACE(ExecutionContext) 276 DEFINE_TRACE(ExecutionContext)
277 { 277 {
278 visitor->trace(m_publicURLManager); 278 visitor->trace(m_publicURLManager);
279 ContextLifecycleNotifier::trace(visitor); 279 ContextLifecycleNotifier::trace(visitor);
280 Supplementable<ExecutionContext>::trace(visitor); 280 Supplementable<ExecutionContext>::trace(visitor);
281 } 281 }
282 282
283 } // namespace blink 283 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/bindings/core/v8/V8ScriptRunner.cpp ('k') | third_party/WebKit/Source/core/dom/Node.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698