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