OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright 2008 The Native Client Authors. All rights reserved. | |
3 * Use of this source code is governed by a BSD-style license that can | |
4 * be found in the LICENSE file. | |
5 */ | |
6 | |
7 // A class containing information regarding a socket connection to a | |
8 // service runtime instance. | |
9 | |
10 #ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SRPC_SERVICE_RUNTIME_H_ | |
11 #define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SRPC_SERVICE_RUNTIME_H_ | |
12 | |
13 #include "native_client/src/include/nacl_macros.h" | |
14 #include "native_client/src/include/nacl_string.h" | |
15 #include "native_client/src/shared/imc/nacl_imc.h" | |
16 #include "native_client/src/trusted/plugin/srpc/utility.h" | |
17 | |
18 namespace nacl { | |
19 class DescWrapper; | |
20 struct SelLdrLauncher; | |
21 } // namespace | |
22 | |
23 | |
24 namespace plugin { | |
25 | |
26 class BrowserInterface; | |
27 class ConnectedSocket; | |
28 class Plugin; | |
29 class SocketAddress; | |
30 class SrtSocket; | |
31 class ScriptableHandle; | |
32 | |
33 // ServiceRuntime abstracts a NativeClient sel_ldr instance. | |
34 class ServiceRuntime { | |
35 public: | |
36 // TODO(sehr): This class should also implement factory methods, using the | |
37 // current contents of the Start methods below. | |
38 ServiceRuntime(BrowserInterface* browser_interface, Plugin* plugin); | |
39 // The destructor terminates the sel_ldr process. | |
40 ~ServiceRuntime(); | |
41 | |
42 // The constructor is passed the name of the nacl_file (from the | |
43 // browser cache, typically). It spawns a sel_ldr instance and establishes | |
44 // a ConnectedSocket to it. | |
45 bool Start(const char* nacl_file); | |
46 bool Start(const char* url, nacl::DescWrapper *); | |
47 | |
48 bool Kill(); | |
49 bool Log(int severity, nacl::string msg); | |
50 ScriptableHandle* default_socket_address() const; | |
51 ScriptableHandle* default_socket() const; | |
52 ScriptableHandle* GetSocketAddress(Plugin* plugin, nacl::Handle channel); | |
53 Plugin* plugin() const { return plugin_; } | |
54 void Shutdown(); | |
55 | |
56 // We need two IMC sockets rather than one because IMC sockets are | |
57 // not full-duplex on Windows. | |
58 // See http://code.google.com/p/nativeclient/issues/detail?id=690. | |
59 // TODO(mseaborn): We should not have to work around this. | |
60 nacl::DescWrapper* async_receive_desc; | |
61 nacl::DescWrapper* async_send_desc; | |
62 | |
63 private: | |
64 NACL_DISALLOW_COPY_AND_ASSIGN(ServiceRuntime); | |
65 bool InitCommunication(nacl::DescWrapper*); | |
66 BrowserInterface* browser_interface_; | |
67 ScriptableHandle* default_socket_address_; | |
68 ScriptableHandle* default_socket_; | |
69 Plugin* plugin_; | |
70 SrtSocket* runtime_channel_; | |
71 nacl::SelLdrLauncher* subprocess_; | |
72 }; | |
73 | |
74 } // namespace plugin | |
75 | |
76 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SRPC_SERVICE_RUNTIME_H_ | |
OLD | NEW |