| 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 <memory> | 5 #include <memory> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "mojo/public/cpp/bindings/binding_set.h" | 10 #include "mojo/public/cpp/bindings/binding_set.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 } | 41 } |
| 42 | 42 |
| 43 // InterfaceFactory<shell::test::mojom::Parent>: | 43 // InterfaceFactory<shell::test::mojom::Parent>: |
| 44 void Create(const shell::Identity& remote_identity, | 44 void Create(const shell::Identity& remote_identity, |
| 45 shell::test::mojom::ParentRequest request) override { | 45 shell::test::mojom::ParentRequest request) override { |
| 46 parent_bindings_.AddBinding(this, std::move(request)); | 46 parent_bindings_.AddBinding(this, std::move(request)); |
| 47 } | 47 } |
| 48 | 48 |
| 49 // Parent: | 49 // Parent: |
| 50 void ConnectToChild(const ConnectToChildCallback& callback) override { | 50 void ConnectToChild(const ConnectToChildCallback& callback) override { |
| 51 child_connection_ = connector()->Connect("mojo:lifecycle_unittest_app"); | 51 child_connection_ = connector()->Connect("service:lifecycle_unittest_app"); |
| 52 shell::test::mojom::LifecycleControlPtr lifecycle; | 52 shell::test::mojom::LifecycleControlPtr lifecycle; |
| 53 child_connection_->GetInterface(&lifecycle); | 53 child_connection_->GetInterface(&lifecycle); |
| 54 { | 54 { |
| 55 base::RunLoop loop; | 55 base::RunLoop loop; |
| 56 lifecycle->Ping(base::Bind(&QuitLoop, &loop)); | 56 lifecycle->Ping(base::Bind(&QuitLoop, &loop)); |
| 57 base::MessageLoop::ScopedNestableTaskAllower allow( | 57 base::MessageLoop::ScopedNestableTaskAllower allow( |
| 58 base::MessageLoop::current()); | 58 base::MessageLoop::current()); |
| 59 loop.Run(); | 59 loop.Run(); |
| 60 } | 60 } |
| 61 callback.Run(); | 61 callback.Run(); |
| 62 } | 62 } |
| 63 void Quit() override { | 63 void Quit() override { |
| 64 base::MessageLoop::current()->QuitWhenIdle(); | 64 base::MessageLoop::current()->QuitWhenIdle(); |
| 65 } | 65 } |
| 66 | 66 |
| 67 std::unique_ptr<shell::Connection> child_connection_; | 67 std::unique_ptr<shell::Connection> child_connection_; |
| 68 mojo::BindingSet<shell::test::mojom::Parent> parent_bindings_; | 68 mojo::BindingSet<shell::test::mojom::Parent> parent_bindings_; |
| 69 | 69 |
| 70 DISALLOW_COPY_AND_ASSIGN(Parent); | 70 DISALLOW_COPY_AND_ASSIGN(Parent); |
| 71 }; | 71 }; |
| 72 | 72 |
| 73 } // namespace | 73 } // namespace |
| 74 | 74 |
| 75 MojoResult ServiceMain(MojoHandle service_request_handle) { | 75 MojoResult ServiceMain(MojoHandle service_request_handle) { |
| 76 Parent* parent = new Parent; | 76 Parent* parent = new Parent; |
| 77 return shell::ServiceRunner(parent).Run(service_request_handle); | 77 return shell::ServiceRunner(parent).Run(service_request_handle); |
| 78 } | 78 } |
| OLD | NEW |