diff options
author | felipeg@chromium.org <felipeg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-11 20:56:52 +0000 |
---|---|---|
committer | felipeg@chromium.org <felipeg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-11 20:56:52 +0000 |
commit | 8cb5f381e9b31703ef670f30900245f30d36aa3d (patch) | |
tree | 3c0e8d939e7c3a480ed0dd5634d7794d1a0f0941 /tools/android/forwarder2/pipe_notifier.h | |
parent | 9827043f58d7b90a2cccd7017134a7d9ae3bdbca (diff) | |
download | chromium_src-8cb5f381e9b31703ef670f30900245f30d36aa3d.zip chromium_src-8cb5f381e9b31703ef670f30900245f30d36aa3d.tar.gz chromium_src-8cb5f381e9b31703ef670f30900245f30d36aa3d.tar.bz2 |
Add DeviceListener and PipeNotifier to Forwarder2.
The big picture CL can be seem here: https://chromiumcodereview.appspot.com/10918057/
BUG=146502
Review URL: https://chromiumcodereview.appspot.com/10909170
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@156120 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/android/forwarder2/pipe_notifier.h')
-rw-r--r-- | tools/android/forwarder2/pipe_notifier.h | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/tools/android/forwarder2/pipe_notifier.h b/tools/android/forwarder2/pipe_notifier.h new file mode 100644 index 0000000..efe303b --- /dev/null +++ b/tools/android/forwarder2/pipe_notifier.h @@ -0,0 +1,35 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef TOOLS_ANDROID_FORWARDER2_PIPE_NOTIFIER_H_ +#define TOOLS_ANDROID_FORWARDER2_PIPE_NOTIFIER_H_ + +#include "base/basictypes.h" + +namespace forwarder2 { + +// Helper class used to create a unix pipe that sends notifications to the +// |receiver_fd_| file descriptor when called |Notify()|. This should be used +// by the main thread to notify other threads that it must exit. +// The |receiver_fd_| can be put into a fd_set and used in a select together +// with a socket waiting to accept or read. +class PipeNotifier { + public: + PipeNotifier(); + ~PipeNotifier(); + + bool Notify(); + + int receiver_fd() const { return receiver_fd_; } + + private: + int sender_fd_; + int receiver_fd_; + + DISALLOW_COPY_AND_ASSIGN(PipeNotifier); +}; + +} // namespace forwarder + +#endif // TOOLS_ANDROID_FORWARDER2_PIPE_NOTIFIER_H_ |