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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/bindings/core/v8/ModuleProxy.h
diff --git a/third_party/WebKit/Source/bindings/core/v8/ModuleProxy.h b/third_party/WebKit/Source/bindings/core/v8/ModuleProxy.h
new file mode 100644
index 0000000000000000000000000000000000000000..fc324a9664201115c7c72f80e424ea3b39edcd84
--- /dev/null
+++ b/third_party/WebKit/Source/bindings/core/v8/ModuleProxy.h
@@ -0,0 +1,59 @@
+// 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.
+
+#ifndef ModuleProxy_h
+#define ModuleProxy_h
+
+#include "core/CoreExport.h"
+#include "wtf/Allocator.h"
+#include "wtf/StdLibExtras.h"
+#include <v8.h>
+
+namespace blink {
+
+class ExecutionContext;
+
+// A proxy class to invoke functions implemented in bindings/modules
+// from bindings/core.
+class CORE_EXPORT ModuleProxy {
+ USING_FAST_MALLOC(ModuleProxy);
+public:
+ static ModuleProxy& moduleProxy()
+ {
+ DEFINE_STATIC_LOCAL(ModuleProxy, moduleProxy, ());
+ return moduleProxy;
+ }
+
+ ExecutionContext* toExecutionContextForModules(v8::Local<v8::Context> context)
+ {
+ RELEASE_ASSERT(m_toExecutionContextForModules);
+ return (*m_toExecutionContextForModules)(context);
+ }
+
+ void registerToExecutionContextForModules(ExecutionContext* (*toExecutionContextForModules)(v8::Local<v8::Context>))
+ {
+ m_toExecutionContextForModules = toExecutionContextForModules;
+ }
+
+ v8::Local<v8::Context> toV8ContextForModules(ExecutionContext* context)
+ {
+ RELEASE_ASSERT(m_toV8ContextForModules);
+ return (*m_toV8ContextForModules)(context);
+ }
+
+ void registerToV8ContextForModules(v8::Local<v8::Context> (*toV8ContextForModules)(ExecutionContext*))
+ {
+ m_toV8ContextForModules = toV8ContextForModules;
+ }
+
+private:
+ ModuleProxy() { }
+
+ ExecutionContext* (*m_toExecutionContextForModules)(v8::Local<v8::Context>) = nullptr;
+ v8::Local<v8::Context> (*m_toV8ContextForModules)(ExecutionContext*) = nullptr;
+};
+
+} // namespace blink
+
+#endif // ModuleProxy_h

Powered by Google App Engine
This is Rietveld 408576698