Chromium Code Reviews| Index: examples/indirect_service/integer_service.cc |
| diff --git a/examples/echo/echo_service.cc b/examples/indirect_service/integer_service.cc |
| similarity index 57% |
| copy from examples/echo/echo_service.cc |
| copy to examples/indirect_service/integer_service.cc |
| index c96f106a688b0d91a9f8f85c3b349ca39c48ffa6..f590438cec6a9c420aee9ac354f53faf55fc7bd1 100644 |
| --- a/examples/echo/echo_service.cc |
| +++ b/examples/indirect_service/integer_service.cc |
| @@ -2,7 +2,7 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#include "examples/echo/echo_service.mojom.h" |
| +#include "examples/indirect_service/indirect_service_demo.mojom.h" |
| #include "mojo/public/c/system/main.h" |
| #include "mojo/public/cpp/application/application_connection.h" |
| #include "mojo/public/cpp/application/application_delegate.h" |
| @@ -12,30 +12,36 @@ |
| namespace mojo { |
| namespace examples { |
| -class EchoServiceImpl : public InterfaceImpl<EchoService> { |
| +class IntegerServiceImpl : public InterfaceImpl<IntegerService> { |
| public: |
| - virtual void EchoString(const String& value, |
| - const Callback<void(String)>& callback) override { |
| - callback.Run(value); |
| + IntegerServiceImpl() : value_(0) {} |
| + virtual ~IntegerServiceImpl() {} |
|
yzshen1
2014/11/20 22:01:44
nit: use "override" instead of "virtual" whenever
hansmuller
2014/11/20 22:35:38
Sorry, I thought I had cleaned all of these up.
|
| + |
| + virtual void Increment(const Callback<void(int32_t)>& callback) override { |
| + callback.Run(value_++); |
| } |
| + |
| + private: |
| + int32_t value_; |
| }; |
| -class EchoServiceDelegate : public ApplicationDelegate { |
| +class IntegerServiceAppDelegate : public ApplicationDelegate { |
| public: |
| virtual bool ConfigureIncomingConnection( |
| ApplicationConnection* connection) override { |
| - connection->AddService(&echo_service_factory_); |
| + connection->AddService(&integer_service_factory_); |
| return true; |
| } |
| private: |
| - InterfaceFactoryImpl<EchoServiceImpl> echo_service_factory_; |
| + InterfaceFactoryImpl<IntegerServiceImpl> integer_service_factory_; |
| }; |
| } // namespace examples |
| } // namespace mojo |
| MojoResult MojoMain(MojoHandle shell_handle) { |
| - mojo::ApplicationRunner runner(new mojo::examples::EchoServiceDelegate); |
| + mojo::ApplicationRunner runner(new mojo::examples::IntegerServiceAppDelegate); |
| return runner.Run(shell_handle); |
| } |
| + |