| 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 <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 request_(std::move(request)) { | 44 request_(std::move(request)) { |
| 45 Start(); | 45 Start(); |
| 46 } | 46 } |
| 47 ~ProvidedShellClient() override { | 47 ~ProvidedShellClient() override { |
| 48 Join(); | 48 Join(); |
| 49 } | 49 } |
| 50 | 50 |
| 51 private: | 51 private: |
| 52 // mojo::ShellClient: | 52 // mojo::ShellClient: |
| 53 void Initialize(Connector* connector, const std::string& name, | 53 void Initialize(Connector* connector, const std::string& name, |
| 54 uint32_t id, uint32_t user_id) override { | 54 const std::string& user_id, uint32_t id) override { |
| 55 name_ = name; | 55 name_ = name; |
| 56 id_ = id; | 56 id_ = id; |
| 57 userid_ = user_id; | 57 userid_ = user_id; |
| 58 bindings_.set_connection_error_handler( | 58 bindings_.set_connection_error_handler( |
| 59 base::Bind(&ProvidedShellClient::OnConnectionError, | 59 base::Bind(&ProvidedShellClient::OnConnectionError, |
| 60 base::Unretained(this))); | 60 base::Unretained(this))); |
| 61 } | 61 } |
| 62 bool AcceptConnection(Connection* connection) override { | 62 bool AcceptConnection(Connection* connection) override { |
| 63 connection->AddInterface<test::mojom::ConnectTestService>(this); | 63 connection->AddInterface<test::mojom::ConnectTestService>(this); |
| 64 connection->AddInterface<test::mojom::BlockedInterface>(this); | 64 connection->AddInterface<test::mojom::BlockedInterface>(this); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 delete this; | 108 delete this; |
| 109 } | 109 } |
| 110 | 110 |
| 111 void OnConnectionError() { | 111 void OnConnectionError() { |
| 112 if (bindings_.empty()) | 112 if (bindings_.empty()) |
| 113 base::MessageLoop::current()->QuitWhenIdle(); | 113 base::MessageLoop::current()->QuitWhenIdle(); |
| 114 } | 114 } |
| 115 | 115 |
| 116 std::string name_; | 116 std::string name_; |
| 117 uint32_t id_ = mojom::Connector::kInvalidApplicationID; | 117 uint32_t id_ = mojom::Connector::kInvalidApplicationID; |
| 118 uint32_t userid_ = mojom::Connector::kUserRoot; | 118 std::string userid_ = mojom::kRootUserID; |
| 119 const std::string title_; | 119 const std::string title_; |
| 120 mojom::ShellClientRequest request_; | 120 mojom::ShellClientRequest request_; |
| 121 test::mojom::ExposedInterfacePtr caller_; | 121 test::mojom::ExposedInterfacePtr caller_; |
| 122 BindingSet<test::mojom::ConnectTestService> bindings_; | 122 BindingSet<test::mojom::ConnectTestService> bindings_; |
| 123 BindingSet<test::mojom::BlockedInterface> blocked_bindings_; | 123 BindingSet<test::mojom::BlockedInterface> blocked_bindings_; |
| 124 | 124 |
| 125 DISALLOW_COPY_AND_ASSIGN(ProvidedShellClient); | 125 DISALLOW_COPY_AND_ASSIGN(ProvidedShellClient); |
| 126 }; | 126 }; |
| 127 | 127 |
| 128 class ConnectTestShellClient | 128 class ConnectTestShellClient |
| 129 : public ShellClient, | 129 : public ShellClient, |
| 130 public InterfaceFactory<mojom::ShellClientFactory>, | 130 public InterfaceFactory<mojom::ShellClientFactory>, |
| 131 public InterfaceFactory<test::mojom::ConnectTestService>, | 131 public InterfaceFactory<test::mojom::ConnectTestService>, |
| 132 public mojom::ShellClientFactory, | 132 public mojom::ShellClientFactory, |
| 133 public test::mojom::ConnectTestService { | 133 public test::mojom::ConnectTestService { |
| 134 public: | 134 public: |
| 135 ConnectTestShellClient() {} | 135 ConnectTestShellClient() {} |
| 136 ~ConnectTestShellClient() override {} | 136 ~ConnectTestShellClient() override {} |
| 137 | 137 |
| 138 private: | 138 private: |
| 139 // mojo::ShellClient: | 139 // mojo::ShellClient: |
| 140 void Initialize(Connector* connector, const std::string& name, | 140 void Initialize(Connector* connector, const std::string& name, |
| 141 uint32_t id, uint32_t user_id) override { | 141 const std::string& user_id, uint32_t id) override { |
| 142 bindings_.set_connection_error_handler( | 142 bindings_.set_connection_error_handler( |
| 143 base::Bind(&ConnectTestShellClient::OnConnectionError, | 143 base::Bind(&ConnectTestShellClient::OnConnectionError, |
| 144 base::Unretained(this))); | 144 base::Unretained(this))); |
| 145 } | 145 } |
| 146 bool AcceptConnection(Connection* connection) override { | 146 bool AcceptConnection(Connection* connection) override { |
| 147 connection->AddInterface<ShellClientFactory>(this); | 147 connection->AddInterface<ShellClientFactory>(this); |
| 148 connection->AddInterface<test::mojom::ConnectTestService>(this); | 148 connection->AddInterface<test::mojom::ConnectTestService>(this); |
| 149 return true; | 149 return true; |
| 150 } | 150 } |
| 151 void ShellConnectionLost() override { | 151 void ShellConnectionLost() override { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 | 195 |
| 196 } // namespace shell | 196 } // namespace shell |
| 197 } // namespace mojo | 197 } // namespace mojo |
| 198 | 198 |
| 199 | 199 |
| 200 MojoResult MojoMain(MojoHandle shell_handle) { | 200 MojoResult MojoMain(MojoHandle shell_handle) { |
| 201 MojoResult rv = mojo::ApplicationRunner( | 201 MojoResult rv = mojo::ApplicationRunner( |
| 202 new mojo::shell::ConnectTestShellClient).Run(shell_handle); | 202 new mojo::shell::ConnectTestShellClient).Run(shell_handle); |
| 203 return rv; | 203 return rv; |
| 204 } | 204 } |
| OLD | NEW |