Chromium Code Reviews| 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_APPLICATION_APPLICATION_IMPL_H_ | 5 #ifndef MOJO_PUBLIC_APPLICATION_APPLICATION_IMPL_H_ |
| 6 #define MOJO_PUBLIC_APPLICATION_APPLICATION_IMPL_H_ | 6 #define MOJO_PUBLIC_APPLICATION_APPLICATION_IMPL_H_ |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "mojo/public/cpp/application/application_connection.h" | 9 #include "mojo/public/cpp/application/application_connection.h" |
| 10 #include "mojo/public/cpp/application/lib/service_connector.h" | 10 #include "mojo/public/cpp/application/lib/service_connector.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 53 class ApplicationImpl : public InterfaceImpl<Application> { | 53 class ApplicationImpl : public InterfaceImpl<Application> { |
| 54 public: | 54 public: |
| 55 ApplicationImpl(ApplicationDelegate* delegate, | 55 ApplicationImpl(ApplicationDelegate* delegate, |
| 56 ScopedMessagePipeHandle shell_handle); | 56 ScopedMessagePipeHandle shell_handle); |
| 57 ApplicationImpl(ApplicationDelegate* delegate, | 57 ApplicationImpl(ApplicationDelegate* delegate, |
| 58 MojoHandle shell_handle); | 58 MojoHandle shell_handle); |
| 59 virtual ~ApplicationImpl(); | 59 virtual ~ApplicationImpl(); |
| 60 | 60 |
| 61 Shell* shell() const { return shell_.get(); } | 61 Shell* shell() const { return shell_.get(); } |
| 62 | 62 |
| 63 const Array<String>& args() { return args_; } | |
|
viettrungluu
2014/09/15 17:26:18
Needs comment.
DaveMoore
2014/09/15 22:35:08
Done.
| |
| 64 | |
| 63 // Establishes a new connection to an application. Caller does not own. | 65 // Establishes a new connection to an application. Caller does not own. |
| 64 ApplicationConnection* ConnectToApplication(const String& application_url); | 66 ApplicationConnection* ConnectToApplication(const String& application_url); |
| 65 | 67 |
| 66 // Connect to application identified by |application_url| and connect to the | 68 // Connect to application identified by |application_url| and connect to the |
| 67 // service implementation of the interface identified by |Interface|. | 69 // service implementation of the interface identified by |Interface|. |
| 68 template <typename Interface> | 70 template <typename Interface> |
| 69 void ConnectToService(const std::string& application_url, | 71 void ConnectToService(const std::string& application_url, |
| 70 InterfacePtr<Interface>* ptr) { | 72 InterfacePtr<Interface>* ptr) { |
| 71 ConnectToApplication(application_url)->ConnectToService(ptr); | 73 ConnectToApplication(application_url)->ConnectToService(ptr); |
| 72 } | 74 } |
| 73 | 75 |
| 74 private: | 76 private: |
| 75 class ShellPtrWatcher; | 77 class ShellPtrWatcher; |
| 76 | 78 |
| 77 void BindShell(ScopedMessagePipeHandle shell_handle); | 79 void BindShell(ScopedMessagePipeHandle shell_handle); |
| 78 void ClearConnections(); | 80 void ClearConnections(); |
| 79 void OnShellError() { | 81 void OnShellError() { |
| 80 ClearConnections(); | 82 ClearConnections(); |
| 81 Terminate(); | 83 Terminate(); |
| 82 }; | 84 }; |
| 83 | 85 |
| 84 // Quits the main run loop for this application. | 86 // Quits the main run loop for this application. |
| 85 static void Terminate(); | 87 static void Terminate(); |
| 86 | 88 |
| 87 // Application implementation. | 89 // Application implementation. |
| 90 virtual void Initialize(Array<String> args) MOJO_OVERRIDE; | |
| 88 virtual void AcceptConnection(const String& requestor_url, | 91 virtual void AcceptConnection(const String& requestor_url, |
| 89 ServiceProviderPtr provider) MOJO_OVERRIDE; | 92 ServiceProviderPtr provider) MOJO_OVERRIDE; |
| 90 | 93 |
| 91 typedef std::vector<internal::ServiceRegistry*> ServiceRegistryList; | 94 typedef std::vector<internal::ServiceRegistry*> ServiceRegistryList; |
| 95 | |
| 96 bool initialized_; | |
| 92 ServiceRegistryList incoming_service_registries_; | 97 ServiceRegistryList incoming_service_registries_; |
| 93 ServiceRegistryList outgoing_service_registries_; | 98 ServiceRegistryList outgoing_service_registries_; |
| 94 ApplicationDelegate* delegate_; | 99 ApplicationDelegate* delegate_; |
| 95 ShellPtr shell_; | 100 ShellPtr shell_; |
| 96 ShellPtrWatcher* shell_watch_; | 101 ShellPtrWatcher* shell_watch_; |
| 102 Array<String> args_; | |
| 97 | 103 |
| 98 MOJO_DISALLOW_COPY_AND_ASSIGN(ApplicationImpl); | 104 MOJO_DISALLOW_COPY_AND_ASSIGN(ApplicationImpl); |
| 99 }; | 105 }; |
| 100 | 106 |
| 101 } // namespace mojo | 107 } // namespace mojo |
| 102 | 108 |
| 103 #endif // MOJO_PUBLIC_APPLICATION_APPLICATION_IMPL_H_ | 109 #endif // MOJO_PUBLIC_APPLICATION_APPLICATION_IMPL_H_ |
| OLD | NEW |