| 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 "base/at_exit.h" | |
| 6 #include "base/command_line.h" | |
| 7 #include "base/macros.h" | |
| 8 #include "mojo/public/cpp/bindings/binding_set.h" | |
| 9 #include "mojo/shell/public/cpp/connection.h" | |
| 10 #include "mojo/shell/public/cpp/connector.h" | |
| 11 #include "mojo/shell/public/cpp/shell_client.h" | |
| 12 #include "mojo/shell/runner/child/test_native_main.h" | |
| 13 #include "mojo/shell/runner/init.h" | |
| 14 #include "mojo/shell/tests/connect/connect_test.mojom.h" | |
| 15 | |
| 16 using mojo::shell::test::mojom::ConnectTestService; | |
| 17 using mojo::shell::test::mojom::ConnectTestServiceRequest; | |
| 18 | |
| 19 namespace { | |
| 20 | |
| 21 class Target : public mojo::ShellClient, | |
| 22 public mojo::InterfaceFactory<ConnectTestService>, | |
| 23 public ConnectTestService { | |
| 24 public: | |
| 25 Target() {} | |
| 26 ~Target() override {} | |
| 27 | |
| 28 private: | |
| 29 // mojo::ShellClient: | |
| 30 void Initialize(mojo::Connector* connector, const mojo::Identity& identity, | |
| 31 uint32_t id) override { | |
| 32 identity_ = identity; | |
| 33 } | |
| 34 bool AcceptConnection(mojo::Connection* connection) override { | |
| 35 connection->AddInterface<ConnectTestService>(this); | |
| 36 return true; | |
| 37 } | |
| 38 | |
| 39 // mojo::InterfaceFactory<ConnectTestService>: | |
| 40 void Create(mojo::Connection* connection, | |
| 41 ConnectTestServiceRequest request) override { | |
| 42 bindings_.AddBinding(this, std::move(request)); | |
| 43 } | |
| 44 | |
| 45 // ConnectTestService: | |
| 46 void GetTitle(const GetTitleCallback& callback) override { | |
| 47 callback.Run("connect_test_exe"); | |
| 48 } | |
| 49 void GetInstance(const GetInstanceCallback& callback) override { | |
| 50 callback.Run(identity_.instance()); | |
| 51 } | |
| 52 | |
| 53 mojo::Identity identity_; | |
| 54 mojo::BindingSet<ConnectTestService> bindings_; | |
| 55 | |
| 56 DISALLOW_COPY_AND_ASSIGN(Target); | |
| 57 }; | |
| 58 | |
| 59 } // namespace | |
| 60 | |
| 61 int main(int argc, char** argv) { | |
| 62 base::AtExitManager at_exit; | |
| 63 base::CommandLine::Init(argc, argv); | |
| 64 | |
| 65 mojo::shell::InitializeLogging(); | |
| 66 | |
| 67 Target target; | |
| 68 return mojo::shell::TestNativeMain(&target); | |
| 69 } | |
| OLD | NEW |