| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 * Copyright (c) 2011 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 NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SRPC_CLIENT_H_ | 10 #ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SRPC_CLIENT_H_ |
| 11 #define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SRPC_CLIENT_H_ | 11 #define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SRPC_CLIENT_H_ |
| 12 | 12 |
| 13 #include <map> | 13 #include <map> |
| 14 #include "native_client/src/include/nacl_macros.h" | 14 #include "native_client/src/include/nacl_macros.h" |
| 15 #include "native_client/src/include/nacl_string.h" | 15 #include "native_client/src/include/nacl_string.h" |
| 16 #include "native_client/src/trusted/plugin/utility.h" | 16 #include "native_client/src/trusted/plugin/utility.h" |
| 17 #include "native_client/src/shared/srpc/nacl_srpc.h" | 17 #include "native_client/src/shared/srpc/nacl_srpc.h" |
| 18 | 18 |
| 19 namespace nacl { | 19 namespace nacl { |
| 20 class DescWrapper; | 20 class DescWrapper; |
| 21 } // namespace nacl | 21 } // namespace nacl |
| 22 | 22 |
| 23 namespace plugin { | 23 namespace plugin { |
| 24 | 24 |
| 25 class BrowserInterface; | |
| 26 class ErrorInfo; | 25 class ErrorInfo; |
| 27 class MethodInfo; | 26 class MethodInfo; |
| 28 class Plugin; | 27 class Plugin; |
| 29 class SrpcParams; | 28 class SrpcParams; |
| 30 | 29 |
| 31 // SrpcClient represents an SRPC connection to a client. | 30 // SrpcClient represents an SRPC connection to a client. |
| 32 class SrpcClient { | 31 class SrpcClient { |
| 33 public: | 32 public: |
| 34 // Factory method for creating SrpcClients. | 33 // Factory method for creating SrpcClients. |
| 35 static SrpcClient* New(Plugin* plugin, nacl::DescWrapper* wrapper); | 34 static SrpcClient* New(nacl::DescWrapper* wrapper); |
| 36 | 35 |
| 37 // Init is passed a DescWrapper. The SrpcClient performs service | 36 // Init is passed a DescWrapper. The SrpcClient performs service |
| 38 // discovery and provides the interface for future rpcs. | 37 // discovery and provides the interface for future rpcs. |
| 39 bool Init(BrowserInterface* browser_interface, nacl::DescWrapper* socket); | 38 bool Init(nacl::DescWrapper* socket); |
| 40 | 39 |
| 41 // The destructor closes the connection to sel_ldr. | 40 // The destructor closes the connection to sel_ldr. |
| 42 ~SrpcClient(); | 41 ~SrpcClient(); |
| 43 | 42 |
| 44 bool StartJSObjectProxy(Plugin* plugin, ErrorInfo* error_info); | 43 bool StartJSObjectProxy(Plugin* plugin, ErrorInfo* error_info); |
| 45 // Test whether the SRPC service has a given method. | 44 // Test whether the SRPC service has a given method. |
| 46 bool HasMethod(uintptr_t method_id); | 45 bool HasMethod(const nacl::string& method_name); |
| 47 // Invoke an SRPC method. | 46 // Invoke an SRPC method. |
| 48 bool Invoke(uintptr_t method_id, SrpcParams* params); | 47 bool Invoke(const nacl::string& method_name, SrpcParams* params); |
| 49 bool InitParams(uintptr_t method_id, SrpcParams* params); | 48 bool InitParams(const nacl::string& method_name, SrpcParams* params); |
| 50 | 49 |
| 51 // Attach a service for reverse-direction (from .nexe) RPCs. | 50 // Attach a service for reverse-direction (from .nexe) RPCs. |
| 52 void AttachService(NaClSrpcService* service, void* instance_data); | 51 void AttachService(NaClSrpcService* service, void* instance_data); |
| 53 | 52 |
| 54 private: | 53 private: |
| 55 NACL_DISALLOW_COPY_AND_ASSIGN(SrpcClient); | 54 NACL_DISALLOW_COPY_AND_ASSIGN(SrpcClient); |
| 56 SrpcClient(); | 55 SrpcClient(); |
| 57 void GetMethods(); | 56 void GetMethods(); |
| 58 typedef std::map<uintptr_t, MethodInfo*> Methods; | 57 typedef std::map<nacl::string, MethodInfo*> Methods; |
| 59 Methods methods_; | 58 Methods methods_; |
| 60 NaClSrpcChannel srpc_channel_; | 59 NaClSrpcChannel srpc_channel_; |
| 61 bool srpc_channel_initialised_; | 60 bool srpc_channel_initialised_; |
| 62 BrowserInterface* browser_interface_; | |
| 63 }; | 61 }; |
| 64 | 62 |
| 65 } // namespace plugin | 63 } // namespace plugin |
| 66 | 64 |
| 67 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SRPC_CLIENT_H_ | 65 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SRPC_CLIENT_H_ |
| OLD | NEW |