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

Side by Side Diff: services/service_manager/connect_util.h

Issue 2617883002: Add a new BindInterface() method to Connector. (Closed)
Patch Set: . Created 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef SERVICES_SERVICE_MANAGER_CONNECT_UTIL_H_ 5 #ifndef SERVICES_SERVICE_MANAGER_CONNECT_UTIL_H_
6 #define SERVICES_SERVICE_MANAGER_CONNECT_UTIL_H_ 6 #define SERVICES_SERVICE_MANAGER_CONNECT_UTIL_H_
7 7
8 #include "mojo/public/cpp/bindings/interface_ptr.h" 8 #include "mojo/public/cpp/bindings/interface_ptr.h"
9 #include "mojo/public/cpp/system/handle.h" 9 #include "mojo/public/cpp/system/handle.h"
10 #include "services/service_manager/public/cpp/identity.h" 10 #include "services/service_manager/public/cpp/identity.h"
11 #include "services/service_manager/public/interfaces/connector.mojom.h" 11 #include "services/service_manager/public/interfaces/connector.mojom.h"
12 12
13 namespace service_manager { 13 namespace service_manager {
14 14
15 class ServiceManager; 15 class ServiceManager;
16 16
17 mojo::ScopedMessagePipeHandle ConnectToInterfaceByName( 17 mojo::ScopedMessagePipeHandle BindInterface(
18 ServiceManager* service_manager, 18 ServiceManager* service_manager,
19 const Identity& source, 19 const Identity& source,
20 const Identity& target, 20 const Identity& target,
21 const std::string& interface_name); 21 const std::string& interface_name);
22 22
23 // Must only be used by Service Manager internals and test code as it does not 23 // Must only be used by Service Manager internals and test code as it does not
24 // forward capability filters. Runs |name| with a permissive capability filter. 24 // forward capability filters. Runs |name| with a permissive capability filter.
25 template <typename Interface> 25 template <typename Interface>
26 inline void ConnectToInterface(ServiceManager* service_manager, 26 inline void BindInterface(ServiceManager* service_manager,
27 const Identity& source, 27 const Identity& source,
28 const Identity& target, 28 const Identity& target,
29 mojo::InterfacePtr<Interface>* ptr) { 29 mojo::InterfacePtr<Interface>* ptr) {
30 mojo::ScopedMessagePipeHandle service_handle = 30 mojo::ScopedMessagePipeHandle service_handle =
31 ConnectToInterfaceByName(service_manager, source, target, 31 BindInterface(service_manager, source, target, Interface::Name_);
32 Interface::Name_);
33 ptr->Bind(mojo::InterfacePtrInfo<Interface>(std::move(service_handle), 0u)); 32 ptr->Bind(mojo::InterfacePtrInfo<Interface>(std::move(service_handle), 0u));
34 } 33 }
35 34
36 template <typename Interface> 35 template <typename Interface>
37 inline void ConnectToInterface(ServiceManager* service_manager, 36 inline void BindInterface(ServiceManager* service_manager,
38 const Identity& source, 37 const Identity& source,
39 const std::string& name, 38 const std::string& name,
40 mojo::InterfacePtr<Interface>* ptr) { 39 mojo::InterfacePtr<Interface>* ptr) {
41 mojo::ScopedMessagePipeHandle service_handle = ConnectToInterfaceByName( 40 mojo::ScopedMessagePipeHandle service_handle = BindInterface(
42 service_manager, source, Identity(name, mojom::kInheritUserID), 41 service_manager, source, Identity(name, mojom::kInheritUserID),
43 Interface::Name_); 42 Interface::Name_);
44 ptr->Bind(mojo::InterfacePtrInfo<Interface>(std::move(service_handle), 0u)); 43 ptr->Bind(mojo::InterfacePtrInfo<Interface>(std::move(service_handle), 0u));
45 } 44 }
46 45
47 } // namespace service_manager 46 } // namespace service_manager
48 47
49 #endif // SERVICES_SERVICE_MANAGER_CONNECT_UTIL_H_ 48 #endif // SERVICES_SERVICE_MANAGER_CONNECT_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698