summaryrefslogtreecommitdiffstats
path: root/remoting/protocol/socket_reader_base.h
blob: 3877f13dbf0ab3a9de7f09b74ba1c0a10430cd56 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef REMOTING_PROTOCOL_SOCKET_READER_BASE_H_
#define REMOTING_PROTOCOL_SOCKET_READER_BASE_H_

#include "base/memory/ref_counted.h"
#include "net/base/completion_callback.h"

namespace net {
class IOBuffer;
class Socket;
}  // namespace net

namespace remoting {

class SocketReaderBase {
 public:
  SocketReaderBase();
  virtual ~SocketReaderBase();

 protected:
  void Init(net::Socket* socket);
  virtual void OnDataReceived(net::IOBuffer* buffer, int data_size) = 0;

 private:
  void DoRead();
  void OnRead(int result);
  void HandleReadResult(int result);

  net::Socket* socket_;
  bool closed_;
  scoped_refptr<net::IOBuffer> read_buffer_;
};

}  // namespace remoting

#endif  // REMOTING_PROTOCOL_SOCKET_READER_BASE_H_