| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef MOJO_SHELL_RUNNER_CHILD_RUNNER_CONNECTION_H_ | 5 #ifndef MOJO_SHELL_RUNNER_CHILD_RUNNER_CONNECTION_H_ |
| 6 #define MOJO_SHELL_RUNNER_CHILD_RUNNER_CONNECTION_H_ | 6 #define MOJO_SHELL_RUNNER_CHILD_RUNNER_CONNECTION_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "mojo/shell/public/interfaces/shell_client.mojom.h" | 9 #include "mojo/shell/public/interfaces/shell_client.mojom.h" |
| 10 | 10 |
| 11 namespace mojo { | 11 namespace mojo { |
| 12 namespace shell { | 12 namespace shell { |
| 13 | 13 |
| 14 // Encapsulates a connection to a runner process. The connection object starts a | 14 // Encapsulates a connection to a runner process. The connection object starts a |
| 15 // background controller thread that is used to receive control messages from | 15 // background controller thread that is used to receive control messages from |
| 16 // the runner. When this object is destroyed the thread is joined. | 16 // the runner. When this object is destroyed the thread is joined. |
| 17 class RunnerConnection { | 17 class RunnerConnection { |
| 18 public: | 18 public: |
| 19 virtual ~RunnerConnection(); | 19 virtual ~RunnerConnection(); |
| 20 | 20 |
| 21 // Establish a connection to the runner, blocking the calling thread until | 21 // Establish a connection to the runner, blocking the calling thread until |
| 22 // it is established. The Application request from the runner is returned via | 22 // it is established. The Application request from the runner is returned via |
| 23 // |request|. | 23 // |request|. |
| 24 // |
| 24 // If a connection to the runner cannot be established, |request| will not be | 25 // If a connection to the runner cannot be established, |request| will not be |
| 25 // modified and this function will return null. | 26 // modified and this function will return null. |
| 27 // |
| 28 // If |exit_on_error| is true, the calling process will be terminated in the |
| 29 // event of an error on |handle|. |
| 30 // |
| 31 // TODO(rockot): Remove |exit_on_error| when it's safe for all clients to be |
| 32 // terminated on such errors. For now we don't want this killing content's |
| 33 // child processes. |
| 26 static RunnerConnection* ConnectToRunner( | 34 static RunnerConnection* ConnectToRunner( |
| 27 InterfaceRequest<mojom::ShellClient>* request, | 35 InterfaceRequest<mojom::ShellClient>* request, |
| 28 ScopedMessagePipeHandle handle); | 36 ScopedMessagePipeHandle handle, |
| 37 bool exit_on_error = true); |
| 29 | 38 |
| 30 protected: | 39 protected: |
| 31 RunnerConnection(); | 40 RunnerConnection(); |
| 32 | 41 |
| 33 private: | 42 private: |
| 34 DISALLOW_COPY_AND_ASSIGN(RunnerConnection); | 43 DISALLOW_COPY_AND_ASSIGN(RunnerConnection); |
| 35 }; | 44 }; |
| 36 | 45 |
| 37 } // namespace shell | 46 } // namespace shell |
| 38 } // namespace mojo | 47 } // namespace mojo |
| 39 | 48 |
| 40 #endif // MOJO_SHELL_RUNNER_CHILD_RUNNER_CONNECTION_H_ | 49 #endif // MOJO_SHELL_RUNNER_CHILD_RUNNER_CONNECTION_H_ |
| OLD | NEW |