OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright (c) 2011 The Native Client Authors. All rights reserved. | |
3 * Use of this source code is governed by a BSD-style license that can be | |
4 * found in the LICENSE file. | |
5 */ | |
6 | |
7 // A representation of an SRPC connection. These can be either to the | |
8 // service runtime or to untrusted NaCl threads. | |
9 | |
10 #ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SRPC_CLIENT_H_ | |
11 #define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SRPC_CLIENT_H_ | |
12 | |
13 #include <map> | |
14 #include "native_client/src/include/nacl_macros.h" | |
15 #include "native_client/src/include/nacl_string.h" | |
16 #include "native_client/src/trusted/plugin/utility.h" | |
17 #include "native_client/src/shared/srpc/nacl_srpc.h" | |
18 | |
19 namespace nacl { | |
20 class DescWrapper; | |
21 } // namespace nacl | |
22 | |
23 namespace plugin { | |
24 | |
25 class BrowserInterface; | |
26 class ErrorInfo; | |
27 class MethodInfo; | |
28 class Plugin; | |
29 class SrpcParams; | |
30 | |
31 // SrpcClient represents an SRPC connection to a client. | |
32 class SrpcClient { | |
33 public: | |
34 // Factory method for creating SrpcClients. | |
35 static SrpcClient* New(Plugin* plugin, nacl::DescWrapper* wrapper); | |
36 | |
37 // Init is passed a DescWrapper. The SrpcClient performs service | |
38 // discovery and provides the interface for future rpcs. | |
39 bool Init(BrowserInterface* browser_interface, nacl::DescWrapper* socket); | |
40 | |
41 // The destructor closes the connection to sel_ldr. | |
42 ~SrpcClient(); | |
43 | |
44 bool StartJSObjectProxy(Plugin* plugin, ErrorInfo* error_info); | |
45 // Test whether the SRPC service has a given method. | |
46 bool HasMethod(uintptr_t method_id); | |
47 // Invoke an SRPC method. | |
48 bool Invoke(uintptr_t method_id, SrpcParams* params); | |
49 bool InitParams(uintptr_t method_id, SrpcParams* params); | |
50 | |
51 private: | |
52 NACL_DISALLOW_COPY_AND_ASSIGN(SrpcClient); | |
53 SrpcClient(); | |
54 void GetMethods(); | |
55 typedef std::map<uintptr_t, MethodInfo*> Methods; | |
56 Methods methods_; | |
57 NaClSrpcChannel srpc_channel_; | |
58 bool srpc_channel_initialised_; | |
59 BrowserInterface* browser_interface_; | |
60 }; | |
61 | |
62 } // namespace plugin | |
63 | |
64 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SRPC_CLIENT_H_ | |
OLD | NEW |