OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/browser/device_orientation/provider.h" | 5 #include "content/browser/device_orientation/provider.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "content/browser/device_orientation/data_fetcher.h" | 8 #include "content/browser/device_orientation/data_fetcher.h" |
9 #include "content/browser/device_orientation/provider_impl.h" | 9 #include "content/browser/device_orientation/provider_impl.h" |
10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
11 | 11 |
12 #if defined(OS_MACOSX) | 12 #if defined(OS_MACOSX) |
13 #include "content/browser/device_orientation/accelerometer_mac.h" | 13 #include "content/browser/device_orientation/accelerometer_mac.h" |
14 #elif defined(OS_ANDROID) | 14 #elif defined(OS_ANDROID) |
15 #include "content/browser/device_orientation/data_fetcher_impl_android.h" | 15 #include "content/browser/device_orientation/data_fetcher_impl_android.h" |
16 #endif | 16 #endif |
17 | 17 |
18 using content::BrowserThread; | 18 using content::BrowserThread; |
19 | 19 |
20 namespace device_orientation { | 20 namespace device_orientation { |
21 | 21 |
22 Provider* Provider::GetInstance() { | 22 Provider* Provider::GetInstance() { |
23 if (!instance_) { | 23 if (!instance_) { |
24 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 24 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
25 const ProviderImpl::DataFetcherFactory default_factories[] = { | 25 const ProviderImpl::DataFetcherFactory *default_factory = NULL; |
hans
2012/08/01 19:08:47
hmm, I thought DataFetcherFactory was of type "poi
aousterh
2012/08/02 10:10:38
Hmmm I'm not sure why it was working before. But n
| |
26 | |
26 #if defined(OS_MACOSX) | 27 #if defined(OS_MACOSX) |
27 AccelerometerMac::Create, | 28 default_factory = AccelerometerMac::Create; |
28 #elif defined(OS_ANDROID) | 29 #elif defined(OS_ANDROID) |
29 DataFetcherImplAndroid::Create, | 30 default_factory = DataFetcherImplAndroid::Create; |
30 #endif | 31 #endif |
31 NULL | |
32 }; | |
33 | 32 |
34 instance_ = new ProviderImpl(default_factories); | 33 instance_ = new ProviderImpl(default_factory); |
35 } | 34 } |
36 return instance_; | 35 return instance_; |
37 } | 36 } |
38 | 37 |
39 void Provider::SetInstanceForTests(Provider* provider) { | 38 void Provider::SetInstanceForTests(Provider* provider) { |
40 DCHECK(!instance_); | 39 DCHECK(!instance_); |
41 instance_ = provider; | 40 instance_ = provider; |
42 } | 41 } |
43 | 42 |
44 Provider* Provider::GetInstanceForTests() { | 43 Provider* Provider::GetInstanceForTests() { |
45 return instance_; | 44 return instance_; |
46 } | 45 } |
47 | 46 |
48 Provider::Provider() { | 47 Provider::Provider() { |
49 } | 48 } |
50 | 49 |
51 Provider::~Provider() { | 50 Provider::~Provider() { |
52 DCHECK(instance_ == this); | 51 DCHECK(instance_ == this); |
53 instance_ = NULL; | 52 instance_ = NULL; |
54 } | 53 } |
55 | 54 |
56 Provider* Provider::instance_ = NULL; | 55 Provider* Provider::instance_ = NULL; |
57 | 56 |
58 } // namespace device_orientation | 57 } // namespace device_orientation |
OLD | NEW |