Chromium Code Reviews| Index: tools/android/forwarder2/forwarders_manager.h |
| diff --git a/tools/android/forwarder2/forwarders_manager.h b/tools/android/forwarder2/forwarders_manager.h |
| index 303ec5cdf7708347ad4646b4e86aefd550a40bb0..76efd328e22646729ba359cf7e8aaa4e0c7d313f 100644 |
| --- a/tools/android/forwarder2/forwarders_manager.h |
| +++ b/tools/android/forwarder2/forwarders_manager.h |
| @@ -5,70 +5,35 @@ |
| #ifndef TOOLS_ANDROID_FORWARDER2_FORWARDERS_MANAGER_H_ |
| #define TOOLS_ANDROID_FORWARDER2_FORWARDERS_MANAGER_H_ |
| -#include "base/memory/ref_counted.h" |
| #include "base/memory/scoped_ptr.h" |
| #include "base/memory/scoped_vector.h" |
| +#include "base/threading/thread.h" |
| #include "tools/android/forwarder2/pipe_notifier.h" |
| -namespace base { |
| - |
| -class SingleThreadTaskRunner; |
| - |
| -} // namespace base |
| - |
| namespace forwarder2 { |
| class Forwarder; |
| class Socket; |
| -// Creates and manages lifetime of a set of Forwarder instances. This class |
| -// ensures in particular that the forwarder instances are deleted on their |
| -// construction thread no matter which thread ~ForwardersManager() is called on. |
| class ForwardersManager { |
|
digit1
2014/01/28 17:28:33
what, no doc for this class?. Come on, you can do
Philippe
2014/01/29 10:50:03
Yeah, I kept the comment quite minimalist though :
|
| public: |
| - // Can be called on any thread. |
| ForwardersManager(); |
| ~ForwardersManager(); |
| - // Note that the (unique) thread that this method is called on must outlive |
| - // the ForwardersManager instance. This is needed since the Forwarder |
| - // instances are deleted on the thread they were constructed on. |
| void CreateAndStartNewForwarder(scoped_ptr<Socket> socket1, |
| scoped_ptr<Socket> socket2); |
| private: |
| - // Ref-counted thread-safe delegate that can (by definition) outlive its outer |
| - // ForwarderManager instance. This is needed since the forwarder instances are |
| - // destroyed on a thread other than the one ~ForwardersManager() is called on. |
| - // The forwarder instances can also call OnForwarderError() below at any time |
| - // on their construction thread (which is the same as their destruction |
| - // thread). This means that a WeakPtr to ForwardersManager can't be used |
| - // instead of ref-counting since checking the validity of the WeakPtr on a |
| - // thread other than the one ~ForwardersManager() is called on would be racy. |
| - class Delegate : public base::RefCountedThreadSafe<Delegate> { |
| - public: |
| - Delegate(); |
| - |
| - void Clear(); |
| - |
| - void CreateAndStartNewForwarder(scoped_ptr<Socket> socket1, |
| - scoped_ptr<Socket> socket2); |
| - |
| - private: |
| - friend class base::RefCountedThreadSafe<Delegate>; |
| - |
| - virtual ~Delegate(); |
| - |
| - void OnForwarderError(scoped_ptr<Forwarder> forwarder); |
| - |
| - void ClearOnForwarderConstructorThread(); |
| + void CreateNewForwarderOnInternalThread(scoped_ptr<Socket> socket1, |
| + scoped_ptr<Socket> socket2); |
| - scoped_refptr<base::SingleThreadTaskRunner> forwarders_constructor_runner_; |
| - PipeNotifier deletion_notifier_; |
| - ScopedVector<Forwarder> forwarders_; |
| - }; |
| + void WaitForEventsOnInternalThreadSoon(); |
| + void WaitForEventsOnInternalThread(); |
| - const scoped_refptr<Delegate> delegate_; |
| + ScopedVector<Forwarder> forwarders_; |
| + PipeNotifier deletion_notifier_; |
| + PipeNotifier wakeup_notifier_; |
| + base::Thread thread_; |
| }; |
| } // namespace forwarder2 |