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

Side by Side 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 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 InterfaceRegistry_h
6 #define InterfaceRegistry_h
7
8 #include "base/callback_forward.h"
9 #include "mojo/public/cpp/system/message_pipe.h"
10 #include "public/platform/WebCommon.h"
11
12 #if INSIDE_BLINK
13 #include "mojo/public/cpp/bindings/interface_request.h"
14 #include "wtf/Functional.h"
15 #endif
16
17 namespace blink {
18
19 using InterfaceFactory = base::Callback<void(mojo::ScopedMessagePipeHandle)>;
20
21 class BLINK_PLATFORM_EXPORT InterfaceRegistry {
22 public:
23 virtual void addInterface(const char* name, const InterfaceFactory&) = 0;
24
25 #if INSIDE_BLINK
26 static InterfaceRegistry* getEmptyInterfaceRegistry();
27
28 template <typename Interface>
29 void addInterface(
30 std::unique_ptr<WTF::Function<void(mojo::InterfaceRequest<Interface>)>>
31 factory) {
32 addInterface(Interface::Name_,
33 convertToBaseCallback(WTF::bind(
34 &InterfaceRegistry::forwardToInterfaceFactory<Interface>,
35 std::move(factory))));
36 }
37
38 private:
39 template <typename Interface>
40 static void forwardToInterfaceFactory(
41 const std::unique_ptr<
42 WTF::Function<void(mojo::InterfaceRequest<Interface>)>>& factory,
43 mojo::ScopedMessagePipeHandle handle) {
44 (*factory)(mojo::MakeRequest<Interface>(std::move(handle)));
45 }
46 #endif // INSIDE_BLINK
47 };
48
49 } // namespace blink
50
51 #endif
OLDNEW
« 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