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

Side by Side Diff: content/browser/device_sensors/device_sensor_host.cc

Issue 2410123002: Remove content::BrowserThread knowledge from Device Sensors (Closed)
Patch Set: Handle DeviceSensorService's ThreadChecker Created 4 years, 2 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_sensors/device_sensor_host.h" 5 #include "content/browser/device_sensors/device_sensor_host.h"
6 6
7 #include "base/message_loop/message_loop.h"
7 #include "content/browser/device_sensors/device_sensor_service.h" 8 #include "content/browser/device_sensors/device_sensor_service.h"
8 #include "content/public/browser/browser_thread.h"
9 #include "mojo/public/cpp/bindings/strong_binding.h" 9 #include "mojo/public/cpp/bindings/strong_binding.h"
10 10
11 namespace content { 11 namespace content {
12 12
13 template <typename MojoInterface, ConsumerType consumer_type> 13 template <typename MojoInterface, ConsumerType consumer_type>
14 void DeviceSensorHost<MojoInterface, consumer_type>::Create( 14 void DeviceSensorHost<MojoInterface, consumer_type>::Create(
15 mojo::InterfaceRequest<MojoInterface> request) { 15 mojo::InterfaceRequest<MojoInterface> request) {
16 mojo::MakeStrongBinding( 16 mojo::MakeStrongBinding(
17 base::WrapUnique(new DeviceSensorHost<MojoInterface, consumer_type>), 17 base::WrapUnique(new DeviceSensorHost<MojoInterface, consumer_type>),
18 std::move(request)); 18 std::move(request));
19 } 19 }
20 20
21 template <typename MojoInterface, ConsumerType consumer_type> 21 template <typename MojoInterface, ConsumerType consumer_type>
22 DeviceSensorHost<MojoInterface, consumer_type>::DeviceSensorHost() 22 DeviceSensorHost<MojoInterface, consumer_type>::DeviceSensorHost()
23 : is_started_(false) { 23 : is_started_(false) {
24 DCHECK_CURRENTLY_ON(BrowserThread::IO); 24 DCHECK(base::MessageLoopForIO::IsCurrent());
25 DeviceSensorService::GetInstance()->InitOnIOThread();
25 } 26 }
26 27
27 template <typename MojoInterface, ConsumerType consumer_type> 28 template <typename MojoInterface, ConsumerType consumer_type>
28 DeviceSensorHost<MojoInterface, consumer_type>::~DeviceSensorHost() { 29 DeviceSensorHost<MojoInterface, consumer_type>::~DeviceSensorHost() {
29 DCHECK(thread_checker_.CalledOnValidThread()); 30 DCHECK(thread_checker_.CalledOnValidThread());
30 if (is_started_) 31 if (is_started_)
31 DeviceSensorService::GetInstance()->RemoveConsumer(consumer_type); 32 DeviceSensorService::GetInstance()->RemoveConsumer(consumer_type);
32 } 33 }
33 34
34 template <typename MojoInterface, ConsumerType consumer_type> 35 template <typename MojoInterface, ConsumerType consumer_type>
(...skipping 23 matching lines...) Expand all
58 template class DeviceSensorHost<device::mojom::LightSensor, 59 template class DeviceSensorHost<device::mojom::LightSensor,
59 CONSUMER_TYPE_LIGHT>; 60 CONSUMER_TYPE_LIGHT>;
60 template class DeviceSensorHost<device::mojom::MotionSensor, 61 template class DeviceSensorHost<device::mojom::MotionSensor,
61 CONSUMER_TYPE_MOTION>; 62 CONSUMER_TYPE_MOTION>;
62 template class DeviceSensorHost<device::mojom::OrientationSensor, 63 template class DeviceSensorHost<device::mojom::OrientationSensor,
63 CONSUMER_TYPE_ORIENTATION>; 64 CONSUMER_TYPE_ORIENTATION>;
64 template class DeviceSensorHost<device::mojom::OrientationAbsoluteSensor, 65 template class DeviceSensorHost<device::mojom::OrientationAbsoluteSensor,
65 CONSUMER_TYPE_ORIENTATION_ABSOLUTE>; 66 CONSUMER_TYPE_ORIENTATION_ABSOLUTE>;
66 67
67 } // namespace content 68 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698