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

Unified Diff: third_party/WebKit/public/platform/InterfaceRegistry.h

Issue 2401333002: Add a blink InterfaceRegistry. (Closed)
Patch Set: Created 4 years, 2 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
« no previous file with comments | « third_party/WebKit/Source/web/WebLocalFrameImpl.cpp ('k') | third_party/WebKit/public/web/WebFrameClient.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/public/platform/InterfaceRegistry.h
diff --git a/third_party/WebKit/public/platform/InterfaceRegistry.h b/third_party/WebKit/public/platform/InterfaceRegistry.h
new file mode 100644
index 0000000000000000000000000000000000000000..d0a2bf43e5ecd7bbbc438818cbec01e26d69094d
--- /dev/null
+++ b/third_party/WebKit/public/platform/InterfaceRegistry.h
@@ -0,0 +1,51 @@
+// 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 InterfaceRegistry_h
+#define InterfaceRegistry_h
+
+#include "base/callback_forward.h"
+#include "mojo/public/cpp/system/message_pipe.h"
+#include "public/platform/WebCommon.h"
+
+#if INSIDE_BLINK
+#include "mojo/public/cpp/bindings/interface_request.h"
+#include "wtf/Functional.h"
+#endif
+
+namespace blink {
+
+using InterfaceFactory = base::Callback<void(mojo::ScopedMessagePipeHandle)>;
+
+class BLINK_PLATFORM_EXPORT InterfaceRegistry {
+ public:
+ virtual void addInterface(const char* name, const InterfaceFactory&) = 0;
+
+#if INSIDE_BLINK
+ static InterfaceRegistry* getEmptyInterfaceRegistry();
+
+ template <typename Interface>
+ void addInterface(
+ std::unique_ptr<WTF::Function<void(mojo::InterfaceRequest<Interface>)>>
+ factory) {
+ addInterface(Interface::Name_,
+ convertToBaseCallback(WTF::bind(
+ &InterfaceRegistry::forwardToInterfaceFactory<Interface>,
+ std::move(factory))));
+ }
+
+ private:
+ template <typename Interface>
+ static void forwardToInterfaceFactory(
+ const std::unique_ptr<
+ WTF::Function<void(mojo::InterfaceRequest<Interface>)>>& factory,
+ mojo::ScopedMessagePipeHandle handle) {
+ (*factory)(mojo::MakeRequest<Interface>(std::move(handle)));
+ }
+#endif // INSIDE_BLINK
+};
+
+} // namespace blink
+
+#endif
« no previous file with comments | « third_party/WebKit/Source/web/WebLocalFrameImpl.cpp ('k') | third_party/WebKit/public/web/WebFrameClient.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698