| 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 #include <utility> | 5 #include <utility> |
| 6 | 6 |
| 7 #include "base/at_exit.h" | 7 #include "base/at_exit.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "mojo/public/cpp/bindings/binding_set.h" | 10 #include "mojo/public/cpp/bindings/binding_set.h" |
| 11 #include "services/shell/public/cpp/connection.h" | 11 #include "services/shell/public/cpp/connection.h" |
| 12 #include "services/shell/public/cpp/interface_factory.h" | 12 #include "services/shell/public/cpp/interface_factory.h" |
| 13 #include "services/shell/public/cpp/shell_client.h" | 13 #include "services/shell/public/cpp/shell_client.h" |
| 14 #include "services/shell/runner/child/test_native_main.h" | 14 #include "services/shell/runner/child/test_native_main.h" |
| 15 #include "services/shell/runner/child/test_native_service.mojom.h" | 15 #include "services/shell/runner/child/test_native_service.mojom.h" |
| 16 #include "services/shell/runner/init.h" | 16 #include "services/shell/runner/init.h" |
| 17 | 17 |
| 18 namespace { | 18 namespace { |
| 19 | 19 |
| 20 class TargetApplicationDelegate | 20 class TargetApplicationDelegate |
| 21 : public mojo::ShellClient, | 21 : public shell::ShellClient, |
| 22 public mojo::shell::test::TestNativeService, | 22 public shell::test::TestNativeService, |
| 23 public mojo::InterfaceFactory<mojo::shell::test::TestNativeService> { | 23 public shell::InterfaceFactory<shell::test::TestNativeService> { |
| 24 public: | 24 public: |
| 25 TargetApplicationDelegate() {} | 25 TargetApplicationDelegate() {} |
| 26 ~TargetApplicationDelegate() override {} | 26 ~TargetApplicationDelegate() override {} |
| 27 | 27 |
| 28 private: | 28 private: |
| 29 // mojo::ShellClient: | 29 // shell::ShellClient: |
| 30 bool AcceptConnection(mojo::Connection* connection) override { | 30 bool AcceptConnection(shell::Connection* connection) override { |
| 31 connection->AddInterface<mojo::shell::test::TestNativeService>(this); | 31 connection->AddInterface<shell::test::TestNativeService>(this); |
| 32 return true; | 32 return true; |
| 33 } | 33 } |
| 34 | 34 |
| 35 // mojo::shell::test::TestNativeService: | 35 // shell::test::TestNativeService: |
| 36 void Invert(bool from_driver, const InvertCallback& callback) override { | 36 void Invert(bool from_driver, const InvertCallback& callback) override { |
| 37 callback.Run(!from_driver); | 37 callback.Run(!from_driver); |
| 38 } | 38 } |
| 39 | 39 |
| 40 // mojo::InterfaceFactory<mojo::shell::test::TestNativeService>: | 40 // shell::InterfaceFactory<shell::test::TestNativeService>: |
| 41 void Create(mojo::Connection* connection, | 41 void Create( |
| 42 mojo::InterfaceRequest<mojo::shell::test::TestNativeService> | 42 shell::Connection* connection, |
| 43 request) override { | 43 mojo::InterfaceRequest<shell::test::TestNativeService> request) override { |
| 44 bindings_.AddBinding(this, std::move(request)); | 44 bindings_.AddBinding(this, std::move(request)); |
| 45 } | 45 } |
| 46 | 46 |
| 47 mojo::BindingSet<mojo::shell::test::TestNativeService> bindings_; | 47 mojo::BindingSet<shell::test::TestNativeService> bindings_; |
| 48 | 48 |
| 49 DISALLOW_COPY_AND_ASSIGN(TargetApplicationDelegate); | 49 DISALLOW_COPY_AND_ASSIGN(TargetApplicationDelegate); |
| 50 }; | 50 }; |
| 51 | 51 |
| 52 } // namespace | 52 } // namespace |
| 53 | 53 |
| 54 int main(int argc, char** argv) { | 54 int main(int argc, char** argv) { |
| 55 base::AtExitManager at_exit; | 55 base::AtExitManager at_exit; |
| 56 base::CommandLine::Init(argc, argv); | 56 base::CommandLine::Init(argc, argv); |
| 57 | 57 |
| 58 mojo::shell::InitializeLogging(); | 58 shell::InitializeLogging(); |
| 59 | 59 |
| 60 TargetApplicationDelegate delegate; | 60 TargetApplicationDelegate delegate; |
| 61 return mojo::shell::TestNativeMain(&delegate); | 61 return shell::TestNativeMain(&delegate); |
| 62 } | 62 } |
| OLD | NEW |