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

Side by Side Diff: content/public/common/associated_interface_registry.h

Issue 2310563002: Adds routed interface support between RenderFrameHost and RenderFrame (Closed)
Patch Set: . Created 4 years, 3 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 CONTENT_PUBLIC_COMMON_ASSOCIATED_INTERFACE_REGISTRY_H_
6 #define CONTENT_PUBLIC_COMMON_ASSOCIATED_INTERFACE_REGISTRY_H_
7
8 #include <string>
9
10 #include "base/bind.h"
11 #include "base/callback.h"
12 #include "mojo/public/cpp/bindings/associated_interface_request.h"
13 #include "mojo/public/cpp/bindings/scoped_interface_endpoint_handle.h"
14
15 namespace content {
16
17 class AssociatedInterfaceRegistry {
18 public:
19 using Binder = base::Callback<void(mojo::ScopedInterfaceEndpointHandle)>;
20
21 virtual ~AssociatedInterfaceRegistry() {}
22
23 // Adds an interface binder to the registry.
24 virtual void AddInterface(const std::string& name, const Binder& binder) = 0;
25
26 // Removes an interface binder from the registry.
27 virtual void RemoveInterface(const std::string& name) = 0;
28
29 template <typename Interface>
30 using InterfaceBinder =
31 base::Callback<void(mojo::AssociatedInterfaceRequest<Interface>)>;
32
33 // Templated helper for AddInterface() above.
34 template <typename Interface>
35 void AddInterface(const InterfaceBinder<Interface>& binder) {
36 AddInterface(Interface::Name_,
37 base::Bind(&BindInterface<Interface>, binder));
38 }
39
40 private:
41 template <typename Interface>
42 static void BindInterface(const InterfaceBinder<Interface>& binder,
43 mojo::ScopedInterfaceEndpointHandle handle) {
44 mojo::AssociatedInterfaceRequest<Interface> request;
45 request.Bind(std::move(handle));
46 binder.Run(std::move(request));
47 }
48 };
49
50 } // namespace content
51
52 #endif // CONTENT_PUBLIC_COMMON_ASSOCIATED_INTERFACE_REGISTRY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698