1 // Copyright (c) 2012 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.
5 #ifndef TOOLS_ANDROID_FORWARDER2_FORWARDER_H_
6 #define TOOLS_ANDROID_FORWARDER2_FORWARDER_H_
8 #include <sys/select.h>
10 #include "base/memory/scoped_ptr.h"
11 #include "base/threading/thread_checker.h"
13 namespace forwarder2
{
17 // Internal class that forwards traffic between |socket1| and |socket2|. Note
18 // that this class is not thread-safe.
21 Forwarder(scoped_ptr
<Socket
> socket1
, scoped_ptr
<Socket
> socket2
);
25 void RegisterFDs(fd_set
* read_fds
, fd_set
* write_fds
, int* max_fd
);
27 void ProcessEvents(const fd_set
& read_fds
, const fd_set
& write_fds
);
29 bool IsClosed() const;
36 base::ThreadChecker thread_checker_
;
37 const scoped_ptr
<Socket
> socket1_
;
38 const scoped_ptr
<Socket
> socket2_
;
39 // Copies data from socket1 to socket2.
40 const scoped_ptr
<BufferedCopier
> buffer1_
;
41 // Copies data from socket2 to socket1.
42 const scoped_ptr
<BufferedCopier
> buffer2_
;
45 } // namespace forwarder2
47 #endif // TOOLS_ANDROID_FORWARDER2_FORWARDER_H_