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 |