Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / tools / android / forwarder2 / forwarders_manager.h
blob4c6dea6797622e7c39ddee204bbd6d211dfdb445
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
3 // found in the LICENSE file.
5 #ifndef TOOLS_ANDROID_FORWARDER2_FORWARDERS_MANAGER_H_
6 #define TOOLS_ANDROID_FORWARDER2_FORWARDERS_MANAGER_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "base/memory/scoped_vector.h"
10 #include "base/threading/thread.h"
11 #include "tools/android/forwarder2/pipe_notifier.h"
13 namespace forwarder2 {
15 class Forwarder;
16 class Socket;
18 // Creates, owns and notifies Forwarder instances on its own internal thread.
19 class ForwardersManager {
20 public:
21 ForwardersManager();
23 // Must be called on the thread the constructor was called on.
24 ~ForwardersManager();
26 // Can be called on any thread.
27 void CreateAndStartNewForwarder(scoped_ptr<Socket> socket1,
28 scoped_ptr<Socket> socket2);
30 private:
31 void CreateNewForwarderOnInternalThread(scoped_ptr<Socket> socket1,
32 scoped_ptr<Socket> socket2);
34 void WaitForEventsOnInternalThreadSoon();
35 void WaitForEventsOnInternalThread();
37 ScopedVector<Forwarder> forwarders_;
38 PipeNotifier deletion_notifier_;
39 PipeNotifier wakeup_notifier_;
40 base::Thread thread_;
43 } // namespace forwarder2
45 #endif // TOOLS_ANDROID_FORWARDER2_FORWARDERS_MANAGER_H_