| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/macros.h" | 6 #include "base/macros.h" |
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "mojo/public/c/system/main.h" | 9 #include "mojo/public/c/system/main.h" |
| 10 #include "mojo/public/cpp/bindings/binding_set.h" | 10 #include "mojo/public/cpp/bindings/binding_set.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 public test::mojom::ConnectTestService, | 27 public test::mojom::ConnectTestService, |
| 28 public test::mojom::StandaloneApp, | 28 public test::mojom::StandaloneApp, |
| 29 public test::mojom::BlockedInterface { | 29 public test::mojom::BlockedInterface { |
| 30 public: | 30 public: |
| 31 ConnectTestApp() {} | 31 ConnectTestApp() {} |
| 32 ~ConnectTestApp() override {} | 32 ~ConnectTestApp() override {} |
| 33 | 33 |
| 34 private: | 34 private: |
| 35 // mojo::ShellClient: | 35 // mojo::ShellClient: |
| 36 void Initialize(Connector* connector, const std::string& name, | 36 void Initialize(Connector* connector, const std::string& name, |
| 37 uint32_t id, uint32_t user_id) override { | 37 const std::string& user_id, uint32_t id) override { |
| 38 connector_ = connector; | 38 connector_ = connector; |
| 39 name_ = name; | 39 name_ = name; |
| 40 id_ = id; | 40 id_ = id; |
| 41 userid_ = user_id; | 41 userid_ = user_id; |
| 42 bindings_.set_connection_error_handler( | 42 bindings_.set_connection_error_handler( |
| 43 base::Bind(&ConnectTestApp::OnConnectionError, | 43 base::Bind(&ConnectTestApp::OnConnectionError, |
| 44 base::Unretained(this))); | 44 base::Unretained(this))); |
| 45 standalone_bindings_.set_connection_error_handler( | 45 standalone_bindings_.set_connection_error_handler( |
| 46 base::Bind(&ConnectTestApp::OnConnectionError, | 46 base::Bind(&ConnectTestApp::OnConnectionError, |
| 47 base::Unretained(this))); | 47 base::Unretained(this))); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 } | 134 } |
| 135 | 135 |
| 136 void OnConnectionError() { | 136 void OnConnectionError() { |
| 137 if (bindings_.empty() && standalone_bindings_.empty()) | 137 if (bindings_.empty() && standalone_bindings_.empty()) |
| 138 base::MessageLoop::current()->QuitWhenIdle(); | 138 base::MessageLoop::current()->QuitWhenIdle(); |
| 139 } | 139 } |
| 140 | 140 |
| 141 Connector* connector_ = nullptr; | 141 Connector* connector_ = nullptr; |
| 142 std::string name_; | 142 std::string name_; |
| 143 uint32_t id_ = mojom::Connector::kInvalidApplicationID; | 143 uint32_t id_ = mojom::Connector::kInvalidApplicationID; |
| 144 uint32_t userid_ = mojom::Connector::kUserRoot; | 144 std::string userid_ = mojom::kRootUserID; |
| 145 BindingSet<test::mojom::ConnectTestService> bindings_; | 145 BindingSet<test::mojom::ConnectTestService> bindings_; |
| 146 BindingSet<test::mojom::StandaloneApp> standalone_bindings_; | 146 BindingSet<test::mojom::StandaloneApp> standalone_bindings_; |
| 147 BindingSet<test::mojom::BlockedInterface> blocked_bindings_; | 147 BindingSet<test::mojom::BlockedInterface> blocked_bindings_; |
| 148 test::mojom::ExposedInterfacePtr caller_; | 148 test::mojom::ExposedInterfacePtr caller_; |
| 149 | 149 |
| 150 DISALLOW_COPY_AND_ASSIGN(ConnectTestApp); | 150 DISALLOW_COPY_AND_ASSIGN(ConnectTestApp); |
| 151 }; | 151 }; |
| 152 | 152 |
| 153 } // namespace shell | 153 } // namespace shell |
| 154 } // namespace mojo | 154 } // namespace mojo |
| 155 | 155 |
| 156 | 156 |
| 157 MojoResult MojoMain(MojoHandle shell_handle) { | 157 MojoResult MojoMain(MojoHandle shell_handle) { |
| 158 MojoResult rv = mojo::ApplicationRunner( | 158 MojoResult rv = mojo::ApplicationRunner( |
| 159 new mojo::shell::ConnectTestApp).Run(shell_handle); | 159 new mojo::shell::ConnectTestApp).Run(shell_handle); |
| 160 return rv; | 160 return rv; |
| 161 } | 161 } |
| OLD | NEW |