blob: 8f0862acf2818450c64d61af971e63d1d8d88a08 (
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
46
47
48
49
50
51
52
53
|
// 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/browser_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(BrowserThread::CurrentlyOn(BrowserThread::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() {
}
Provider::~Provider() {
DCHECK(instance_ == this);
instance_ = NULL;
}
Provider* Provider::instance_ = NULL;
} // namespace device_orientation
|