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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/ModuleProxy.h

Issue 1535943005: Initial implementation of bindings and basic classes for worklets. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address (most) comments. Created 4 years, 11 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 #ifndef ModuleProxy_h
6 #define ModuleProxy_h
7
8 #include "core/CoreExport.h"
9 #include "wtf/Allocator.h"
10 #include "wtf/StdLibExtras.h"
11 #include <v8.h>
12
13 namespace blink {
14
15 class ExecutionContext;
16
17 // A proxy class to invoke functions implemented in bindings/modules
18 // from bindings/core.
19 class CORE_EXPORT ModuleProxy {
20 USING_FAST_MALLOC(ModuleProxy);
21 public:
22 static ModuleProxy& moduleProxy()
23 {
24 DEFINE_STATIC_LOCAL(ModuleProxy, moduleProxy, ());
25 return moduleProxy;
26 }
27
28 ExecutionContext* toExecutionContextForModules(v8::Local<v8::Context> contex t)
29 {
30 RELEASE_ASSERT(m_toExecutionContextForModules);
31 return (*m_toExecutionContextForModules)(context);
32 }
33
34 void registerToExecutionContextForModules(ExecutionContext* (*toExecutionCon textForModules)(v8::Local<v8::Context>))
35 {
36 m_toExecutionContextForModules = toExecutionContextForModules;
37 }
38
39 v8::Local<v8::Context> toV8ContextForModules(ExecutionContext* context)
40 {
41 RELEASE_ASSERT(m_toV8ContextForModules);
42 return (*m_toV8ContextForModules)(context);
43 }
44
45 void registerToV8ContextForModules(v8::Local<v8::Context> (*toV8ContextForMo dules)(ExecutionContext*))
46 {
47 m_toV8ContextForModules = toV8ContextForModules;
48 }
49
50 private:
51 ModuleProxy() { }
52
53 ExecutionContext* (*m_toExecutionContextForModules)(v8::Local<v8::Context>) = nullptr;
54 v8::Local<v8::Context> (*m_toV8ContextForModules)(ExecutionContext*) = nullp tr;
55 };
56
57 } // namespace blink
58
59 #endif // ModuleProxy_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698