DeviceOrientationClientManx.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * Copyright 2010, The Android Open Source Project
  3. * Copyright (C) 2012 Samsung Electronics. All rights reserved.
  4. * Copyright (C) 2014 Sony Computer Entertainment Inc.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. * * Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. * * Redistributions in binary form must reproduce the above copyright
  12. * notice, this list of conditions and the following disclaimer in the
  13. * documentation and/or other materials provided with the distribution.
  14. *
  15. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
  16. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  17. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  18. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  19. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  20. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  21. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  22. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
  23. * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  25. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. #ifndef DeviceOrientationClientManx_h
  28. #define DeviceOrientationClientManx_h
  29. #include "DeviceOrientationClient.h"
  30. #include "DeviceOrientationData.h"
  31. #include <wtf/RefPtr.h>
  32. #include <wtf/ThreadingPrimitives.h>
  33. #if OS(PSP2)
  34. #include <motion/motion.h>
  35. #else
  36. #error This platform is not supported.
  37. #endif
  38. namespace WebCore {
  39. class DeviceOrientationClientManx : public WebCore::DeviceOrientationClient, public motion::OrientationProvider::Client {
  40. public:
  41. DeviceOrientationClientManx();
  42. virtual ~DeviceOrientationClientManx();
  43. // DeviceClient interface
  44. virtual void startUpdating();
  45. virtual void stopUpdating();
  46. // DeviceOrientationClient interface
  47. virtual void setController(DeviceOrientationController*);
  48. virtual DeviceOrientationData* lastOrientation() const;
  49. virtual void deviceOrientationControllerDestroyed();
  50. protected:
  51. void onUpdate(motion::OrientationData);
  52. static void handleDidChangeDeviceOrientationOnMainThread(void*);
  53. private:
  54. DeviceOrientationController* m_controller;
  55. motion::OrientationProvider* m_provider;
  56. mutable WTF::Mutex m_mutex;
  57. mutable RefPtr<DeviceOrientationData> m_lastOrientation;
  58. };
  59. } // namespace WebCore
  60. #endif // DeviceOrientationClientManx_h