Chromium Code Reviews| 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) 2009, 2011 Google Inc. All Rights Reserved. | 3 * Copyright (C) 2009, 2011 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 55 #include "core/workers/WorkerReportingProxy.h" | 55 #include "core/workers/WorkerReportingProxy.h" |
| 56 #include "core/workers/WorkerScriptLoader.h" | 56 #include "core/workers/WorkerScriptLoader.h" |
| 57 #include "core/workers/WorkerThread.h" | 57 #include "core/workers/WorkerThread.h" |
| 58 #include "platform/network/ContentSecurityPolicyParsers.h" | 58 #include "platform/network/ContentSecurityPolicyParsers.h" |
| 59 #include "platform/weborigin/KURL.h" | 59 #include "platform/weborigin/KURL.h" |
| 60 #include "platform/weborigin/SecurityOrigin.h" | 60 #include "platform/weborigin/SecurityOrigin.h" |
| 61 #include "public/platform/WebURLRequest.h" | 61 #include "public/platform/WebURLRequest.h" |
| 62 | 62 |
| 63 namespace blink { | 63 namespace blink { |
| 64 | 64 |
| 65 static unsigned long s_workerExceptionUniqueIdentifier = 0; | |
|
vsevik
2014/11/24 09:51:34
Let's put these into an anonymous namespace.
kozy
2014/12/01 13:11:55
Done.
| |
| 66 | |
| 67 unsigned long createWorkerExceptionUniqueIdentifier() | |
| 68 { | |
| 69 return ++s_workerExceptionUniqueIdentifier; | |
| 70 } | |
| 71 | |
| 65 class CloseWorkerGlobalScopeTask : public ExecutionContextTask { | 72 class CloseWorkerGlobalScopeTask : public ExecutionContextTask { |
| 66 public: | 73 public: |
| 67 static PassOwnPtr<CloseWorkerGlobalScopeTask> create() | 74 static PassOwnPtr<CloseWorkerGlobalScopeTask> create() |
| 68 { | 75 { |
| 69 return adoptPtr(new CloseWorkerGlobalScopeTask); | 76 return adoptPtr(new CloseWorkerGlobalScopeTask); |
| 70 } | 77 } |
| 71 | 78 |
| 72 virtual void performTask(ExecutionContext *context) | 79 virtual void performTask(ExecutionContext *context) |
| 73 { | 80 { |
| 74 WorkerGlobalScope* workerGlobalScope = toWorkerGlobalScope(context); | 81 WorkerGlobalScope* workerGlobalScope = toWorkerGlobalScope(context); |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 260 return; | 267 return; |
| 261 } | 268 } |
| 262 } | 269 } |
| 263 } | 270 } |
| 264 | 271 |
| 265 EventTarget* WorkerGlobalScope::errorEventTarget() | 272 EventTarget* WorkerGlobalScope::errorEventTarget() |
| 266 { | 273 { |
| 267 return this; | 274 return this; |
| 268 } | 275 } |
| 269 | 276 |
| 270 void WorkerGlobalScope::logExceptionToConsole(const String& errorMessage, int, c onst String& sourceURL, int lineNumber, int columnNumber, PassRefPtrWillBeRawPtr <ScriptCallStack>) | 277 void WorkerGlobalScope::logExceptionToConsole(const String& errorMessage, int, c onst String& sourceURL, int lineNumber, int columnNumber, PassRefPtrWillBeRawPtr <ScriptCallStack> callStack) |
| 271 { | 278 { |
| 272 thread()->workerReportingProxy().reportException(errorMessage, lineNumber, c olumnNumber, sourceURL); | 279 unsigned long exceptionId = createWorkerExceptionUniqueIdentifier(); |
| 280 RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = ConsoleMessage::create(J SMessageSource, ErrorMessageLevel, errorMessage, sourceURL, lineNumber); | |
| 281 consoleMessage->setCallStack(callStack); | |
| 282 m_pendingMessages.set(exceptionId, consoleMessage); | |
| 283 | |
| 284 thread()->workerReportingProxy().reportException(errorMessage, lineNumber, c olumnNumber, sourceURL, exceptionId); | |
| 273 } | 285 } |
| 274 | 286 |
| 275 void WorkerGlobalScope::reportBlockedScriptExecutionToInspector(const String& di rectiveText) | 287 void WorkerGlobalScope::reportBlockedScriptExecutionToInspector(const String& di rectiveText) |
| 276 { | 288 { |
| 277 InspectorInstrumentation::scriptExecutionBlockedByCSP(this, directiveText); | 289 InspectorInstrumentation::scriptExecutionBlockedByCSP(this, directiveText); |
| 278 } | 290 } |
| 279 | 291 |
| 280 void WorkerGlobalScope::addConsoleMessage(PassRefPtrWillBeRawPtr<ConsoleMessage> prpConsoleMessage) | 292 void WorkerGlobalScope::addConsoleMessage(PassRefPtrWillBeRawPtr<ConsoleMessage> prpConsoleMessage) |
| 281 { | 293 { |
| 282 RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = prpConsoleMessage; | 294 RefPtrWillBeRawPtr<ConsoleMessage> consoleMessage = prpConsoleMessage; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 322 void WorkerGlobalScope::countDeprecation(UseCounter::Feature) const | 334 void WorkerGlobalScope::countDeprecation(UseCounter::Feature) const |
| 323 { | 335 { |
| 324 // FIXME: How should we count features for shared/service workers? | 336 // FIXME: How should we count features for shared/service workers? |
| 325 } | 337 } |
| 326 | 338 |
| 327 ConsoleMessageStorage* WorkerGlobalScope::messageStorage() | 339 ConsoleMessageStorage* WorkerGlobalScope::messageStorage() |
| 328 { | 340 { |
| 329 return m_messageStorage.get(); | 341 return m_messageStorage.get(); |
| 330 } | 342 } |
| 331 | 343 |
| 344 void WorkerGlobalScope::exceptionHandled(int exceptionId, bool isHandled) | |
| 345 { | |
| 346 RefPtr<ConsoleMessage> consoleMessage = m_pendingMessages.take(exceptionId); | |
| 347 if (!isHandled) { | |
| 348 thread()->workerReportingProxy().reportConsoleMessage(consoleMessage); | |
| 349 addMessageToWorkerConsole(consoleMessage.release()); | |
| 350 } | |
| 351 } | |
| 352 | |
| 332 void WorkerGlobalScope::trace(Visitor* visitor) | 353 void WorkerGlobalScope::trace(Visitor* visitor) |
| 333 { | 354 { |
| 334 #if ENABLE(OILPAN) | 355 #if ENABLE(OILPAN) |
| 335 visitor->trace(m_console); | 356 visitor->trace(m_console); |
| 336 visitor->trace(m_location); | 357 visitor->trace(m_location); |
| 337 visitor->trace(m_navigator); | 358 visitor->trace(m_navigator); |
| 338 visitor->trace(m_workerInspectorController); | 359 visitor->trace(m_workerInspectorController); |
| 339 visitor->trace(m_eventQueue); | 360 visitor->trace(m_eventQueue); |
| 340 visitor->trace(m_workerClients); | 361 visitor->trace(m_workerClients); |
| 341 visitor->trace(m_messageStorage); | 362 visitor->trace(m_messageStorage); |
| 342 HeapSupplementable<WorkerGlobalScope>::trace(visitor); | 363 HeapSupplementable<WorkerGlobalScope>::trace(visitor); |
| 343 #endif | 364 #endif |
| 344 ExecutionContext::trace(visitor); | 365 ExecutionContext::trace(visitor); |
| 345 EventTargetWithInlineData::trace(visitor); | 366 EventTargetWithInlineData::trace(visitor); |
| 346 } | 367 } |
| 347 | 368 |
| 348 } // namespace blink | 369 } // namespace blink |
| OLD | NEW |