summaryrefslogtreecommitdiffstats
path: root/chrome/browser/device_orientation/provider.cc
blob: 1ac02205a0b28b80e84741c59dbda9a7d8196567 (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
43
44
45
// Copyright (c) 2010 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.

#include "chrome/browser/device_orientation/provider.h"

#include "base/logging.h"
#include "chrome/browser/chrome_thread.h"

#if defined(OS_MACOSX)
#include "chrome/browser/device_orientation/accelerometer_mac.h"
#endif

#include "chrome/browser/device_orientation/data_fetcher.h"
#include "chrome/browser/device_orientation/provider_impl.h"

namespace device_orientation {

Provider* Provider::GetInstance() {
  if (!instance_) {
    DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
    const ProviderImpl::DataFetcherFactory default_factories[] = {
#if defined(OS_MACOSX)
      AccelerometerMac::Create,
#endif
      NULL
    };

    instance_ = new ProviderImpl(default_factories);
  }
  return instance_;
}

void Provider::SetInstanceForTests(Provider* provider) {
  DCHECK(!instance_);
  instance_ = provider;
}

Provider* Provider::GetInstanceForTests() {
  return instance_;
}

Provider* Provider::instance_ = NULL;

} //  namespace device_orientation