| 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_PUBLIC_SHELL_APPLICATION_H_ | 5 #ifndef MOJO_PUBLIC_SHELL_APPLICATION_H_ |
| 6 #define MOJO_PUBLIC_SHELL_APPLICATION_H_ | 6 #define MOJO_PUBLIC_SHELL_APPLICATION_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "mojo/public/cpp/bindings/remote_ptr.h" | |
| 11 #include "mojo/public/cpp/shell/service.h" | 10 #include "mojo/public/cpp/shell/service.h" |
| 12 #include "mojo/public/cpp/system/core.h" | 11 #include "mojo/public/cpp/system/core.h" |
| 13 #include "mojo/public/interfaces/shell/shell.mojom.h" | 12 #include "mojo/public/interfaces/shell/shell.mojom.h" |
| 14 | 13 |
| 15 namespace mojo { | 14 namespace mojo { |
| 16 | 15 |
| 17 class Application : public internal::ServiceConnectorBase::Owner { | 16 class Application : public internal::ServiceConnectorBase::Owner { |
| 18 public: | 17 public: |
| 19 explicit Application(ScopedShellHandle shell_handle); | 18 explicit Application(ScopedMessagePipeHandle shell_handle); |
| 20 explicit Application(MojoHandle shell_handle); | 19 explicit Application(MojoHandle shell_handle); |
| 21 virtual ~Application(); | 20 virtual ~Application(); |
| 22 | 21 |
| 23 // internal::ServiceConnectorBase::Owner methods. | 22 // internal::ServiceConnectorBase::Owner methods. |
| 24 // Takes ownership of |service_connector|. | 23 // Takes ownership of |service_connector|. |
| 25 virtual void AddServiceConnector( | 24 virtual void AddServiceConnector( |
| 26 internal::ServiceConnectorBase* service_connector) MOJO_OVERRIDE; | 25 internal::ServiceConnectorBase* service_connector) MOJO_OVERRIDE; |
| 27 virtual void RemoveServiceConnector( | 26 virtual void RemoveServiceConnector( |
| 28 internal::ServiceConnectorBase* service_connector) MOJO_OVERRIDE; | 27 internal::ServiceConnectorBase* service_connector) MOJO_OVERRIDE; |
| 29 | 28 |
| 29 template <typename Interface> |
| 30 void ConnectTo(const std::string& url, InterfacePtr<Interface>* ptr) { |
| 31 mojo::ConnectTo(shell(), url, ptr); |
| 32 } |
| 33 |
| 30 protected: | 34 protected: |
| 31 // ShellClient methods. | 35 // ShellClient methods. |
| 32 virtual void AcceptConnection(const mojo::String& url, | 36 virtual void AcceptConnection(const mojo::String& url, |
| 33 ScopedMessagePipeHandle client_handle) | 37 ScopedMessagePipeHandle client_handle) |
| 34 MOJO_OVERRIDE; | 38 MOJO_OVERRIDE; |
| 35 | 39 |
| 36 private: | 40 private: |
| 37 typedef std::vector<internal::ServiceConnectorBase*> ServiceConnectorList; | 41 typedef std::vector<internal::ServiceConnectorBase*> ServiceConnectorList; |
| 38 ServiceConnectorList service_connectors_; | 42 ServiceConnectorList service_connectors_; |
| 39 }; | 43 }; |
| 40 | 44 |
| 41 } // namespace mojo | 45 } // namespace mojo |
| 42 | 46 |
| 43 #endif // MOJO_PUBLIC_SHELL_APPLICATION_H_ | 47 #endif // MOJO_PUBLIC_SHELL_APPLICATION_H_ |
| OLD | NEW |