| OLD | NEW |
| (Empty) |
| 1 /* | |
| 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. | |
| 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 COMPONENTS_NACL_RENDERER_PLUGIN_SRPC_CLIENT_H_ | |
| 11 #define COMPONENTS_NACL_RENDERER_PLUGIN_SRPC_CLIENT_H_ | |
| 12 | |
| 13 #include <map> | |
| 14 #include <string> | |
| 15 | |
| 16 #include "base/macros.h" | |
| 17 #include "components/nacl/renderer/plugin/utility.h" | |
| 18 #include "native_client/src/include/nacl_macros.h" | |
| 19 #include "native_client/src/shared/srpc/nacl_srpc.h" | |
| 20 | |
| 21 namespace nacl { | |
| 22 class DescWrapper; | |
| 23 } // namespace nacl | |
| 24 | |
| 25 namespace plugin { | |
| 26 | |
| 27 class MethodInfo; | |
| 28 class SrpcParams; | |
| 29 | |
| 30 // SrpcClient represents an SRPC connection to a client. | |
| 31 class SrpcClient { | |
| 32 public: | |
| 33 // Factory method for creating SrpcClients. | |
| 34 static SrpcClient* New(nacl::DescWrapper* wrapper); | |
| 35 | |
| 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); | |
| 39 | |
| 40 // The destructor closes the connection to sel_ldr. | |
| 41 ~SrpcClient(); | |
| 42 | |
| 43 // Test whether the SRPC service has a given method. | |
| 44 bool HasMethod(const std::string& method_name); | |
| 45 // Invoke an SRPC method. | |
| 46 bool Invoke(const std::string& method_name, SrpcParams* params); | |
| 47 // Get the error status from that last method invocation | |
| 48 NaClSrpcError GetLastError() const { return last_error_; } | |
| 49 bool InitParams(const std::string& method_name, SrpcParams* params); | |
| 50 | |
| 51 private: | |
| 52 NACL_DISALLOW_COPY_AND_ASSIGN(SrpcClient); | |
| 53 SrpcClient(); | |
| 54 void GetMethods(); | |
| 55 typedef std::map<std::string, MethodInfo*> Methods; | |
| 56 Methods methods_; | |
| 57 NaClSrpcChannel srpc_channel_; | |
| 58 bool srpc_channel_initialised_; | |
| 59 NaClSrpcError last_error_; | |
| 60 }; | |
| 61 | |
| 62 } // namespace plugin | |
| 63 | |
| 64 #endif // COMPONENTS_NACL_RENDERER_PLUGIN_SRPC_CLIENT_H_ | |
| OLD | NEW |