LCOV - code coverage report
Current view: directory - src/trusted/debug_stub - transport.h (source / functions) Found Hit Coverage
Test: coverage.lcov Lines: 1 1 100.0 %
Date: 2014-09-25 Functions: 0 0 -

       1                 : /*
       2                 :  * Copyright (c) 2010 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                 : 
       8                 : // This module provides interfaces for an IO stream.  The stream is
       9                 : // expected to throw a std::exception if the stream is terminated on
      10                 : // either side.
      11                 : #ifndef NATIVE_CLIENT_PORT_TRANSPORT_H_
      12                 : #define NATIVE_CLIENT_PORT_TRANSPORT_H_
      13                 : 
      14                 : #include "native_client/src/include/portability.h"
      15                 : #include "native_client/src/include/portability_sockets.h"
      16                 : 
      17                 : struct NaClApp;
      18                 : 
      19                 : namespace port {
      20                 : 
      21                 : class ITransport {
      22                 :  public:
      23               1 :   virtual ~ITransport() {}  // Allow to delete using base pointer
      24                 : 
      25                 :   // Read from this transport, return true on success.
      26                 :   virtual bool Read(void *ptr, int32_t len) = 0;
      27                 : 
      28                 :   // Write to this transport, return true on success.
      29                 :   virtual bool Write(const void *ptr, int32_t len)  = 0;
      30                 : 
      31                 :   // Return true if there is data to read.
      32                 :   virtual bool IsDataAvailable() = 0;
      33                 : 
      34                 :   // Wait until there is input from GDB or some NaCl thread is faulted.
      35                 :   virtual void WaitForDebugStubEvent(struct NaClApp *nap,
      36                 :                                      bool ignore_gdb) = 0;
      37                 : 
      38                 :   // Disconnect the transport, R/W and Select will now throw an exception
      39                 :   virtual void Disconnect() = 0;
      40                 : };
      41                 : 
      42                 : class SocketBinding {
      43                 :  public:
      44                 :   // Wrap existing socket handle.
      45                 :   explicit SocketBinding(NaClSocketHandle socket_handle);
      46                 :   // Bind to the specified TCP port.
      47                 :   static SocketBinding *Bind(const char *addr);
      48                 : 
      49                 :   // Accept a connection on an already-bound TCP port.
      50                 :   ITransport *AcceptConnection();
      51                 : 
      52                 :   // Get port the socket is bound to.
      53                 :   uint16_t GetBoundPort();
      54                 : 
      55                 :  private:
      56                 :   NaClSocketHandle socket_handle_;
      57                 : };
      58                 : 
      59                 : }  // namespace port
      60                 : 
      61                 : #endif  // NATIVE_CLIENT_PORT_TRANSPORT_H_
      62                 : 

Generated by: LCOV version 1.7