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

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

Issue 18572014: Implement Android shared memory data fetcher for Device Motion. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@renderer-sync-12June-tryASYNC-2-bis-tryRebase-6
Patch Set: fixed comments, added proper singleton implementation and shutdown. Created 7 years, 5 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/accelerometer_mac.h" 5 #include "content/browser/device_orientation/accelerometer_mac.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "content/browser/device_orientation/orientation.h" 10 #include "content/browser/device_orientation/orientation.h"
11 #include "third_party/sudden_motion_sensor/sudden_motion_sensor_mac.h" 11 #include "third_party/sudden_motion_sensor/sudden_motion_sensor_mac.h"
12 12
13 namespace content { 13 namespace content {
14 14
15 AccelerometerMac* AccelerometerMac::instance() {
16 CR_DEFINE_STATIC_LOCAL(AccelerometerMac, s_data_fetcher, ());
17 return &s_data_fetcher;
18 }
19
15 // Create a AccelerometerMac object and return NULL if no valid sensor found. 20 // Create a AccelerometerMac object and return NULL if no valid sensor found.
16 DataFetcher* AccelerometerMac::Create() { 21 DataFetcher* AccelerometerMac::Create() {
17 scoped_ptr<AccelerometerMac> accelerometer(new AccelerometerMac); 22 AccelerometerMac* accelerometer = AccelerometerMac::instance();
18 return accelerometer->Init() ? accelerometer.release() : NULL; 23 return accelerometer->Init() ? accelerometer : NULL;
19 } 24 }
20 25
21 AccelerometerMac::~AccelerometerMac() { 26 AccelerometerMac::~AccelerometerMac() {
22 } 27 }
23 28
24 AccelerometerMac::AccelerometerMac() { 29 AccelerometerMac::AccelerometerMac() {
25 } 30 }
26 31
27 const DeviceData* AccelerometerMac::GetDeviceData(DeviceData::Type type) { 32 const DeviceData* AccelerometerMac::GetDeviceData(DeviceData::Type type) {
28 if (type != DeviceData::kTypeOrientation) 33 if (type != DeviceData::kTypeOrientation)
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 orientation->AddRef(); 101 orientation->AddRef();
97 return orientation.get(); 102 return orientation.get();
98 } 103 }
99 104
100 bool AccelerometerMac::Init() { 105 bool AccelerometerMac::Init() {
101 sudden_motion_sensor_.reset(SuddenMotionSensor::Create()); 106 sudden_motion_sensor_.reset(SuddenMotionSensor::Create());
102 return sudden_motion_sensor_.get() != NULL; 107 return sudden_motion_sensor_.get() != NULL;
103 } 108 }
104 109
105 } // namespace content 110 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698