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

Unified Diff: third_party/WebKit/Source/core/workers/ThreadedWorkletGlobalScope.cpp

Issue 2254593002: [worklets] Introduce AnimationWorkletGlobalScope and ThreadedWorkletGlobalScope (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add super call to WorkletGlobalScope::dispose() Created 4 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 side-by-side diff with in-line comments
Download patch
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..d6c48b63e2f055315ecfa1bdb357cfd018e91eda
--- /dev/null
+++ b/third_party/WebKit/Source/core/workers/ThreadedWorkletGlobalScope.cpp
@@ -0,0 +1,63 @@
+// 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/workers/WorkerReportingProxy.h"
+#include "core/workers/WorkerThread.h"
+#include "platform/weborigin/KURL.h"
+#include "platform/weborigin/SecurityOrigin.h"
+#include "public/platform/Platform.h"
+#include "wtf/Assertions.h"
+#include "wtf/RefPtr.h"
+
+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()
+{
+ DCHECK(!m_thread);
+}
+
+void ThreadedWorkletGlobalScope::dispose()
+{
+ DCHECK(isContextThread());
+ m_thread = nullptr;
+
+ WorkletGlobalScope::dispose();
+}
+
+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

Powered by Google App Engine
This is Rietveld 408576698