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/application_export.h" | |
10 #include "mojo/public/cpp/application/lib/service_connector.h" | 11 #include "mojo/public/cpp/application/lib/service_connector.h" |
11 #include "mojo/public/cpp/application/lib/service_registry.h" | 12 #include "mojo/public/cpp/application/lib/service_registry.h" |
12 #include "mojo/public/cpp/system/core.h" | 13 #include "mojo/public/cpp/system/core.h" |
13 #include "mojo/public/interfaces/application/application.mojom.h" | 14 #include "mojo/public/interfaces/application/application.mojom.h" |
14 #include "mojo/public/interfaces/application/shell.mojom.h" | 15 #include "mojo/public/interfaces/application/shell.mojom.h" |
15 | 16 |
16 #if defined(WIN32) | |
17 #if !defined(CDECL) | |
18 #define CDECL __cdecl | |
19 #endif | |
20 #define APPLICATION_EXPORT __declspec(dllexport) | |
21 #else | |
22 #define CDECL | |
23 #define APPLICATION_EXPORT __attribute__((visibility("default"))) | |
24 #endif | |
25 | |
26 // DSOs can either implement MojoMain directly or include | |
27 // mojo_main_{standalone|chromium}.cc in their project and implement | |
28 // ApplicationImpl::Create(); | |
29 // TODO(davemoore): Establish this as part of our SDK for third party mojo | |
30 // application writers. | |
31 extern "C" APPLICATION_EXPORT MojoResult CDECL MojoMain( | |
32 MojoHandle service_provider_handle); | |
33 | |
34 namespace mojo { | 17 namespace mojo { |
35 | 18 |
36 class ApplicationDelegate; | 19 class ApplicationDelegate; |
37 | 20 |
38 // Utility class for communicating with the Shell, and providing Services | 21 // Utility class for communicating with the Shell, and providing Services |
39 // to clients. | 22 // to clients. |
40 // | 23 // |
41 // To use define a class that implements your specific server api, e.g. FooImpl | 24 // To use define a class that implements your specific server api, e.g. FooImpl |
42 // to implement a service named Foo. | 25 // to implement a service named Foo. |
43 // That class must subclass an InterfaceImpl specialization. | 26 // That class must subclass an InterfaceImpl specialization. |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
92 class ShellPtrWatcher : public ErrorHandler { | 75 class ShellPtrWatcher : public ErrorHandler { |
93 public: | 76 public: |
94 explicit ShellPtrWatcher(ApplicationImpl* impl); | 77 explicit ShellPtrWatcher(ApplicationImpl* impl); |
95 virtual ~ShellPtrWatcher(); | 78 virtual ~ShellPtrWatcher(); |
96 virtual void OnConnectionError() MOJO_OVERRIDE; | 79 virtual void OnConnectionError() MOJO_OVERRIDE; |
97 private: | 80 private: |
98 ApplicationImpl* impl_; | 81 ApplicationImpl* impl_; |
99 MOJO_DISALLOW_COPY_AND_ASSIGN(ShellPtrWatcher); | 82 MOJO_DISALLOW_COPY_AND_ASSIGN(ShellPtrWatcher); |
100 }; | 83 }; |
101 | 84 |
102 friend MojoResult (::MojoMain)(MojoHandle); | 85 friend MojoResult (::MojoMain)(MojoHandle); |
DaveMoore
2014/08/07 01:54:33
Can this friend declaration go away?
tim (not reviewing)
2014/08/07 17:13:21
Yep. We may also be able to do away with all the
| |
103 | 86 |
104 void BindShell(ScopedMessagePipeHandle shell_handle); | 87 void BindShell(ScopedMessagePipeHandle shell_handle); |
105 void BindShell(MojoHandle shell_handle); | 88 void BindShell(MojoHandle shell_handle); |
106 void ClearConnections(); | 89 void ClearConnections(); |
107 void OnShellError() { ClearConnections(); Terminate(); }; | 90 void OnShellError() { ClearConnections(); Terminate(); }; |
108 | 91 |
109 // Quits the main run loop for this application. | 92 // Quits the main run loop for this application. |
110 void Terminate(); | 93 static void Terminate(); |
111 | 94 |
112 // Application implementation. | 95 // Application implementation. |
113 virtual void AcceptConnection(const String& requestor_url, | 96 virtual void AcceptConnection(const String& requestor_url, |
114 ServiceProviderPtr provider) MOJO_OVERRIDE; | 97 ServiceProviderPtr provider) MOJO_OVERRIDE; |
115 | 98 |
116 typedef std::vector<internal::ServiceRegistry*> ServiceRegistryList; | 99 typedef std::vector<internal::ServiceRegistry*> ServiceRegistryList; |
117 ServiceRegistryList incoming_service_registries_; | 100 ServiceRegistryList incoming_service_registries_; |
118 ServiceRegistryList outgoing_service_registries_; | 101 ServiceRegistryList outgoing_service_registries_; |
119 ApplicationDelegate* delegate_; | 102 ApplicationDelegate* delegate_; |
120 ShellPtr shell_; | 103 ShellPtr shell_; |
121 ShellPtrWatcher shell_watch_; | 104 ShellPtrWatcher shell_watch_; |
122 | 105 |
123 MOJO_DISALLOW_COPY_AND_ASSIGN(ApplicationImpl); | 106 MOJO_DISALLOW_COPY_AND_ASSIGN(ApplicationImpl); |
124 }; | 107 }; |
125 | 108 |
126 } // namespace mojo | 109 } // namespace mojo |
127 | 110 |
128 #endif // MOJO_PUBLIC_APPLICATION_APPLICATION_IMPL_H_ | 111 #endif // MOJO_PUBLIC_APPLICATION_APPLICATION_IMPL_H_ |
OLD | NEW |