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

Side by Side 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, 3 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
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "core/workers/ThreadedWorkletGlobalScope.h"
6
7 #include "core/inspector/ConsoleMessage.h"
8 #include "core/inspector/ConsoleMessageStorage.h"
9 #include "core/inspector/WorkerThreadDebugger.h"
10 #include "core/workers/WorkerReportingProxy.h"
11 #include "core/workers/WorkerThread.h"
12 #include "platform/weborigin/KURL.h"
13 #include "platform/weborigin/SecurityOrigin.h"
14 #include "public/platform/Platform.h"
15 #include "wtf/Assertions.h"
16 #include "wtf/RefPtr.h"
17
18 namespace blink {
19
20 ThreadedWorkletGlobalScope::ThreadedWorkletGlobalScope(const KURL& url, const St ring& userAgent, PassRefPtr<SecurityOrigin> securityOrigin, v8::Isolate* isolate , WorkerThread* thread)
21 : WorkletGlobalScope(url, userAgent, securityOrigin, isolate)
22 , m_thread(thread)
23 {
24 }
25
26 ThreadedWorkletGlobalScope::~ThreadedWorkletGlobalScope()
27 {
28 DCHECK(!m_thread);
29 }
30
31 void ThreadedWorkletGlobalScope::dispose()
32 {
33 DCHECK(isContextThread());
34 m_thread = nullptr;
35
36 WorkletGlobalScope::dispose();
37 }
38
39 bool ThreadedWorkletGlobalScope::isContextThread() const
40 {
41 return thread()->isCurrentThread();
42 }
43
44 void ThreadedWorkletGlobalScope::postTask(const WebTraceLocation& location, std: :unique_ptr<ExecutionContextTask> task, const String& taskNameForInstrumentation )
45 {
46 thread()->postTask(location, std::move(task), !taskNameForInstrumentation.is Empty());
47 }
48
49 void ThreadedWorkletGlobalScope::addConsoleMessage(ConsoleMessage* consoleMessag e)
50 {
51 DCHECK(isContextThread());
52 thread()->workerReportingProxy().reportConsoleMessage(consoleMessage->source (), consoleMessage->level(), consoleMessage->message(), consoleMessage->location ());
53 thread()->consoleMessageStorage()->addConsoleMessage(this, consoleMessage);
54 }
55
56 void ThreadedWorkletGlobalScope::exceptionThrown(ErrorEvent* errorEvent)
57 {
58 DCHECK(isContextThread());
59 if (WorkerThreadDebugger* debugger = WorkerThreadDebugger::from(thread()->is olate()))
60 debugger->exceptionThrown(errorEvent);
61 }
62
63 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698