OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 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. |
| 4 |
| 5 #ifndef CONTENT_BROWSER_SENSORS_PROVIDER_IMPL_H_ |
| 6 #define CONTENT_BROWSER_SENSORS_PROVIDER_IMPL_H_ |
| 7 #pragma once |
| 8 |
| 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/message_loop_proxy.h" |
| 11 #include "base/threading/thread.h" |
| 12 #include "content/browser/sensors/provider.h" |
| 13 |
| 14 #include <set> |
| 15 |
| 16 template <typename T> |
| 17 struct DefaultSingletonTraits; |
| 18 |
| 19 namespace sensors { |
| 20 |
| 21 class ConnectionImpl; |
| 22 |
| 23 class ProviderImpl : public Provider { |
| 24 public: |
| 25 static ProviderImpl* GetInstance(); |
| 26 |
| 27 virtual Connection* Open(Listener* listener); |
| 28 |
| 29 virtual void FireSensorChanged(Channel channel, const std::string& data); |
| 30 |
| 31 private: |
| 32 static const int kIIOMessageSize = 16; |
| 33 |
| 34 ProviderImpl(); |
| 35 virtual ~ProviderImpl(); |
| 36 |
| 37 friend class DefaultSingletonTraits<ProviderImpl>; |
| 38 DISALLOW_COPY_AND_ASSIGN(ProviderImpl); |
| 39 |
| 40 // Quick hack to support cwolfe's IIO driver |
| 41 |
| 42 bool IsOnDeviceThread() const; |
| 43 |
| 44 void DeviceStart(); |
| 45 void DeviceStop(); |
| 46 void DeviceRead(); |
| 47 bool DoDeviceRead(); |
| 48 |
| 49 scoped_refptr<base::MessageLoopProxy> device_proxy_; |
| 50 int device_fd_; |
| 51 unsigned char device_buf_[kIIOMessageSize]; |
| 52 int device_buf_end_; |
| 53 |
| 54 friend class ConnectionImpl; |
| 55 void ConnectionStarted(ConnectionImpl* conn, |
| 56 Channel channel, const std::string& data); |
| 57 void ConnectionStopped(ConnectionImpl* conn, |
| 58 Channel channel); |
| 59 void ConnectionClosed(ConnectionImpl* conn); |
| 60 |
| 61 ObserverList<ConnectionImpl, true> connections_; |
| 62 }; |
| 63 |
| 64 } // namespace sensors |
| 65 |
| 66 DISABLE_RUNNABLE_METHOD_REFCOUNT(sensors::ProviderImpl); |
| 67 |
| 68 #endif // CONTENT_BROWSER_SENSORS_PROVIDER_IMPL_H_ |
OLD | NEW |