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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 | 63 |
64 // Connect to application identified by |application_url| and connect to the | 64 // Connect to application identified by |application_url| and connect to the |
65 // service implementation of the interface identified by |Interface|. | 65 // service implementation of the interface identified by |Interface|. |
66 template <typename Interface> | 66 template <typename Interface> |
67 void ConnectToService(const std::string& application_url, | 67 void ConnectToService(const std::string& application_url, |
68 InterfacePtr<Interface>* ptr) { | 68 InterfacePtr<Interface>* ptr) { |
69 ConnectToApplication(application_url)->ConnectToService(ptr); | 69 ConnectToApplication(application_url)->ConnectToService(ptr); |
70 } | 70 } |
71 | 71 |
72 private: | 72 private: |
73 class ShellPtrWatcher : public ErrorHandler { | 73 class ShellPtrWatcher; |
74 public: | |
75 explicit ShellPtrWatcher(ApplicationImpl* impl); | |
76 virtual ~ShellPtrWatcher(); | |
77 virtual void OnConnectionError() MOJO_OVERRIDE; | |
78 private: | |
79 ApplicationImpl* impl_; | |
80 MOJO_DISALLOW_COPY_AND_ASSIGN(ShellPtrWatcher); | |
81 }; | |
82 | 74 |
83 void BindShell(ScopedMessagePipeHandle shell_handle); | 75 void BindShell(ScopedMessagePipeHandle shell_handle); |
84 void ClearConnections(); | 76 void ClearConnections(); |
85 void OnShellError() { | 77 void OnShellError() { |
86 ClearConnections(); | 78 ClearConnections(); |
87 Terminate(); | 79 Terminate(); |
88 }; | 80 }; |
89 | 81 |
90 // Quits the main run loop for this application. | 82 // Quits the main run loop for this application. |
91 static void Terminate(); | 83 static void Terminate(); |
92 | 84 |
93 // Application implementation. | 85 // Application implementation. |
94 virtual void AcceptConnection(const String& requestor_url, | 86 virtual void AcceptConnection(const String& requestor_url, |
95 ServiceProviderPtr provider) MOJO_OVERRIDE; | 87 ServiceProviderPtr provider) MOJO_OVERRIDE; |
96 | 88 |
97 typedef std::vector<internal::ServiceRegistry*> ServiceRegistryList; | 89 typedef std::vector<internal::ServiceRegistry*> ServiceRegistryList; |
98 ServiceRegistryList incoming_service_registries_; | 90 ServiceRegistryList incoming_service_registries_; |
99 ServiceRegistryList outgoing_service_registries_; | 91 ServiceRegistryList outgoing_service_registries_; |
100 ApplicationDelegate* delegate_; | 92 ApplicationDelegate* delegate_; |
101 ShellPtr shell_; | 93 ShellPtr shell_; |
102 ShellPtrWatcher shell_watch_; | 94 ShellPtrWatcher* shell_watch_; |
103 | 95 |
104 MOJO_DISALLOW_COPY_AND_ASSIGN(ApplicationImpl); | 96 MOJO_DISALLOW_COPY_AND_ASSIGN(ApplicationImpl); |
105 }; | 97 }; |
106 | 98 |
107 } // namespace mojo | 99 } // namespace mojo |
108 | 100 |
109 #endif // MOJO_PUBLIC_APPLICATION_APPLICATION_IMPL_H_ | 101 #endif // MOJO_PUBLIC_APPLICATION_APPLICATION_IMPL_H_ |
OLD | NEW |