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_H_ |
| 6 #define CONTENT_BROWSER_SENSORS_PROVIDER_H_ |
| 7 #pragma once |
| 8 |
| 9 #include "content/common/sensors_listener.h" |
| 10 |
| 11 namespace sensors { |
| 12 |
| 13 // The sensors API will unify various types of sensor data into a set of |
| 14 // channels, each of which provides change events and periodic updates. |
| 15 // |
| 16 // This version of the API is intended only to support the experimental screen |
| 17 // rotation code and is not for general use. In particular, the final listener |
| 18 // will declare generic |OnSensorChange| and |OnSensorUpdate| methods, rather |
| 19 // than the special-purpose |OnScreenOrientationChange|. |
| 20 // |
| 21 // TODO(cwolfe): Finish defining the initial set of channels and replace this |
| 22 // with the generic sensor provider. |
| 23 // |
| 24 class Provider { |
| 25 public: |
| 26 static Provider* GetInstance(); |
| 27 |
| 28 // Adds a sensor listener. The listener will receive callbacks to indicate |
| 29 // sensor changes and updates until it is removed. |
| 30 // |
| 31 // This method may be called in any thread. Callbacks on a listener will |
| 32 // always be executed in the thread which added that listener. |
| 33 virtual void AddListener(Listener* listener) = 0; |
| 34 |
| 35 // Removes a sensor listener. |
| 36 // |
| 37 // This method must be called in the same thread which added the listener. |
| 38 // If the listener is not currently subscribed, this method may be called in |
| 39 // any thread. |
| 40 virtual void RemoveListener(Listener* listener) = 0; |
| 41 |
| 42 // Broadcasts a change to the coarse screen orientation. |
| 43 // |
| 44 // This method may be called in any thread. |
| 45 virtual void FireScreenOrientationChange(const ScreenOrientation& change) = 0; |
| 46 |
| 47 protected: |
| 48 Provider(); |
| 49 virtual ~Provider(); |
| 50 |
| 51 DISALLOW_COPY_AND_ASSIGN(Provider); |
| 52 }; |
| 53 |
| 54 } // namespace sensors |
| 55 |
| 56 #endif // CONTENT_BROWSER_SENSORS_PROVIDER_H_ |
OLD | NEW |