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

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

Issue 27311002: Introduce ExecutionContextClient (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix clang build error Created 7 years, 2 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/ExecutionContext.h ('k') | Source/core/dom/ExecutionContextClient.h » ('j') | 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 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 { 194 {
195 RefPtr<ErrorEvent> errorEvent = event; 195 RefPtr<ErrorEvent> errorEvent = event;
196 if (m_inDispatchErrorEvent) { 196 if (m_inDispatchErrorEvent) {
197 if (!m_pendingExceptions) 197 if (!m_pendingExceptions)
198 m_pendingExceptions = adoptPtr(new Vector<OwnPtr<PendingException> > ()); 198 m_pendingExceptions = adoptPtr(new Vector<OwnPtr<PendingException> > ());
199 m_pendingExceptions->append(adoptPtr(new PendingException(errorEvent->me ssageForConsole(), errorEvent->lineno(), errorEvent->colno(), errorEvent->filena me(), callStack))); 199 m_pendingExceptions->append(adoptPtr(new PendingException(errorEvent->me ssageForConsole(), errorEvent->lineno(), errorEvent->colno(), errorEvent->filena me(), callStack)));
200 return; 200 return;
201 } 201 }
202 202
203 // First report the original exception and only then all the nested ones. 203 // First report the original exception and only then all the nested ones.
204 if (!dispatchErrorEvent(errorEvent, corsStatus)) 204 if (!dispatchErrorEvent(errorEvent, corsStatus) && m_client)
205 logExceptionToConsole(errorEvent->messageForConsole(), errorEvent->filen ame(), errorEvent->lineno(), errorEvent->colno(), callStack); 205 m_client->logExceptionToConsole(errorEvent->messageForConsole(), errorEv ent->filename(), errorEvent->lineno(), errorEvent->colno(), callStack);
206 206
207 if (!m_pendingExceptions) 207 if (!m_pendingExceptions)
208 return; 208 return;
209 209
210 for (size_t i = 0; i < m_pendingExceptions->size(); i++) { 210 for (size_t i = 0; i < m_pendingExceptions->size(); i++) {
211 PendingException* e = m_pendingExceptions->at(i).get(); 211 PendingException* e = m_pendingExceptions->at(i).get();
212 logExceptionToConsole(e->m_errorMessage, e->m_sourceURL, e->m_lineNumber , e->m_columnNumber, e->m_callStack); 212 if (m_client)
213 m_client->logExceptionToConsole(e->m_errorMessage, e->m_sourceURL, e ->m_lineNumber, e->m_columnNumber, e->m_callStack);
213 } 214 }
214 m_pendingExceptions.clear(); 215 m_pendingExceptions.clear();
215 } 216 }
216 217
217 void ExecutionContext::addConsoleMessage(MessageSource source, MessageLevel leve l, const String& message, const String& sourceURL, unsigned lineNumber) 218 void ExecutionContext::addConsoleMessage(MessageSource source, MessageLevel leve l, const String& message, const String& sourceURL, unsigned lineNumber)
218 { 219 {
219 addMessage(source, level, message, sourceURL, lineNumber, 0); 220 if (!m_client)
221 return;
222 m_client->addMessage(source, level, message, sourceURL, lineNumber, 0);
220 } 223 }
221 224
222 void ExecutionContext::addConsoleMessage(MessageSource source, MessageLevel leve l, const String& message, ScriptState* state) 225 void ExecutionContext::addConsoleMessage(MessageSource source, MessageLevel leve l, const String& message, ScriptState* state)
223 { 226 {
224 addMessage(source, level, message, String(), 0, state); 227 if (!m_client)
228 return;
229 m_client->addMessage(source, level, message, String(), 0, state);
225 } 230 }
226 231
227 bool ExecutionContext::dispatchErrorEvent(PassRefPtr<ErrorEvent> event, AccessCo ntrolStatus corsStatus) 232 bool ExecutionContext::dispatchErrorEvent(PassRefPtr<ErrorEvent> event, AccessCo ntrolStatus corsStatus)
228 { 233 {
229 EventTarget* target = errorEventTarget(); 234 if (!m_client)
235 return false;
236 EventTarget* target = m_client->errorEventTarget();
230 if (!target) 237 if (!target)
231 return false; 238 return false;
232 239
233 RefPtr<ErrorEvent> errorEvent = event; 240 RefPtr<ErrorEvent> errorEvent = event;
234 if (shouldSanitizeScriptError(errorEvent->filename(), corsStatus)) 241 if (shouldSanitizeScriptError(errorEvent->filename(), corsStatus))
235 errorEvent = ErrorEvent::createSanitizedError(errorEvent->world()); 242 errorEvent = ErrorEvent::createSanitizedError(errorEvent->world());
236 243
237 ASSERT(!m_inDispatchErrorEvent); 244 ASSERT(!m_inDispatchErrorEvent);
238 m_inDispatchErrorEvent = true; 245 m_inDispatchErrorEvent = true;
239 target->dispatchEvent(errorEvent); 246 target->dispatchEvent(errorEvent);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 m_publicURLManager = PublicURLManager::create(this); 286 m_publicURLManager = PublicURLManager::create(this);
280 return *m_publicURLManager; 287 return *m_publicURLManager;
281 } 288 }
282 289
283 void ExecutionContext::didChangeTimerAlignmentInterval() 290 void ExecutionContext::didChangeTimerAlignmentInterval()
284 { 291 {
285 for (TimeoutMap::iterator iter = m_timeouts.begin(); iter != m_timeouts.end( ); ++iter) 292 for (TimeoutMap::iterator iter = m_timeouts.begin(); iter != m_timeouts.end( ); ++iter)
286 iter->value->didChangeAlignmentInterval(); 293 iter->value->didChangeAlignmentInterval();
287 } 294 }
288 295
296 EventQueue* ExecutionContext::eventQueue() const
297 {
298 if (!m_client)
299 return 0;
300 return m_client->eventQueue();
301 }
302
303 const KURL& ExecutionContext::url() const
304 {
305 if (!m_client) {
306 DEFINE_STATIC_LOCAL(KURL, emptyURL, ());
307 return emptyURL;
308 }
309
310 return m_client->virtualURL();
311 }
312
313 KURL ExecutionContext::completeURL(const String& url) const
314 {
315
316 if (!m_client) {
317 DEFINE_STATIC_LOCAL(KURL, emptyURL, ());
318 return emptyURL;
319 }
320
321 return m_client->virtualCompleteURL(url);
322 }
323
324 void ExecutionContext::userEventWasHandled()
325 {
326 if (!m_client)
327 return;
328 m_client->userEventWasHandled();
329 }
330
331 void ExecutionContext::disableEval(const String& errorMessage)
332 {
333 if (!m_client)
334 return;
335 return m_client->disableEval(errorMessage);
336 }
337
338 DOMWindow* ExecutionContext::executingWindow() const
339 {
340 if (!m_client)
341 return 0;
342 return m_client->executingWindow();
343 }
344
345 String ExecutionContext::userAgent(const KURL& url) const
346 {
347 if (!m_client)
348 return String();
349 return m_client->userAgent(url);
350 }
351
289 double ExecutionContext::timerAlignmentInterval() const 352 double ExecutionContext::timerAlignmentInterval() const
290 { 353 {
291 return DOMTimer::visiblePageAlignmentInterval(); 354 if (!m_client)
355 return DOMTimer::visiblePageAlignmentInterval();
356 return m_client->timerAlignmentInterval();
357 }
358
359 void ExecutionContext::postTask(PassOwnPtr<ExecutionContextTask> task)
360 {
361 if (!m_client)
362 return;
363 m_client->postTask(task);
364 }
365
366 PassOwnPtr<LifecycleNotifier> ExecutionContext::createLifecycleNotifier()
367 {
368 if (!m_client)
369 return PassOwnPtr<LifecycleNotifier>();
370 return m_client->createLifecycleNotifier();
292 } 371 }
293 372
294 ContextLifecycleNotifier* ExecutionContext::lifecycleNotifier() 373 ContextLifecycleNotifier* ExecutionContext::lifecycleNotifier()
295 { 374 {
296 return static_cast<ContextLifecycleNotifier*>(LifecycleContext::lifecycleNot ifier()); 375 return static_cast<ContextLifecycleNotifier*>(LifecycleContext::lifecycleNot ifier());
297 } 376 }
298 377
299 PassOwnPtr<LifecycleNotifier> ExecutionContext::createLifecycleNotifier()
300 {
301 return ContextLifecycleNotifier::create(this);
302 }
303
304 bool ExecutionContext::isIteratingOverObservers() const 378 bool ExecutionContext::isIteratingOverObservers() const
305 { 379 {
306 return m_lifecycleNotifier && m_lifecycleNotifier->isIteratingOverObservers( ); 380 return m_lifecycleNotifier && m_lifecycleNotifier->isIteratingOverObservers( );
307 } 381 }
308 382
309 void ExecutionContext::setDatabaseContext(DatabaseContext* databaseContext) 383 void ExecutionContext::setDatabaseContext(DatabaseContext* databaseContext)
310 { 384 {
311 m_databaseContext = databaseContext; 385 m_databaseContext = databaseContext;
312 } 386 }
313 387
314 } // namespace WebCore 388 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/dom/ExecutionContext.h ('k') | Source/core/dom/ExecutionContextClient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698