LCOV - code coverage report
Current view: directory - src/trusted/sel_universal - rpc_universal.h (source / functions) Found Hit Coverage
Test: coverage.lcov Lines: 2 2 100.0 %
Date: 2014-06-18 Functions: 0 0 -

       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                 : #ifndef NATIVE_CLIENT_SRC_TRUSTED_SEL_UNIVERSAL_RPC_UNIVERSAL_H_
       8                 : #define NATIVE_CLIENT_SRC_TRUSTED_SEL_UNIVERSAL_RPC_UNIVERSAL_H_
       9                 : 
      10                 : #include "native_client/src/shared/srpc/nacl_srpc.h"
      11                 : 
      12                 : #include <map>
      13                 : #include <string>
      14                 : #include <vector>
      15                 : 
      16                 : using std::map;
      17                 : using std::string;
      18                 : using std::vector;
      19                 : 
      20                 : class NaClCommandLoop;
      21                 : typedef bool (*CommandHandler)(NaClCommandLoop* ncl,
      22                 :                                const vector<string>& args);
      23                 : 
      24                 : class NaClCommandLoop {
      25                 :  public:
      26                 :   NaClCommandLoop(NaClSrpcService* service,
      27                 :                   NaClSrpcChannel* channel,
      28                 :                   NaClSrpcImcDescType default_socket_address);
      29                 :   ~NaClCommandLoop();
      30                 : 
      31                 :   void SetVariable(string name, string value);
      32                 :   string GetVariable(string name) const;
      33                 :   void RegisterNonDeterministicOutput(string content, string name);
      34                 :   void AddHandler(string name, CommandHandler handler);
      35                 :   void AddDesc(NaClDesc* desc, string name);
      36                 :   void AddUpcallRpc(string signature, NaClSrpcMethod rpc);
      37                 :   void AddUpcallRpcSecondary(string signature, NaClSrpcMethod rpc);
      38                 :   string AddDescUniquify(NaClDesc* desc, string prefix);
      39                 :   NaClSrpcImcDescType FindDescByName(string name) const;
      40              45 :   NaClSrpcService* getService() const { return service_; }
      41              45 :   NaClSrpcChannel* getChannel() const { return channel_; }
      42                 :   void DumpArgsAndResults(NaClSrpcArg* inv[], NaClSrpcArg* outv[]);
      43                 :   bool InvokeNexeRpc(string signature, NaClSrpcArg** in, NaClSrpcArg** out);
      44                 : 
      45                 :   int ProcessOneCommand(const string command);
      46                 :   bool StartInteractiveLoop(bool abort_on_error);
      47                 :   bool ProcessCommands(const vector<string>& commands);
      48                 : 
      49                 :  private:
      50                 :   // Note, most handlers are not even class members, the ones below
      51                 :   // need to access to certain private class members
      52                 :   static bool HandleShowDescriptors(NaClCommandLoop* ncl,
      53                 :                                     const vector<string>& args);
      54                 :   static bool HandleShowVariables(NaClCommandLoop* ncl,
      55                 :                                   const vector<string>& args);
      56                 :   static bool HandleSetVariable(NaClCommandLoop* ncl,
      57                 :                                   const vector<string>& args);
      58                 :   static bool HandleInstallUpcalls(NaClCommandLoop* ncl,
      59                 :                                    const vector<string>& args);
      60                 :   static bool HandleNondeterministic(NaClCommandLoop* ncl,
      61                 :                                      const vector<string>& args);
      62                 :   static bool HandleEcho(NaClCommandLoop* ncl,
      63                 :                          const vector<string>& args);
      64                 :   static bool HandleShutdown(NaClCommandLoop* nacl,
      65                 :                              const vector<string>& args);
      66                 : 
      67                 :   int desc_count_;
      68                 :   NaClSrpcService* service_;
      69                 :   NaClSrpcChannel* channel_;
      70                 : 
      71                 :   // map names to content
      72                 :   map<string, string> vars_;
      73                 :   // map non-determinisic content into deterministic names
      74                 :   map<string, string> nondeterministic_;
      75                 :   // map names to descriptors
      76                 :   map<string, NaClSrpcImcDescType> descs_;
      77                 :   map<string, CommandHandler> handlers_;
      78                 :   map<string, NaClSrpcMethod> upcall_rpcs_;
      79                 :   map<string, NaClSrpcMethod> upcall_rpcs_secondary_;
      80                 :   bool upcall_installed_;
      81                 : };
      82                 : 
      83                 : // possibly platform dependent stuff (c.f. rpc_universal_system.cc)
      84                 : bool HandlerSleep(NaClCommandLoop* ncl, const vector<string>& args);
      85                 : bool HandlerReadonlyFile(NaClCommandLoop* ncl, const vector<string>& args);
      86                 : bool HandlerReadwriteFile(NaClCommandLoop* ncl, const vector<string>& args);
      87                 : bool HandlerReadwriteFileQuota(NaClCommandLoop* ncl,
      88                 :                                const vector<string>& args);
      89                 : bool HandlerShmem(NaClCommandLoop* ncl, const vector<string>& args);
      90                 : bool HandlerMap(NaClCommandLoop* ncl, const vector<string>& args);
      91                 : bool HandlerSaveToFile(NaClCommandLoop* ncl, const vector<string>& args);
      92                 : bool HandlerLoadFromFile(NaClCommandLoop* ncl, const vector<string>& args);
      93                 : bool HandlerFileSize(NaClCommandLoop* ncl, const vector<string>& args);
      94                 : bool HandlerSyncSocketCreate(NaClCommandLoop* ncl,
      95                 :                              const vector<string>& args);
      96                 : bool HandlerSyncSocketWrite(NaClCommandLoop* ncl,
      97                 :                             const vector<string>& args);
      98                 : 
      99                 : #endif  /* NATIVE_CLIENT_SRC_TRUSTED_SEL_UNIVERSAL_RPC_UNIVERSAL_H_ */

Generated by: LCOV version 1.7