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

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

Issue 2050123002: Remove OwnPtr from Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: First attempt to land. Created 4 years, 6 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 19 matching lines...) Expand all
30 #include "bindings/core/v8/SourceLocation.h" 30 #include "bindings/core/v8/SourceLocation.h"
31 #include "core/dom/ExecutionContextTask.h" 31 #include "core/dom/ExecutionContextTask.h"
32 #include "core/events/ErrorEvent.h" 32 #include "core/events/ErrorEvent.h"
33 #include "core/events/EventTarget.h" 33 #include "core/events/EventTarget.h"
34 #include "core/fetch/MemoryCache.h" 34 #include "core/fetch/MemoryCache.h"
35 #include "core/frame/UseCounter.h" 35 #include "core/frame/UseCounter.h"
36 #include "core/html/PublicURLManager.h" 36 #include "core/html/PublicURLManager.h"
37 #include "core/inspector/InspectorInstrumentation.h" 37 #include "core/inspector/InspectorInstrumentation.h"
38 #include "core/workers/WorkerGlobalScope.h" 38 #include "core/workers/WorkerGlobalScope.h"
39 #include "core/workers/WorkerThread.h" 39 #include "core/workers/WorkerThread.h"
40 #include "wtf/PtrUtil.h"
41 #include <memory>
40 42
41 namespace blink { 43 namespace blink {
42 44
43 class ExecutionContext::PendingException { 45 class ExecutionContext::PendingException {
44 WTF_MAKE_NONCOPYABLE(PendingException); 46 WTF_MAKE_NONCOPYABLE(PendingException);
45 public: 47 public:
46 PendingException(const String& errorMessage, PassOwnPtr<SourceLocation> loca tion) 48 PendingException(const String& errorMessage, std::unique_ptr<SourceLocation> location)
47 : m_errorMessage(errorMessage) 49 : m_errorMessage(errorMessage)
48 , m_location(std::move(location)) 50 , m_location(std::move(location))
49 { 51 {
50 } 52 }
51 53
52 String m_errorMessage; 54 String m_errorMessage;
53 OwnPtr<SourceLocation> m_location; 55 std::unique_ptr<SourceLocation> m_location;
54 }; 56 };
55 57
56 ExecutionContext::ExecutionContext() 58 ExecutionContext::ExecutionContext()
57 : m_circularSequentialID(0) 59 : m_circularSequentialID(0)
58 , m_inDispatchErrorEvent(false) 60 , m_inDispatchErrorEvent(false)
59 , m_activeDOMObjectsAreSuspended(false) 61 , m_activeDOMObjectsAreSuspended(false)
60 , m_activeDOMObjectsAreStopped(false) 62 , m_activeDOMObjectsAreStopped(false)
61 , m_windowInteractionTokens(0) 63 , m_windowInteractionTokens(0)
62 , m_isRunSuspendableTasksScheduled(false) 64 , m_isRunSuspendableTasksScheduled(false)
63 , m_referrerPolicy(ReferrerPolicyDefault) 65 , m_referrerPolicy(ReferrerPolicyDefault)
(...skipping 17 matching lines...) Expand all
81 m_activeDOMObjectsAreSuspended = false; 83 m_activeDOMObjectsAreSuspended = false;
82 notifyResumingActiveDOMObjects(); 84 notifyResumingActiveDOMObjects();
83 } 85 }
84 86
85 void ExecutionContext::stopActiveDOMObjects() 87 void ExecutionContext::stopActiveDOMObjects()
86 { 88 {
87 m_activeDOMObjectsAreStopped = true; 89 m_activeDOMObjectsAreStopped = true;
88 notifyStoppingActiveDOMObjects(); 90 notifyStoppingActiveDOMObjects();
89 } 91 }
90 92
91 void ExecutionContext::postSuspendableTask(PassOwnPtr<SuspendableTask> task) 93 void ExecutionContext::postSuspendableTask(std::unique_ptr<SuspendableTask> task )
92 { 94 {
93 m_suspendedTasks.append(std::move(task)); 95 m_suspendedTasks.append(std::move(task));
94 if (!m_activeDOMObjectsAreSuspended) 96 if (!m_activeDOMObjectsAreSuspended)
95 postTask(BLINK_FROM_HERE, createSameThreadTask(&ExecutionContext::runSus pendableTasks, this)); 97 postTask(BLINK_FROM_HERE, createSameThreadTask(&ExecutionContext::runSus pendableTasks, this));
96 } 98 }
97 99
98 void ExecutionContext::notifyContextDestroyed() 100 void ExecutionContext::notifyContextDestroyed()
99 { 101 {
100 Deque<OwnPtr<SuspendableTask>> suspendedTasks; 102 Deque<std::unique_ptr<SuspendableTask>> suspendedTasks;
101 suspendedTasks.swap(m_suspendedTasks); 103 suspendedTasks.swap(m_suspendedTasks);
102 for (Deque<OwnPtr<SuspendableTask>>::iterator it = suspendedTasks.begin(); i t != suspendedTasks.end(); ++it) 104 for (Deque<std::unique_ptr<SuspendableTask>>::iterator it = suspendedTasks.b egin(); it != suspendedTasks.end(); ++it)
103 (*it)->contextDestroyed(); 105 (*it)->contextDestroyed();
104 ContextLifecycleNotifier::notifyContextDestroyed(); 106 ContextLifecycleNotifier::notifyContextDestroyed();
105 } 107 }
106 108
107 void ExecutionContext::suspendScheduledTasks() 109 void ExecutionContext::suspendScheduledTasks()
108 { 110 {
109 suspendActiveDOMObjects(); 111 suspendActiveDOMObjects();
110 tasksWereSuspended(); 112 tasksWereSuspended();
111 } 113 }
112 114
(...skipping 22 matching lines...) Expand all
135 { 137 {
136 if (corsStatus == OpaqueResource) 138 if (corsStatus == OpaqueResource)
137 return true; 139 return true;
138 return !(getSecurityOrigin()->canRequestNoSuborigin(completeURL(sourceURL)) || corsStatus == SharableCrossOrigin); 140 return !(getSecurityOrigin()->canRequestNoSuborigin(completeURL(sourceURL)) || corsStatus == SharableCrossOrigin);
139 } 141 }
140 142
141 void ExecutionContext::reportException(ErrorEvent* errorEvent, AccessControlStat us corsStatus) 143 void ExecutionContext::reportException(ErrorEvent* errorEvent, AccessControlStat us corsStatus)
142 { 144 {
143 if (m_inDispatchErrorEvent) { 145 if (m_inDispatchErrorEvent) {
144 if (!m_pendingExceptions) 146 if (!m_pendingExceptions)
145 m_pendingExceptions = adoptPtr(new Vector<OwnPtr<PendingException>>( )); 147 m_pendingExceptions = wrapUnique(new Vector<std::unique_ptr<PendingE xception>>());
146 m_pendingExceptions->append(adoptPtr(new PendingException(errorEvent->me ssageForConsole(), errorEvent->location()->clone()))); 148 m_pendingExceptions->append(wrapUnique(new PendingException(errorEvent-> messageForConsole(), errorEvent->location()->clone())));
147 return; 149 return;
148 } 150 }
149 151
150 // First report the original exception and only then all the nested ones. 152 // First report the original exception and only then all the nested ones.
151 if (!dispatchErrorEvent(errorEvent, corsStatus)) 153 if (!dispatchErrorEvent(errorEvent, corsStatus))
152 logExceptionToConsole(errorEvent->messageForConsole(), errorEvent->locat ion()->clone()); 154 logExceptionToConsole(errorEvent->messageForConsole(), errorEvent->locat ion()->clone());
153 155
154 if (!m_pendingExceptions) 156 if (!m_pendingExceptions)
155 return; 157 return;
156 158
(...skipping 17 matching lines...) Expand all
174 m_inDispatchErrorEvent = true; 176 m_inDispatchErrorEvent = true;
175 target->dispatchEvent(errorEvent); 177 target->dispatchEvent(errorEvent);
176 m_inDispatchErrorEvent = false; 178 m_inDispatchErrorEvent = false;
177 return errorEvent->defaultPrevented(); 179 return errorEvent->defaultPrevented();
178 } 180 }
179 181
180 void ExecutionContext::runSuspendableTasks() 182 void ExecutionContext::runSuspendableTasks()
181 { 183 {
182 m_isRunSuspendableTasksScheduled = false; 184 m_isRunSuspendableTasksScheduled = false;
183 while (!m_activeDOMObjectsAreSuspended && m_suspendedTasks.size()) { 185 while (!m_activeDOMObjectsAreSuspended && m_suspendedTasks.size()) {
184 OwnPtr<SuspendableTask> task = m_suspendedTasks.takeFirst(); 186 std::unique_ptr<SuspendableTask> task = m_suspendedTasks.takeFirst();
185 task->run(); 187 task->run();
186 } 188 }
187 } 189 }
188 190
189 int ExecutionContext::circularSequentialID() 191 int ExecutionContext::circularSequentialID()
190 { 192 {
191 ++m_circularSequentialID; 193 ++m_circularSequentialID;
192 if (m_circularSequentialID > ((1U << 31) - 1U)) 194 if (m_circularSequentialID > ((1U << 31) - 1U))
193 m_circularSequentialID = 1; 195 m_circularSequentialID = 1;
194 196
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 } 268 }
267 269
268 DEFINE_TRACE(ExecutionContext) 270 DEFINE_TRACE(ExecutionContext)
269 { 271 {
270 visitor->trace(m_publicURLManager); 272 visitor->trace(m_publicURLManager);
271 ContextLifecycleNotifier::trace(visitor); 273 ContextLifecycleNotifier::trace(visitor);
272 Supplementable<ExecutionContext>::trace(visitor); 274 Supplementable<ExecutionContext>::trace(visitor);
273 } 275 }
274 276
275 } // namespace blink 277 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/ExecutionContext.h ('k') | third_party/WebKit/Source/core/dom/ExecutionContextTask.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698