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