Index: third_party/WebKit/Source/core/workers/ThreadedWorkletGlobalScope.cpp |
diff --git a/third_party/WebKit/Source/core/workers/ThreadedWorkletGlobalScope.cpp b/third_party/WebKit/Source/core/workers/ThreadedWorkletGlobalScope.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..a647f38383af00bf37b7ade29f173aa15343ff82 |
--- /dev/null |
+++ b/third_party/WebKit/Source/core/workers/ThreadedWorkletGlobalScope.cpp |
@@ -0,0 +1,68 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "core/workers/ThreadedWorkletGlobalScope.h" |
+ |
+#include "core/inspector/ConsoleMessage.h" |
+#include "core/inspector/ConsoleMessageStorage.h" |
+#include "core/inspector/WorkerThreadDebugger.h" |
+#include "core/loader/WorkerThreadableLoader.h" |
+#include "core/workers/WorkerLoaderProxy.h" |
+#include "core/workers/WorkerReportingProxy.h" |
+#include "core/workers/WorkerScriptLoader.h" |
+#include "core/workers/WorkerThread.h" |
+#include "platform/network/ContentSecurityPolicyParsers.h" |
+#include "platform/weborigin/KURL.h" |
+#include "platform/weborigin/SecurityOrigin.h" |
+#include "public/platform/Platform.h" |
+#include "public/platform/WebScheduler.h" |
+#include "public/platform/WebURLRequest.h" |
+#include "wtf/Assertions.h" |
+#include "wtf/RefPtr.h" |
nhiroki
2016/08/17 05:56:57
Following inclusions might not be necessary.
"cor
ikilpatrick
2016/08/22 19:07:32
Done.
|
+ |
+namespace blink { |
+ |
+ThreadedWorkletGlobalScope::ThreadedWorkletGlobalScope(const KURL& url, const String& userAgent, PassRefPtr<SecurityOrigin> securityOrigin, v8::Isolate* isolate, WorkerThread* thread) |
+ : WorkletGlobalScope(url, userAgent, securityOrigin, isolate) |
+ , m_thread(thread) |
+{ |
+} |
+ |
+ThreadedWorkletGlobalScope::~ThreadedWorkletGlobalScope() |
+{ |
haraken
2016/08/17 06:07:25
Shall we add DCHECK(!m_thread) ?
ikilpatrick
2016/08/22 19:07:32
Done.
|
+} |
+ |
+void ThreadedWorkletGlobalScope::dispose() |
+{ |
+ DCHECK(isContextThread()); |
+ stopActiveDOMObjects(); |
+ |
+ m_thread = nullptr; |
+} |
+ |
+bool ThreadedWorkletGlobalScope::isContextThread() const |
+{ |
+ return thread()->isCurrentThread(); |
+} |
+ |
+void ThreadedWorkletGlobalScope::postTask(const WebTraceLocation& location, std::unique_ptr<ExecutionContextTask> task, const String& taskNameForInstrumentation) |
+{ |
+ thread()->postTask(location, std::move(task), !taskNameForInstrumentation.isEmpty()); |
+} |
+ |
+void ThreadedWorkletGlobalScope::addConsoleMessage(ConsoleMessage* consoleMessage) |
+{ |
+ DCHECK(isContextThread()); |
+ thread()->workerReportingProxy().reportConsoleMessage(consoleMessage->source(), consoleMessage->level(), consoleMessage->message(), consoleMessage->location()); |
+ thread()->consoleMessageStorage()->addConsoleMessage(this, consoleMessage); |
+} |
+ |
+void ThreadedWorkletGlobalScope::exceptionThrown(ErrorEvent* errorEvent) |
+{ |
+ DCHECK(isContextThread()); |
+ if (WorkerThreadDebugger* debugger = WorkerThreadDebugger::from(thread()->isolate())) |
+ debugger->exceptionThrown(errorEvent); |
+} |
+ |
+} // namespace blink |