LCOV - code coverage report
Current view: directory - src/trusted/sel_universal - rpc_universal.h (source / functions) Found Hit Coverage
Test: coverage.lcov Lines: 3 3 100.0 %
Date: 2012-02-16 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              10 : class NaClCommandLoop {
      25                 :  public:
      26                 :   NaClCommandLoop(NaClSrpcService* service,
      27                 :                   NaClSrpcChannel* channel,
      28                 :                   NaClSrpcImcDescType default_socket_address);
      29                 : 
      30                 :   void SetVariable(string name, string value);
      31                 :   string GetVariable(string name) const;
      32                 :   void RegisterNonDeterministicOutput(string content, string name);
      33                 :   void AddHandler(string name, CommandHandler handler);
      34                 :   void AddDesc(NaClDesc* desc, string name);
      35                 :   void AddUpcallRpc(string signature, NaClSrpcMethod rpc);
      36                 :   void AddUpcallRpcSecondary(string signature, NaClSrpcMethod rpc);
      37                 :   string AddDescUniquify(NaClDesc* desc, string prefix);
      38                 :   NaClSrpcImcDescType FindDescByName(string name) const;
      39              47 :   NaClSrpcService* getService() const { return service_; }
      40              47 :   NaClSrpcChannel* getChannel() const { return channel_; }
      41                 :   void DumpArgsAndResults(NaClSrpcArg* inv[], NaClSrpcArg* outv[]);
      42                 :   bool InvokeNexeRpc(string signature, NaClSrpcArg** in, NaClSrpcArg** out);
      43                 : 
      44                 :   int ProcessOneCommand(const string command);
      45                 :   bool StartInteractiveLoop(bool abort_on_error);
      46                 :   bool ProcessCommands(const vector<string>& commands);
      47                 : 
      48                 :  private:
      49                 :   // Note, most handlers are not even class members, the ones below
      50                 :   // need to access to certain private class members
      51                 :   static bool HandleShowDescriptors(NaClCommandLoop* ncl,
      52                 :                                     const vector<string>& args);
      53                 :   static bool HandleShowVariables(NaClCommandLoop* ncl,
      54                 :                                   const vector<string>& args);
      55                 :   static bool HandleSetVariable(NaClCommandLoop* ncl,
      56                 :                                   const vector<string>& args);
      57                 :   static bool HandleInstallUpcalls(NaClCommandLoop* ncl,
      58                 :                                    const vector<string>& args);
      59                 :   static bool HandleNondeterministic(NaClCommandLoop* ncl,
      60                 :                                      const vector<string>& args);
      61                 :   static bool HandleEcho(NaClCommandLoop* ncl,
      62                 :                          const vector<string>& args);
      63                 : 
      64                 :   int desc_count_;
      65                 :   NaClSrpcService* service_;
      66                 :   NaClSrpcChannel* channel_;
      67                 : 
      68                 :   // map names to content
      69                 :   map<string, string> vars_;
      70                 :   // map non-determinisic content into deterministic names
      71                 :   map<string, string> nondeterministic_;
      72                 :   // map names to descriptors
      73                 :   map<string, NaClSrpcImcDescType> descs_;
      74                 :   map<string, CommandHandler> handlers_;
      75                 :   map<string, NaClSrpcMethod> upcall_rpcs_;
      76                 :   map<string, NaClSrpcMethod> upcall_rpcs_secondary_;
      77                 :   bool upcall_installed_;
      78                 : };
      79                 : 
      80                 : // possibly platform dependent stuff (c.f. rpc_universal_system.cc)
      81                 : bool HandlerSleep(NaClCommandLoop* ncl, const vector<string>& args);
      82                 : bool HandlerReadonlyFile(NaClCommandLoop* ncl, const vector<string>& args);
      83                 : bool HandlerReadwriteFile(NaClCommandLoop* ncl, const vector<string>& args);
      84                 : bool HandlerReadwriteFileQuota(NaClCommandLoop* ncl,
      85                 :                                const vector<string>& args);
      86                 : bool HandlerShmem(NaClCommandLoop* ncl, const vector<string>& args);
      87                 : bool HandlerMap(NaClCommandLoop* ncl, const vector<string>& args);
      88                 : bool HandlerSaveToFile(NaClCommandLoop* ncl, const vector<string>& args);
      89                 : bool HandlerLoadFromFile(NaClCommandLoop* ncl, const vector<string>& args);
      90                 : bool HandlerFileSize(NaClCommandLoop* ncl, const vector<string>& args);
      91                 : bool HandlerSyncSocketCreate(NaClCommandLoop* ncl,
      92                 :                              const vector<string>& args);
      93                 : bool HandlerSyncSocketWrite(NaClCommandLoop* ncl,
      94                 :                             const vector<string>& args);
      95                 : 
      96                 : #endif  /* NATIVE_CLIENT_SRC_TRUSTED_SEL_UNIVERSAL_RPC_UNIVERSAL_H_ */

Generated by: LCOV version 1.7