Home | History | Annotate | Download | only in flip_server
      1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #ifndef NET_TOOLS_FLIP_SERVER_SM_INTERFACE_H_
      6 #define NET_TOOLS_FLIP_SERVER_SM_INTERFACE_H_
      7 
      8 // State Machine Interfaces
      9 
     10 #include <string>
     11 
     12 #include "net/tools/flip_server/balsa_headers.h"
     13 
     14 namespace net {
     15 
     16 class EpollServer;
     17 class SMConnectionPoolInterface;
     18 class SMConnection;
     19 
     20 class SMInterface {
     21  public:
     22   virtual void InitSMInterface(SMInterface* sm_other_interface,
     23                                int32 server_idx) = 0;
     24   virtual void InitSMConnection(SMConnectionPoolInterface* connection_pool,
     25                                 SMInterface* sm_interface,
     26                                 EpollServer* epoll_server,
     27                                 int fd,
     28                                 std::string server_ip,
     29                                 std::string server_port,
     30                                 std::string remote_ip,
     31                                 bool use_ssl)  = 0;
     32   virtual size_t ProcessReadInput(const char* data, size_t len) = 0;
     33   virtual size_t ProcessWriteInput(const char* data, size_t len) = 0;
     34   virtual void SetStreamID(uint32 stream_id) = 0;
     35   virtual bool MessageFullyRead() const = 0;
     36   virtual bool Error() const = 0;
     37   virtual const char* ErrorAsString() const = 0;
     38   virtual void Reset() = 0;
     39   virtual void ResetForNewInterface(int32 server_idx) = 0;
     40   // ResetForNewConnection is used for interfaces which control SMConnection
     41   // objects. When called an interface may put its connection object into
     42   // a reusable instance pool. Currently this is what the HttpSM interface
     43   // does.
     44   virtual void ResetForNewConnection() = 0;
     45   virtual void Cleanup() = 0;
     46 
     47   virtual int PostAcceptHook() = 0;
     48 
     49   virtual void NewStream(uint32 stream_id, uint32 priority,
     50                          const std::string& filename) = 0;
     51   virtual void SendEOF(uint32 stream_id) = 0;
     52   virtual void SendErrorNotFound(uint32 stream_id) = 0;
     53   virtual size_t SendSynStream(uint32 stream_id,
     54                               const BalsaHeaders& headers) = 0;
     55   virtual size_t SendSynReply(uint32 stream_id,
     56                               const BalsaHeaders& headers) = 0;
     57   virtual void SendDataFrame(uint32 stream_id, const char* data, int64 len,
     58                              uint32 flags, bool compress) = 0;
     59   virtual void GetOutput() = 0;
     60   virtual void set_is_request() = 0;
     61 
     62   virtual ~SMInterface() {}
     63 };
     64 
     65 class SMConnectionInterface {
     66  public:
     67    virtual ~SMConnectionInterface() {}
     68    virtual void ReadyToSend() = 0;
     69    virtual EpollServer* epoll_server() = 0;
     70 };
     71 
     72 class SMConnectionPoolInterface {
     73  public:
     74   virtual ~SMConnectionPoolInterface() {}
     75   virtual void SMConnectionDone(SMConnection* connection) = 0;
     76 };
     77 
     78 }  // namespace net
     79 
     80 #endif  // NET_TOOLS_FLIP_SERVER_SM_INTERFACE_H_
     81 
     82