| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_PUBLIC_CPP_SHELL_CONNECTION_H_ | 5 #ifndef MOJO_SHELL_PUBLIC_CPP_SHELL_CONNECTION_H_ |
| 6 #define MOJO_SHELL_PUBLIC_CPP_SHELL_CONNECTION_H_ | 6 #define MOJO_SHELL_PUBLIC_CPP_SHELL_CONNECTION_H_ |
| 7 | 7 |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 // - In an implementation of mojo::shell::mojom::ContentHandler to bind the | 36 // - In an implementation of mojo::shell::mojom::ContentHandler to bind the |
| 37 // mojo::shell::mojom::ShellClientRequest passed via StartApplication. In this | 37 // mojo::shell::mojom::ShellClientRequest passed via StartApplication. In this |
| 38 // scenario there can be many instances of this class per process. | 38 // scenario there can be many instances of this class per process. |
| 39 // | 39 // |
| 40 // Instances of this class are constructed with an implementation of the Shell | 40 // Instances of this class are constructed with an implementation of the Shell |
| 41 // Client Lib's mojo::ShellClient interface. See documentation in shell_client.h | 41 // Client Lib's mojo::ShellClient interface. See documentation in shell_client.h |
| 42 // for details. | 42 // for details. |
| 43 // | 43 // |
| 44 class ShellConnection : public shell::mojom::ShellClient { | 44 class ShellConnection : public shell::mojom::ShellClient { |
| 45 public: | 45 public: |
| 46 // Creates a new ShellConnection to eventually be bound to a | 46 // Creates a new ShellConnection bound to |request|. This connection may be |
| 47 // ShellClientRequest (see BindToRequest()). This connection may be used | 47 // used immediately to make outgoing connections via connector(). Does not |
| 48 // immediately to begin making outgoing connections via connector(). | 48 // take ownership of |client|, which must remain valid for the lifetime of |
| 49 // | 49 // ShellConnection. |
| 50 // Does not take ownership of |client|, which must remain valid for the | |
| 51 // lifetime of ShellConnection. | |
| 52 explicit ShellConnection(mojo::ShellClient* client); | |
| 53 | |
| 54 // Like above but binds to |request| upon construction. | |
| 55 ShellConnection(mojo::ShellClient* client, | 50 ShellConnection(mojo::ShellClient* client, |
| 56 shell::mojom::ShellClientRequest request); | 51 shell::mojom::ShellClientRequest request); |
| 57 | 52 |
| 58 ~ShellConnection() override; | 53 ~ShellConnection() override; |
| 59 | 54 |
| 60 Connector* connector() { return connector_.get(); } | 55 Connector* connector() { return connector_.get(); } |
| 61 | 56 |
| 62 // Binds this ShellConnection to a client request if one was not available at | |
| 63 // construction time. | |
| 64 void BindToRequest(shell::mojom::ShellClientRequest request); | |
| 65 | |
| 66 // TODO(rockot): Remove this once we get rid of app tests. | 57 // TODO(rockot): Remove this once we get rid of app tests. |
| 67 void SetAppTestConnectorForTesting(shell::mojom::ConnectorPtr connector); | 58 void SetAppTestConnectorForTesting(shell::mojom::ConnectorPtr connector); |
| 68 | 59 |
| 69 private: | 60 private: |
| 70 // shell::mojom::ShellClient: | 61 // shell::mojom::ShellClient: |
| 71 void Initialize(shell::mojom::IdentityPtr identity, | 62 void Initialize(shell::mojom::IdentityPtr identity, |
| 72 uint32_t id, | 63 uint32_t id, |
| 73 const InitializeCallback& callback) override; | 64 const InitializeCallback& callback) override; |
| 74 void AcceptConnection( | 65 void AcceptConnection( |
| 75 shell::mojom::IdentityPtr source, | 66 shell::mojom::IdentityPtr source, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 91 mojo::ShellClient* client_; | 82 mojo::ShellClient* client_; |
| 92 Binding<shell::mojom::ShellClient> binding_; | 83 Binding<shell::mojom::ShellClient> binding_; |
| 93 scoped_ptr<Connector> connector_; | 84 scoped_ptr<Connector> connector_; |
| 94 | 85 |
| 95 DISALLOW_COPY_AND_ASSIGN(ShellConnection); | 86 DISALLOW_COPY_AND_ASSIGN(ShellConnection); |
| 96 }; | 87 }; |
| 97 | 88 |
| 98 } // namespace mojo | 89 } // namespace mojo |
| 99 | 90 |
| 100 #endif // MOJO_SHELL_PUBLIC_CPP_SHELL_CONNECTION_H_ | 91 #endif // MOJO_SHELL_PUBLIC_CPP_SHELL_CONNECTION_H_ |
| OLD | NEW |