Chromium Code Reviews| 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 // Connects to the shell over a given ShellClientFactory request. If |request| |
| 46 // Initialized() application with a bound ShellPtr. This call is a no-op | 46 // is null, this attempts to extract a request pipe from the command line. |
| 47 // if the connection has already been initialized. | 47 // This must only be called once. |
| 48 void BindToCommandLinePlatformChannel(); | 48 void Connect(mojo::shell::mojom::ShellClientFactoryRequest request); |
|
Ben Goodger (Google)
2016/03/13 04:16:24
I think this name is confusing. Generally we use t
Ken Rockot(use gerrit already)
2016/03/13 16:14:25
I've changed it to BindToRequestFromCommandLine fo
| |
| 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 | 49 |
| 54 private: | 50 private: |
| 55 explicit MojoShellConnectionImpl(bool external); | 51 explicit MojoShellConnectionImpl(bool external); |
| 56 ~MojoShellConnectionImpl() override; | 52 ~MojoShellConnectionImpl() override; |
| 57 | 53 |
| 58 // mojo::ShellClient: | 54 // mojo::ShellClient: |
| 59 void Initialize(mojo::Connector* connector, const mojo::Identity& identity, | 55 void Initialize(mojo::Connector* connector, |
| 56 const mojo::Identity& identity, | |
| 60 uint32_t id) override; | 57 uint32_t id) override; |
| 61 bool AcceptConnection(mojo::Connection* connection) override; | 58 bool AcceptConnection(mojo::Connection* connection) override; |
| 62 | 59 |
| 63 // MojoShellConnection: | 60 // MojoShellConnection: |
| 64 mojo::Connector* GetConnector() override; | 61 mojo::Connector* GetConnector() override; |
| 65 bool UsingExternalShell() const override; | 62 bool UsingExternalShell() const override; |
| 66 void AddListener(Listener* listener) override; | 63 void AddListener(Listener* listener) override; |
| 67 void RemoveListener(Listener* listener) override; | 64 void RemoveListener(Listener* listener) override; |
| 68 | 65 |
| 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_; | 66 bool external_; |
| 75 bool initialized_; | 67 scoped_ptr<mojo::ShellConnection> shell_connection_; |
| 76 scoped_ptr<mojo::shell::RunnerConnection> runner_connection_; | 68 scoped_ptr<mojo::shell::RunnerConnection> runner_connection_; |
| 77 scoped_ptr<mojo::ShellConnection> shell_connection_; | |
| 78 std::vector<Listener*> listeners_; | 69 std::vector<Listener*> listeners_; |
| 79 | 70 |
| 80 DISALLOW_COPY_AND_ASSIGN(MojoShellConnectionImpl); | 71 DISALLOW_COPY_AND_ASSIGN(MojoShellConnectionImpl); |
| 81 }; | 72 }; |
| 82 | 73 |
| 83 } // namespace content | 74 } // namespace content |
| 84 | 75 |
| 85 #endif // CONTENT_COMMON_MOJO_SHELL_CONNECTION_IMPL_H_ | 76 #endif // CONTENT_COMMON_MOJO_SHELL_CONNECTION_IMPL_H_ |
| OLD | NEW |