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

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

Issue 14678012: Implement the content/renderer and content/browser part of the Device Motion API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: similarity=70 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
(Empty)
1 // Copyright (c) 2013 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 "content/browser/device_orientation/device_motion_service.h"
6
7 #include "base/bind.h"
8 #include "base/logging.h"
9 #include "base/memory/singleton.h"
10 #include "content/browser/device_orientation/device_motion_provider.h"
11 #include "content/public/browser/render_process_host.h"
12
13 namespace content {
14
15 DeviceMotionService::DeviceMotionService() : num_readers_(0) {
16 }
17
18 DeviceMotionService::~DeviceMotionService() {
19 }
20
21 DeviceMotionService* DeviceMotionService::GetInstance() {
22 return Singleton<DeviceMotionService,
23 LeakySingletonTraits<DeviceMotionService> >::get();
24 }
25
26 void DeviceMotionService::AddConsumer() {
27 DCHECK(thread_checker_.CalledOnValidThread());
28
29 num_readers_++;
30 DCHECK(num_readers_ > 0);
31 if (!provider_.get())
32 provider_.reset(new DeviceMotionProvider);
33 provider_->StartFetchingDeviceMotionData();
34 }
35
36 void DeviceMotionService::RemoveConsumer() {
37 DCHECK(thread_checker_.CalledOnValidThread());
38
39 --num_readers_;
40 DCHECK(num_readers_ >= 0);
41
42 if (num_readers_ == 0) {
43 LOG(INFO) << "ACTIVE service stop fetching";
44 provider_->StopFetchingDeviceMotionData();
45 }
46 }
47
48 void DeviceMotionService::Terminate() {
49 provider_.reset();
50 }
51
52 base::SharedMemoryHandle DeviceMotionService::GetSharedMemoryHandleForProcess(
53 base::ProcessHandle handle) {
54 DCHECK(thread_checker_.CalledOnValidThread());
55 return provider_->GetSharedMemoryHandleForProcess(handle);
56 }
57
58 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698