15f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)// Copyright 2014 The Chromium Authors. All rights reserved. 25f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)// found in the LICENSE file. 45f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) 55f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#include "mojo/examples/echo/echo_service.mojom.h" 603b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)#include "mojo/public/c/system/main.h" 75f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#include "mojo/public/cpp/application/application_connection.h" 85f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#include "mojo/public/cpp/application/application_delegate.h" 903b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)#include "mojo/public/cpp/application/application_runner.h" 105f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#include "mojo/public/cpp/application/interface_factory_impl.h" 115f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) 125f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)namespace mojo { 135f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)namespace examples { 145f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) 155f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)class EchoServiceImpl : public InterfaceImpl<EchoService> { 165f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) public: 175f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) virtual void EchoString( 185f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) const String& value, 195f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) const Callback<void(String)>& callback) MOJO_OVERRIDE { 205f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) callback.Run(value); 215f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) } 225f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)}; 235f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) 245f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)class EchoServiceDelegate : public ApplicationDelegate { 255f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) public: 265f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) virtual bool ConfigureIncomingConnection(ApplicationConnection* connection) 275f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) MOJO_OVERRIDE { 285f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) connection->AddService(&echo_service_factory_); 295f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) return true; 305f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) } 315f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) 325f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) private: 335f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) InterfaceFactoryImpl<EchoServiceImpl> echo_service_factory_; 345f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)}; 355f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) 365f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)} // namespace examples 3703b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)} // namespace mojo 385f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) 3903b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)MojoResult MojoMain(MojoHandle shell_handle) { 4003b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) mojo::ApplicationRunner runner(new mojo::examples::EchoServiceDelegate); 4103b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) return runner.Run(shell_handle); 425f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)} 43