OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef TOOLS_ANDROID_FORWARDER2_FORWARDER_H_ | 5 #ifndef TOOLS_ANDROID_FORWARDER2_FORWARDER_H_ |
6 #define TOOLS_ANDROID_FORWARDER2_FORWARDER_H_ | 6 #define TOOLS_ANDROID_FORWARDER2_FORWARDER_H_ |
7 | 7 |
8 #include <sys/select.h> | 8 #include <sys/select.h> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include <memory> |
| 11 |
11 #include "base/threading/thread_checker.h" | 12 #include "base/threading/thread_checker.h" |
12 | 13 |
13 namespace forwarder2 { | 14 namespace forwarder2 { |
14 | 15 |
15 class Socket; | 16 class Socket; |
16 | 17 |
17 // Internal class that forwards traffic between |socket1| and |socket2|. Note | 18 // Internal class that forwards traffic between |socket1| and |socket2|. Note |
18 // that this class is not thread-safe. | 19 // that this class is not thread-safe. |
19 class Forwarder { | 20 class Forwarder { |
20 public: | 21 public: |
21 Forwarder(scoped_ptr<Socket> socket1, scoped_ptr<Socket> socket2); | 22 Forwarder(std::unique_ptr<Socket> socket1, std::unique_ptr<Socket> socket2); |
22 | 23 |
23 ~Forwarder(); | 24 ~Forwarder(); |
24 | 25 |
25 void RegisterFDs(fd_set* read_fds, fd_set* write_fds, int* max_fd); | 26 void RegisterFDs(fd_set* read_fds, fd_set* write_fds, int* max_fd); |
26 | 27 |
27 void ProcessEvents(const fd_set& read_fds, const fd_set& write_fds); | 28 void ProcessEvents(const fd_set& read_fds, const fd_set& write_fds); |
28 | 29 |
29 bool IsClosed() const; | 30 bool IsClosed() const; |
30 | 31 |
31 void Shutdown(); | 32 void Shutdown(); |
32 | 33 |
33 private: | 34 private: |
34 class BufferedCopier; | 35 class BufferedCopier; |
35 | 36 |
36 base::ThreadChecker thread_checker_; | 37 base::ThreadChecker thread_checker_; |
37 const scoped_ptr<Socket> socket1_; | 38 const std::unique_ptr<Socket> socket1_; |
38 const scoped_ptr<Socket> socket2_; | 39 const std::unique_ptr<Socket> socket2_; |
39 // Copies data from socket1 to socket2. | 40 // Copies data from socket1 to socket2. |
40 const scoped_ptr<BufferedCopier> buffer1_; | 41 const std::unique_ptr<BufferedCopier> buffer1_; |
41 // Copies data from socket2 to socket1. | 42 // Copies data from socket2 to socket1. |
42 const scoped_ptr<BufferedCopier> buffer2_; | 43 const std::unique_ptr<BufferedCopier> buffer2_; |
43 }; | 44 }; |
44 | 45 |
45 } // namespace forwarder2 | 46 } // namespace forwarder2 |
46 | 47 |
47 #endif // TOOLS_ANDROID_FORWARDER2_FORWARDER_H_ | 48 #endif // TOOLS_ANDROID_FORWARDER2_FORWARDER_H_ |
OLD | NEW |