| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 14 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
| 15 #include "base/threading/simple_thread.h" | 15 #include "base/threading/simple_thread.h" |
| 16 #include "mojo/public/c/system/main.h" | 16 #include "mojo/public/c/system/main.h" |
| 17 #include "mojo/public/cpp/bindings/binding_set.h" | 17 #include "mojo/public/cpp/bindings/binding_set.h" |
| 18 #include "services/shell/public/cpp/application_runner.h" | |
| 19 #include "services/shell/public/cpp/connector.h" | 18 #include "services/shell/public/cpp/connector.h" |
| 20 #include "services/shell/public/cpp/interface_factory.h" | 19 #include "services/shell/public/cpp/interface_factory.h" |
| 21 #include "services/shell/public/cpp/service.h" | 20 #include "services/shell/public/cpp/service.h" |
| 21 #include "services/shell/public/cpp/service_runner.h" |
| 22 #include "services/shell/public/interfaces/service_factory.mojom.h" | 22 #include "services/shell/public/interfaces/service_factory.mojom.h" |
| 23 #include "services/shell/tests/connect/connect_test.mojom.h" | 23 #include "services/shell/tests/connect/connect_test.mojom.h" |
| 24 | 24 |
| 25 // Tests that multiple applications can be packaged in a single Mojo application | 25 // Tests that multiple applications can be packaged in a single Mojo application |
| 26 // implementing ServiceFactory; that these applications can be specified by | 26 // implementing ServiceFactory; that these applications can be specified by |
| 27 // the package's manifest and are thus registered with the PackageManager. | 27 // the package's manifest and are thus registered with the PackageManager. |
| 28 | 28 |
| 29 namespace shell { | 29 namespace shell { |
| 30 | 30 |
| 31 namespace { | 31 namespace { |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 base::MessageLoop::ScopedNestableTaskAllower allow( | 133 base::MessageLoop::ScopedNestableTaskAllower allow( |
| 134 base::MessageLoop::current()); | 134 base::MessageLoop::current()); |
| 135 loop.Run(); | 135 loop.Run(); |
| 136 } | 136 } |
| 137 callback.Run(static_cast<int32_t>(connection->GetResult()), | 137 callback.Run(static_cast<int32_t>(connection->GetResult()), |
| 138 mojom::Identity::From(connection->GetRemoteIdentity())); | 138 mojom::Identity::From(connection->GetRemoteIdentity())); |
| 139 } | 139 } |
| 140 | 140 |
| 141 // base::SimpleThread: | 141 // base::SimpleThread: |
| 142 void Run() override { | 142 void Run() override { |
| 143 ApplicationRunner(this).Run(request_.PassMessagePipe().release().value(), | 143 ServiceRunner(this).Run(request_.PassMessagePipe().release().value(), |
| 144 false); | 144 false); |
| 145 delete this; | 145 delete this; |
| 146 } | 146 } |
| 147 | 147 |
| 148 void OnConnectionError() { | 148 void OnConnectionError() { |
| 149 if (bindings_.empty()) | 149 if (bindings_.empty()) |
| 150 base::MessageLoop::current()->QuitWhenIdle(); | 150 base::MessageLoop::current()->QuitWhenIdle(); |
| 151 } | 151 } |
| 152 | 152 |
| 153 Connector* connector_ = nullptr; | 153 Connector* connector_ = nullptr; |
| 154 Identity identity_; | 154 Identity identity_; |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 std::vector<std::unique_ptr<Service>> delegates_; | 226 std::vector<std::unique_ptr<Service>> delegates_; |
| 227 mojo::BindingSet<mojom::ServiceFactory> service_factory_bindings_; | 227 mojo::BindingSet<mojom::ServiceFactory> service_factory_bindings_; |
| 228 mojo::BindingSet<test::mojom::ConnectTestService> bindings_; | 228 mojo::BindingSet<test::mojom::ConnectTestService> bindings_; |
| 229 | 229 |
| 230 DISALLOW_COPY_AND_ASSIGN(ConnectTestService); | 230 DISALLOW_COPY_AND_ASSIGN(ConnectTestService); |
| 231 }; | 231 }; |
| 232 | 232 |
| 233 } // namespace shell | 233 } // namespace shell |
| 234 | 234 |
| 235 MojoResult MojoMain(MojoHandle shell_handle) { | 235 MojoResult MojoMain(MojoHandle shell_handle) { |
| 236 MojoResult rv = shell::ApplicationRunner(new shell::ConnectTestService) | 236 MojoResult rv = shell::ServiceRunner(new shell::ConnectTestService) |
| 237 .Run(shell_handle); | 237 .Run(shell_handle); |
| 238 return rv; | 238 return rv; |
| 239 } | 239 } |
| OLD | NEW |