| 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 CONTENT_COMMON_MOJO_SHELL_CONNECTION_IMPL_H_ | 5 #ifndef CONTENT_COMMON_MOJO_SHELL_CONNECTION_IMPL_H_ |
| 6 #define CONTENT_COMMON_MOJO_SHELL_CONNECTION_IMPL_H_ | 6 #define CONTENT_COMMON_MOJO_SHELL_CONNECTION_IMPL_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 | 35 |
| 36 // Like above but for initializing a connection to an embedded in-process | 36 // Like above but for initializing a connection to an embedded in-process |
| 37 // shell implementation. Binds to |request|. | 37 // shell implementation. Binds to |request|. |
| 38 static void Create(mojo::shell::mojom::ShellClientRequest request); | 38 static void Create(mojo::shell::mojom::ShellClientRequest request); |
| 39 | 39 |
| 40 // Will return null if no connection has been established (either because it | 40 // Will return null if no connection has been established (either because it |
| 41 // hasn't happened yet or the application was not spawned from the external | 41 // hasn't happened yet or the application was not spawned from the external |
| 42 // Mojo shell). | 42 // Mojo shell). |
| 43 static MojoShellConnectionImpl* Get(); | 43 static MojoShellConnectionImpl* Get(); |
| 44 | 44 |
| 45 // Blocks the calling thread until calling GetApplication() will return an | 45 // Binds the shell connection to a ShellClientFactory request pipe from the |
| 46 // Initialized() application with a bound ShellPtr. This call is a no-op | 46 // command line. This must only be called once. |
| 47 // if the connection has already been initialized. | 47 void BindToRequestFromCommandLine(); |
| 48 void BindToCommandLinePlatformChannel(); | |
| 49 | |
| 50 // Same as BindToCommandLinePlatformChannel(), but receives a |handle| instead | |
| 51 // of looking for one on the command line. | |
| 52 void BindToMessagePipe(mojo::ScopedMessagePipeHandle handle); | |
| 53 | 48 |
| 54 private: | 49 private: |
| 55 explicit MojoShellConnectionImpl(bool external); | 50 explicit MojoShellConnectionImpl(bool external); |
| 56 ~MojoShellConnectionImpl() override; | 51 ~MojoShellConnectionImpl() override; |
| 57 | 52 |
| 58 // mojo::ShellClient: | 53 // mojo::ShellClient: |
| 59 void Initialize(mojo::Connector* connector, const mojo::Identity& identity, | 54 void Initialize(mojo::Connector* connector, |
| 55 const mojo::Identity& identity, |
| 60 uint32_t id) override; | 56 uint32_t id) override; |
| 61 bool AcceptConnection(mojo::Connection* connection) override; | 57 bool AcceptConnection(mojo::Connection* connection) override; |
| 62 | 58 |
| 63 // MojoShellConnection: | 59 // MojoShellConnection: |
| 64 mojo::Connector* GetConnector() override; | 60 mojo::Connector* GetConnector() override; |
| 65 bool UsingExternalShell() const override; | 61 bool UsingExternalShell() const override; |
| 66 void AddListener(Listener* listener) override; | 62 void AddListener(Listener* listener) override; |
| 67 void RemoveListener(Listener* listener) override; | 63 void RemoveListener(Listener* listener) override; |
| 68 | 64 |
| 69 // Blocks the calling thread until a connection to the spawning shell is | |
| 70 // established, an Application request from it is bound, and the Initialize() | |
| 71 // method on that application is called. | |
| 72 void WaitForShell(mojo::ScopedMessagePipeHandle handle); | |
| 73 | |
| 74 bool external_; | 65 bool external_; |
| 75 bool initialized_; | 66 scoped_ptr<mojo::ShellConnection> shell_connection_; |
| 76 scoped_ptr<mojo::shell::RunnerConnection> runner_connection_; | 67 scoped_ptr<mojo::shell::RunnerConnection> runner_connection_; |
| 77 scoped_ptr<mojo::ShellConnection> shell_connection_; | |
| 78 std::vector<Listener*> listeners_; | 68 std::vector<Listener*> listeners_; |
| 79 | 69 |
| 80 DISALLOW_COPY_AND_ASSIGN(MojoShellConnectionImpl); | 70 DISALLOW_COPY_AND_ASSIGN(MojoShellConnectionImpl); |
| 81 }; | 71 }; |
| 82 | 72 |
| 83 } // namespace content | 73 } // namespace content |
| 84 | 74 |
| 85 #endif // CONTENT_COMMON_MOJO_SHELL_CONNECTION_IMPL_H_ | 75 #endif // CONTENT_COMMON_MOJO_SHELL_CONNECTION_IMPL_H_ |
| OLD | NEW |