summaryrefslogtreecommitdiffstats
path: root/content/browser/sensors/sensors_provider_impl.h
blob: b88b1e5bb53498cf6a1ac31dddc5849b538b6b16 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Copyright (c) 2011 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 CONTENT_BROWSER_SENSORS_PROVIDER_IMPL_H_
#define CONTENT_BROWSER_SENSORS_PROVIDER_IMPL_H_
#pragma once

#include "base/compiler_specific.h"
#include "base/memory/ref_counted.h"
#include "base/observer_list_threadsafe.h"
#include "content/browser/sensors/sensors_provider.h"

template <typename T> struct DefaultSingletonTraits;

namespace sensors {

class ProviderImpl : public Provider {
 public:
  static ProviderImpl* GetInstance();

  // Provider implementation
  virtual void AddListener(content::SensorsListener* listener) OVERRIDE;
  virtual void RemoveListener(content::SensorsListener* listener) OVERRIDE;
  virtual void ScreenOrientationChanged(
      content::ScreenOrientation change) OVERRIDE;

 private:
  friend struct DefaultSingletonTraits<ProviderImpl>;

  ProviderImpl();
  virtual ~ProviderImpl();

  typedef ObserverListThreadSafe<content::SensorsListener> ListenerList;
  scoped_refptr<ListenerList> listeners_;

  DISALLOW_COPY_AND_ASSIGN(ProviderImpl);
};

}  // namespace sensors

#endif  // CONTENT_BROWSER_SENSORS_PROVIDER_IMPL_H_