1cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)// Copyright 2014 The Chromium Authors. All rights reserved.
2cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
3cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)// found in the LICENSE file.
4cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)
5cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#ifndef MOJO_PUBLIC_CPP_APPLICATION_CONNECT_H_
6cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#define MOJO_PUBLIC_CPP_APPLICATION_CONNECT_H_
7cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)
85f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#include "mojo/public/interfaces/application/service_provider.mojom.h"
9cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)
10cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)namespace mojo {
11cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)
12cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)template <typename Interface>
13cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)inline void ConnectToService(ServiceProvider* service_provider,
14cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)                             InterfacePtr<Interface>* ptr) {
15cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  MessagePipe pipe;
16cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  ptr->Bind(pipe.handle0.Pass());
17116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  service_provider->ConnectToService(Interface::Name_, pipe.handle1.Pass());
18cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)}
19cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)
20cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)}  // namespace mojo
21cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)
22cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#endif  // MOJO_PUBLIC_CPP_APPLICATION_CONNECT_H_
23