| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_FORWARDERS_MANAGER_H_ | 5 #ifndef TOOLS_ANDROID_FORWARDER2_FORWARDERS_MANAGER_H_ |
| 6 #define TOOLS_ANDROID_FORWARDER2_FORWARDERS_MANAGER_H_ | 6 #define TOOLS_ANDROID_FORWARDER2_FORWARDERS_MANAGER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <vector> |
| 9 | 10 |
| 10 #include "base/memory/scoped_vector.h" | |
| 11 #include "base/threading/thread.h" | 11 #include "base/threading/thread.h" |
| 12 #include "tools/android/forwarder2/pipe_notifier.h" | 12 #include "tools/android/forwarder2/pipe_notifier.h" |
| 13 | 13 |
| 14 namespace forwarder2 { | 14 namespace forwarder2 { |
| 15 | 15 |
| 16 class Forwarder; | 16 class Forwarder; |
| 17 class Socket; | 17 class Socket; |
| 18 | 18 |
| 19 // Creates, owns and notifies Forwarder instances on its own internal thread. | 19 // Creates, owns and notifies Forwarder instances on its own internal thread. |
| 20 class ForwardersManager { | 20 class ForwardersManager { |
| 21 public: | 21 public: |
| 22 ForwardersManager(); | 22 ForwardersManager(); |
| 23 | 23 |
| 24 // Must be called on the thread the constructor was called on. | 24 // Must be called on the thread the constructor was called on. |
| 25 ~ForwardersManager(); | 25 ~ForwardersManager(); |
| 26 | 26 |
| 27 // Can be called on any thread. | 27 // Can be called on any thread. |
| 28 void CreateAndStartNewForwarder(std::unique_ptr<Socket> socket1, | 28 void CreateAndStartNewForwarder(std::unique_ptr<Socket> socket1, |
| 29 std::unique_ptr<Socket> socket2); | 29 std::unique_ptr<Socket> socket2); |
| 30 | 30 |
| 31 private: | 31 private: |
| 32 void CreateNewForwarderOnInternalThread(std::unique_ptr<Socket> socket1, | 32 void CreateNewForwarderOnInternalThread(std::unique_ptr<Socket> socket1, |
| 33 std::unique_ptr<Socket> socket2); | 33 std::unique_ptr<Socket> socket2); |
| 34 | 34 |
| 35 void WaitForEventsOnInternalThreadSoon(); | 35 void WaitForEventsOnInternalThreadSoon(); |
| 36 void WaitForEventsOnInternalThread(); | 36 void WaitForEventsOnInternalThread(); |
| 37 | 37 |
| 38 ScopedVector<Forwarder> forwarders_; | 38 std::vector<std::unique_ptr<Forwarder>> forwarders_; |
| 39 PipeNotifier deletion_notifier_; | 39 PipeNotifier deletion_notifier_; |
| 40 PipeNotifier wakeup_notifier_; | 40 PipeNotifier wakeup_notifier_; |
| 41 base::Thread thread_; | 41 base::Thread thread_; |
| 42 }; | 42 }; |
| 43 | 43 |
| 44 } // namespace forwarder2 | 44 } // namespace forwarder2 |
| 45 | 45 |
| 46 #endif // TOOLS_ANDROID_FORWARDER2_FORWARDERS_MANAGER_H_ | 46 #endif // TOOLS_ANDROID_FORWARDER2_FORWARDERS_MANAGER_H_ |
| OLD | NEW |