| OLD | NEW |
| 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 MOJO_SHELL_CONNECT_UTIL_H_ | 5 #ifndef MOJO_SHELL_CONNECT_UTIL_H_ |
| 6 #define MOJO_SHELL_CONNECT_UTIL_H_ | 6 #define MOJO_SHELL_CONNECT_UTIL_H_ |
| 7 | 7 |
| 8 #include <utility> |
| 9 |
| 8 #include "mojo/public/cpp/bindings/interface_ptr.h" | 10 #include "mojo/public/cpp/bindings/interface_ptr.h" |
| 9 #include "mojo/public/cpp/system/handle.h" | 11 #include "mojo/public/cpp/system/handle.h" |
| 10 | 12 |
| 11 class GURL; | 13 class GURL; |
| 12 | 14 |
| 13 namespace mojo { | 15 namespace mojo { |
| 14 namespace shell { | 16 namespace shell { |
| 15 | 17 |
| 16 class ApplicationManager; | 18 class ApplicationManager; |
| 17 | 19 |
| 18 ScopedMessagePipeHandle ConnectToServiceByName( | 20 ScopedMessagePipeHandle ConnectToServiceByName( |
| 19 ApplicationManager* application_manager, | 21 ApplicationManager* application_manager, |
| 20 const GURL& application_url, | 22 const GURL& application_url, |
| 21 const std::string& interface_name); | 23 const std::string& interface_name); |
| 22 | 24 |
| 23 // Must only be used by shell internals and test code as it does not forward | 25 // Must only be used by shell internals and test code as it does not forward |
| 24 // capability filters. Runs |application_url| with a permissive capability | 26 // capability filters. Runs |application_url| with a permissive capability |
| 25 // filter. | 27 // filter. |
| 26 template <typename Interface> | 28 template <typename Interface> |
| 27 inline void ConnectToService(ApplicationManager* application_manager, | 29 inline void ConnectToService(ApplicationManager* application_manager, |
| 28 const GURL& application_url, | 30 const GURL& application_url, |
| 29 InterfacePtr<Interface>* ptr) { | 31 InterfacePtr<Interface>* ptr) { |
| 30 ScopedMessagePipeHandle service_handle = | 32 ScopedMessagePipeHandle service_handle = |
| 31 ConnectToServiceByName(application_manager, application_url, | 33 ConnectToServiceByName(application_manager, application_url, |
| 32 Interface::Name_); | 34 Interface::Name_); |
| 33 ptr->Bind(InterfacePtrInfo<Interface>(service_handle.Pass(), 0u)); | 35 ptr->Bind(InterfacePtrInfo<Interface>(std::move(service_handle), 0u)); |
| 34 } | 36 } |
| 35 | 37 |
| 36 } // namespace shell | 38 } // namespace shell |
| 37 } // namespace mojo | 39 } // namespace mojo |
| 38 | 40 |
| 39 | 41 |
| 40 #endif // MOJO_SHELL_CONNECT_UTIL_H_ | 42 #endif // MOJO_SHELL_CONNECT_UTIL_H_ |
| OLD | NEW |