| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2010 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. | |
| 4 | |
| 5 #include "chrome/browser/device_orientation/provider.h" | |
| 6 | |
| 7 #include "base/logging.h" | |
| 8 #include "chrome/browser/browser_thread.h" | |
| 9 | |
| 10 #if defined(OS_MACOSX) | |
| 11 #include "chrome/browser/device_orientation/accelerometer_mac.h" | |
| 12 #endif | |
| 13 | |
| 14 #include "chrome/browser/device_orientation/data_fetcher.h" | |
| 15 #include "chrome/browser/device_orientation/provider_impl.h" | |
| 16 | |
| 17 namespace device_orientation { | |
| 18 | |
| 19 Provider* Provider::GetInstance() { | |
| 20 if (!instance_) { | |
| 21 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
| 22 const ProviderImpl::DataFetcherFactory default_factories[] = { | |
| 23 #if defined(OS_MACOSX) | |
| 24 AccelerometerMac::Create, | |
| 25 #endif | |
| 26 NULL | |
| 27 }; | |
| 28 | |
| 29 instance_ = new ProviderImpl(default_factories); | |
| 30 } | |
| 31 return instance_; | |
| 32 } | |
| 33 | |
| 34 void Provider::SetInstanceForTests(Provider* provider) { | |
| 35 DCHECK(!instance_); | |
| 36 instance_ = provider; | |
| 37 } | |
| 38 | |
| 39 Provider* Provider::GetInstanceForTests() { | |
| 40 return instance_; | |
| 41 } | |
| 42 | |
| 43 Provider::Provider() { | |
| 44 } | |
| 45 | |
| 46 Provider::~Provider() { | |
| 47 DCHECK(instance_ == this); | |
| 48 instance_ = NULL; | |
| 49 } | |
| 50 | |
| 51 Provider* Provider::instance_ = NULL; | |
| 52 | |
| 53 } // namespace device_orientation | |
| OLD | NEW |