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