Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / mojo / examples / echo / echo_service.cc
1 // Copyright 2014 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 #include "mojo/examples/echo/echo_service.mojom.h"
6 #include "mojo/public/cpp/application/application_connection.h"
7 #include "mojo/public/cpp/application/application_delegate.h"
8 #include "mojo/public/cpp/application/interface_factory_impl.h"
9
10 namespace mojo {
11 namespace examples {
12
13 class EchoServiceImpl : public InterfaceImpl<EchoService> {
14  public:
15   virtual void EchoString(
16       const String& value,
17       const Callback<void(String)>& callback) MOJO_OVERRIDE {
18     callback.Run(value);
19   }
20 };
21
22 class EchoServiceDelegate : public ApplicationDelegate {
23  public:
24   virtual bool ConfigureIncomingConnection(ApplicationConnection* connection)
25       MOJO_OVERRIDE {
26     connection->AddService(&echo_service_factory_);
27     return true;
28   }
29
30  private:
31   InterfaceFactoryImpl<EchoServiceImpl> echo_service_factory_;
32 };
33
34 }  // namespace examples
35
36 // static
37 ApplicationDelegate* ApplicationDelegate::Create() {
38   return new examples::EchoServiceDelegate();
39 }
40
41 }  // namespace mojo