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

Side by Side Diff: Source/core/dom/ScriptExecutionContext.cpp

Issue 20883003: Drop CachedScript from ScriptExecutionContext. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/dom/ScriptExecutionContext.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 17 matching lines...) Expand all
28 #include "config.h" 28 #include "config.h"
29 #include "core/dom/ScriptExecutionContext.h" 29 #include "core/dom/ScriptExecutionContext.h"
30 30
31 #include "core/dom/ContextLifecycleNotifier.h" 31 #include "core/dom/ContextLifecycleNotifier.h"
32 #include "core/dom/ErrorEvent.h" 32 #include "core/dom/ErrorEvent.h"
33 #include "core/dom/EventTarget.h" 33 #include "core/dom/EventTarget.h"
34 #include "core/dom/MessagePort.h" 34 #include "core/dom/MessagePort.h"
35 #include "core/html/PublicURLManager.h" 35 #include "core/html/PublicURLManager.h"
36 #include "core/inspector/InspectorInstrumentation.h" 36 #include "core/inspector/InspectorInstrumentation.h"
37 #include "core/inspector/ScriptCallStack.h" 37 #include "core/inspector/ScriptCallStack.h"
38 #include "core/loader/cache/CachedScript.h"
39 #include "core/page/DOMTimer.h" 38 #include "core/page/DOMTimer.h"
40 #include "core/workers/WorkerGlobalScope.h" 39 #include "core/workers/WorkerGlobalScope.h"
41 #include "core/workers/WorkerThread.h" 40 #include "core/workers/WorkerThread.h"
42 #include "modules/webdatabase/DatabaseContext.h" 41 #include "modules/webdatabase/DatabaseContext.h"
43 #include "wtf/MainThread.h" 42 #include "wtf/MainThread.h"
44 43
45 namespace WebCore { 44 namespace WebCore {
46 45
47 class ProcessMessagesSoonTask : public ScriptExecutionContext::Task { 46 class ProcessMessagesSoonTask : public ScriptExecutionContext::Task {
48 public: 47 public:
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 } 187 }
189 188
190 void ScriptExecutionContext::closeMessagePorts() { 189 void ScriptExecutionContext::closeMessagePorts() {
191 HashSet<MessagePort*>::iterator messagePortsEnd = m_messagePorts.end(); 190 HashSet<MessagePort*>::iterator messagePortsEnd = m_messagePorts.end();
192 for (HashSet<MessagePort*>::iterator iter = m_messagePorts.begin(); iter != messagePortsEnd; ++iter) { 191 for (HashSet<MessagePort*>::iterator iter = m_messagePorts.begin(); iter != messagePortsEnd; ++iter) {
193 ASSERT((*iter)->scriptExecutionContext() == this); 192 ASSERT((*iter)->scriptExecutionContext() == this);
194 (*iter)->close(); 193 (*iter)->close();
195 } 194 }
196 } 195 }
197 196
198 bool ScriptExecutionContext::sanitizeScriptError(String& errorMessage, int& line Number, int& columnNumber, String& sourceURL, CachedScript* cachedScript) 197 bool ScriptExecutionContext::sanitizeScriptError(String& errorMessage, int& line Number, int& columnNumber, String& sourceURL)
199 { 198 {
200 KURL targetURL = completeURL(sourceURL); 199 KURL targetURL = completeURL(sourceURL);
201 if (securityOrigin()->canRequest(targetURL) || (cachedScript && cachedScript ->passesAccessControlCheck(securityOrigin()))) 200 if (securityOrigin()->canRequest(targetURL))
202 return false; 201 return false;
203 errorMessage = "Script error."; 202 errorMessage = "Script error.";
204 sourceURL = String(); 203 sourceURL = String();
205 lineNumber = 0; 204 lineNumber = 0;
206 columnNumber = 0; 205 columnNumber = 0;
207 return true; 206 return true;
208 } 207 }
209 208
210 void ScriptExecutionContext::reportException(const String& errorMessage, int lin eNumber, int columnNumber, const String& sourceURL, PassRefPtr<ScriptCallStack> callStack, CachedScript* cachedScript) 209 void ScriptExecutionContext::reportException(const String& errorMessage, int lin eNumber, int columnNumber, const String& sourceURL, PassRefPtr<ScriptCallStack> callStack)
211 { 210 {
212 if (m_inDispatchErrorEvent) { 211 if (m_inDispatchErrorEvent) {
213 if (!m_pendingExceptions) 212 if (!m_pendingExceptions)
214 m_pendingExceptions = adoptPtr(new Vector<OwnPtr<PendingException> > ()); 213 m_pendingExceptions = adoptPtr(new Vector<OwnPtr<PendingException> > ());
215 m_pendingExceptions->append(adoptPtr(new PendingException(errorMessage, lineNumber, columnNumber, sourceURL, callStack))); 214 m_pendingExceptions->append(adoptPtr(new PendingException(errorMessage, lineNumber, columnNumber, sourceURL, callStack)));
216 return; 215 return;
217 } 216 }
218 217
219 // First report the original exception and only then all the nested ones. 218 // First report the original exception and only then all the nested ones.
220 if (!dispatchErrorEvent(errorMessage, lineNumber, columnNumber, sourceURL, c achedScript)) 219 if (!dispatchErrorEvent(errorMessage, lineNumber, columnNumber, sourceURL))
221 logExceptionToConsole(errorMessage, sourceURL, lineNumber, columnNumber, callStack); 220 logExceptionToConsole(errorMessage, sourceURL, lineNumber, columnNumber, callStack);
222 221
223 if (!m_pendingExceptions) 222 if (!m_pendingExceptions)
224 return; 223 return;
225 224
226 for (size_t i = 0; i < m_pendingExceptions->size(); i++) { 225 for (size_t i = 0; i < m_pendingExceptions->size(); i++) {
227 PendingException* e = m_pendingExceptions->at(i).get(); 226 PendingException* e = m_pendingExceptions->at(i).get();
228 logExceptionToConsole(e->m_errorMessage, e->m_sourceURL, e->m_lineNumber , e->m_columnNumber, e->m_callStack); 227 logExceptionToConsole(e->m_errorMessage, e->m_sourceURL, e->m_lineNumber , e->m_columnNumber, e->m_callStack);
229 } 228 }
230 m_pendingExceptions.clear(); 229 m_pendingExceptions.clear();
231 } 230 }
232 231
233 void ScriptExecutionContext::addConsoleMessage(MessageSource source, MessageLeve l level, const String& message, const String& sourceURL, unsigned lineNumber, Sc riptState* state, unsigned long requestIdentifier) 232 void ScriptExecutionContext::addConsoleMessage(MessageSource source, MessageLeve l level, const String& message, const String& sourceURL, unsigned lineNumber, Sc riptState* state, unsigned long requestIdentifier)
234 { 233 {
235 addMessage(source, level, message, sourceURL, lineNumber, 0, state, requestI dentifier); 234 addMessage(source, level, message, sourceURL, lineNumber, 0, state, requestI dentifier);
236 } 235 }
237 236
238 bool ScriptExecutionContext::dispatchErrorEvent(const String& errorMessage, int lineNumber, int columnNumber, const String& sourceURL, CachedScript* cachedScrip t) 237 bool ScriptExecutionContext::dispatchErrorEvent(const String& errorMessage, int lineNumber, int columnNumber, const String& sourceURL)
239 { 238 {
240 EventTarget* target = errorEventTarget(); 239 EventTarget* target = errorEventTarget();
241 if (!target) 240 if (!target)
242 return false; 241 return false;
243 242
244 String message = errorMessage; 243 String message = errorMessage;
245 int line = lineNumber; 244 int line = lineNumber;
246 int column = columnNumber; 245 int column = columnNumber;
247 String sourceName = sourceURL; 246 String sourceName = sourceURL;
248 sanitizeScriptError(message, line, column, sourceName, cachedScript); 247 sanitizeScriptError(message, line, column, sourceName);
249 248
250 ASSERT(!m_inDispatchErrorEvent); 249 ASSERT(!m_inDispatchErrorEvent);
251 m_inDispatchErrorEvent = true; 250 m_inDispatchErrorEvent = true;
252 RefPtr<ErrorEvent> errorEvent = ErrorEvent::create(message, sourceName, line , column); 251 RefPtr<ErrorEvent> errorEvent = ErrorEvent::create(message, sourceName, line , column);
253 target->dispatchEvent(errorEvent); 252 target->dispatchEvent(errorEvent);
254 m_inDispatchErrorEvent = false; 253 m_inDispatchErrorEvent = false;
255 return errorEvent->defaultPrevented(); 254 return errorEvent->defaultPrevented();
256 } 255 }
257 256
258 int ScriptExecutionContext::circularSequentialID() 257 int ScriptExecutionContext::circularSequentialID()
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 ScriptExecutionContext::Task::~Task() 317 ScriptExecutionContext::Task::~Task()
319 { 318 {
320 } 319 }
321 320
322 void ScriptExecutionContext::setDatabaseContext(DatabaseContext* databaseContext ) 321 void ScriptExecutionContext::setDatabaseContext(DatabaseContext* databaseContext )
323 { 322 {
324 m_databaseContext = databaseContext; 323 m_databaseContext = databaseContext;
325 } 324 }
326 325
327 } // namespace WebCore 326 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/dom/ScriptExecutionContext.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698