summaryrefslogtreecommitdiff
path: root/chromium/net/test/embedded_test_server/embedded_test_server_connection_listener.h
blob: d07dca7e4201d4611b9b9cde81631a70c206172f (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
40
41
42
43
44
// Copyright 2015 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 NET_TEST_EMBEDDED_TEST_SERVER_EMBEDDED_TEST_SERVER_CONNECTION_LISTENER_H_
#define NET_TEST_EMBEDDED_TEST_SERVER_EMBEDDED_TEST_SERVER_CONNECTION_LISTENER_H_

#include <memory>

namespace net {

class StreamSocket;

namespace test_server {

// An interface for connection event notifications.
class EmbeddedTestServerConnectionListener {
 public:
  // Notified when a socket was accepted by the EmbeddedTestServer. The listener
  // can return |socket| or a wrapper to customize the socket behavior.
  virtual std::unique_ptr<StreamSocket> AcceptedSocket(
      std::unique_ptr<StreamSocket> socket) = 0;

  // Notified when a socket was read from by the EmbeddedTestServer.
  virtual void ReadFromSocket(const StreamSocket& socket, int rv) = 0;

  // Notified when the EmbeddedTestServer has completed a request and response
  // successfully on |socket|. The listener can take |socket| to manually handle
  // further traffic on it (for example, if doing a proxy tunnel). Not called if
  // the socket has already been closed by the remote side, since it can't be
  // used to convey data if that happens.
  virtual void OnResponseCompletedSuccessfully(
      std::unique_ptr<StreamSocket> socket) {}

 protected:
  EmbeddedTestServerConnectionListener() {}

  virtual ~EmbeddedTestServerConnectionListener() {}
};

}  // namespace test_server
}  // namespace net

#endif  // NET_TEST_EMBEDDED_TEST_SERVER_EMBEDDED_TEST_SERVER_CONNECTION_LISTENER_H_