Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(208)

Side by Side Diff: content/browser/device_orientation/provider.cc

Issue 13433002: Implement DeviceOrientation API on Windows (Closed) Base URL: ssh://nhu@powerbuilder.sh.intel.com/home/www-data/git-repos/perc/chromium.git@sensor
Patch Set: Update according to sail's and peter's comments #8, #9 and #11 Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #elif defined(OS_WIN)
17 #include "content/browser/device_orientation/data_fetcher_impl_win.h"
16 #endif 18 #endif
17 19
18 namespace content { 20 namespace content {
19 21
20 Provider* Provider::GetInstance() { 22 Provider* Provider::GetInstance() {
21 if (!instance_) { 23 if (!instance_) {
22 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 24 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
23 ProviderImpl::DataFetcherFactory default_factory = NULL; 25 ProviderImpl::DataFetcherFactory default_factory = NULL;
24 26
25 #if defined(OS_MACOSX) 27 #if defined(OS_MACOSX)
26 default_factory = AccelerometerMac::Create; 28 default_factory = AccelerometerMac::Create;
27 #elif defined(OS_ANDROID) 29 #elif defined(OS_ANDROID)
28 default_factory = DataFetcherImplAndroid::Create; 30 default_factory = DataFetcherImplAndroid::Create;
31 #elif defined(OS_WIN)
32 default_factory = DataFetcherImplWin::Create;
29 #endif 33 #endif
30 34
31 instance_ = new ProviderImpl(default_factory); 35 instance_ = new ProviderImpl(default_factory);
32 } 36 }
33 return instance_; 37 return instance_;
34 } 38 }
35 39
36 void Provider::SetInstanceForTests(Provider* provider) { 40 void Provider::SetInstanceForTests(Provider* provider) {
37 DCHECK(!instance_); 41 DCHECK(!instance_);
38 instance_ = provider; 42 instance_ = provider;
39 } 43 }
40 44
41 Provider* Provider::GetInstanceForTests() { 45 Provider* Provider::GetInstanceForTests() {
42 return instance_; 46 return instance_;
43 } 47 }
44 48
45 Provider::Provider() { 49 Provider::Provider() {
46 } 50 }
47 51
48 Provider::~Provider() { 52 Provider::~Provider() {
49 DCHECK(instance_ == this); 53 DCHECK(instance_ == this);
50 instance_ = NULL; 54 instance_ = NULL;
51 } 55 }
52 56
53 Provider* Provider::instance_ = NULL; 57 Provider* Provider::instance_ = NULL;
54 58
55 } // namespace content 59 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698