1 // Copyright (c) 2012 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.
5 #include "content/browser/device_orientation/provider.h"
7 #include "base/logging.h"
8 #include "content/browser/device_orientation/data_fetcher.h"
9 #include "content/browser/device_orientation/provider_impl.h"
10 #include "content/public/browser/browser_thread.h"
12 #if defined(OS_MACOSX)
13 #include "content/browser/device_orientation/accelerometer_mac.h"
14 #elif defined(OS_ANDROID)
15 #include "content/browser/device_orientation/data_fetcher_impl_android.h"
17 #include "content/browser/device_orientation/data_fetcher_impl_win.h"
22 Provider
* Provider::GetInstance() {
24 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO
));
25 ProviderImpl::DataFetcherFactory default_factory
= NULL
;
27 #if defined(OS_MACOSX)
28 default_factory
= AccelerometerMac::Create
;
29 #elif defined(OS_ANDROID)
30 default_factory
= DataFetcherImplAndroid::Create
;
32 default_factory
= DataFetcherImplWin::Create
;
35 instance_
= new ProviderImpl(default_factory
);
40 void Provider::SetInstanceForTests(Provider
* provider
) {
45 Provider
* Provider::GetInstanceForTests() {
49 Provider::Provider() {
52 Provider::~Provider() {
53 DCHECK(instance_
== this);
57 Provider
* Provider::instance_
= NULL
;
59 } // namespace content