Index: athena/system/device_socket_listener.h |
diff --git a/athena/system/device_socket_listener.h b/athena/system/device_socket_listener.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..cc9eab0006ee700073fd328d06d9ae67ef2b7040 |
--- /dev/null |
+++ b/athena/system/device_socket_listener.h |
@@ -0,0 +1,39 @@ |
+// Copyright (c) 2013 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 ATHENA_SYSTEM_DEVICE_SOCKET_LISTENER_H_ |
+#define ATHENA_SYSTEM_DEVICE_SOCKET_LISTENER_H_ |
+ |
+#include <string> |
+ |
+#include "base/basictypes.h" |
+ |
+namespace athena { |
+ |
+// This class reads device-data from a socket. |
+class DeviceSocketListener { |
+ public: |
+ DeviceSocketListener(const std::string& socket_parth, |
+ size_t data_size); |
+ virtual ~DeviceSocketListener(); |
+ |
+ // This is called on the IO thread when data is available on the socket. |
+ // |data| is guaranteed to be of exactly |data_size| length. Note that the |
+ // implementation must not mutate or free the data. |
+ virtual void OnDataAvailableOnIO(const void* data) = 0; |
+ |
+ protected: |
+ void StartListening(); |
+ void StopListening(); |
+ |
+ private: |
+ const std::string socket_path_; |
+ size_t data_size_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(DeviceSocketListener); |
+}; |
+ |
+} // namespace athena |
+ |
+#endif // ATHENA_SYSTEM_DEVICE_SOCKET_LISTENER_H_ |