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
4 * found in the LICENSE file.
7 // A representation of an SRPC connection. These can be either to the
8 // service runtime or to untrusted NaCl threads.
10 #ifndef NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SRPC_CLIENT_H_
11 #define NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SRPC_CLIENT_H_
14 #include "native_client/src/include/nacl_macros.h"
15 #include "native_client/src/include/nacl_string.h"
16 #include "native_client/src/shared/srpc/nacl_srpc.h"
17 #include "ppapi/native_client/src/trusted/plugin/utility.h"
30 // SrpcClient represents an SRPC connection to a client.
33 // Factory method for creating SrpcClients.
34 static SrpcClient
* New(nacl::DescWrapper
* wrapper
);
36 // Init is passed a DescWrapper. The SrpcClient performs service
37 // discovery and provides the interface for future rpcs.
38 bool Init(nacl::DescWrapper
* socket
);
40 // The destructor closes the connection to sel_ldr.
43 // Test whether the SRPC service has a given method.
44 bool HasMethod(const nacl::string
& method_name
);
45 // Invoke an SRPC method.
46 bool Invoke(const nacl::string
& method_name
, SrpcParams
* params
);
47 // Get the error status from that last method invocation
48 NaClSrpcError
GetLastError() { return last_error_
; }
49 bool InitParams(const nacl::string
& method_name
, SrpcParams
* params
);
51 // Attach a service for reverse-direction (from .nexe) RPCs.
52 void AttachService(NaClSrpcService
* service
, void* instance_data
);
55 NACL_DISALLOW_COPY_AND_ASSIGN(SrpcClient
);
58 typedef std::map
<nacl::string
, MethodInfo
*> Methods
;
60 NaClSrpcChannel srpc_channel_
;
61 bool srpc_channel_initialised_
;
62 NaClSrpcError last_error_
;
67 #endif // NATIVE_CLIENT_SRC_TRUSTED_PLUGIN_SRPC_CLIENT_H_