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

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

Issue 2416123003: [Device Sensors] Move Mojo communication to UI thread on Android (Closed)
Patch Set: Response to review Created 4 years, 1 month 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 "content/browser/device_sensors/device_sensor_service.h" 7 #include "content/browser/device_sensors/device_sensor_service.h"
8 #include "content/public/browser/browser_thread.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 #if defined(OS_ANDROID)
25 DCHECK_CURRENTLY_ON(BrowserThread::UI);
26 #else
24 DCHECK_CURRENTLY_ON(BrowserThread::IO); 27 DCHECK_CURRENTLY_ON(BrowserThread::IO);
28 #endif
25 } 29 }
26 30
27 template <typename MojoInterface, ConsumerType consumer_type> 31 template <typename MojoInterface, ConsumerType consumer_type>
28 DeviceSensorHost<MojoInterface, consumer_type>::~DeviceSensorHost() { 32 DeviceSensorHost<MojoInterface, consumer_type>::~DeviceSensorHost() {
29 DCHECK(thread_checker_.CalledOnValidThread()); 33 DCHECK(thread_checker_.CalledOnValidThread());
30 if (is_started_) 34 if (is_started_)
31 DeviceSensorService::GetInstance()->RemoveConsumer(consumer_type); 35 DeviceSensorService::GetInstance()->RemoveConsumer(consumer_type);
32 } 36 }
33 37
34 template <typename MojoInterface, ConsumerType consumer_type> 38 template <typename MojoInterface, ConsumerType consumer_type>
(...skipping 23 matching lines...) Expand all
58 template class DeviceSensorHost<device::mojom::LightSensor, 62 template class DeviceSensorHost<device::mojom::LightSensor,
59 CONSUMER_TYPE_LIGHT>; 63 CONSUMER_TYPE_LIGHT>;
60 template class DeviceSensorHost<device::mojom::MotionSensor, 64 template class DeviceSensorHost<device::mojom::MotionSensor,
61 CONSUMER_TYPE_MOTION>; 65 CONSUMER_TYPE_MOTION>;
62 template class DeviceSensorHost<device::mojom::OrientationSensor, 66 template class DeviceSensorHost<device::mojom::OrientationSensor,
63 CONSUMER_TYPE_ORIENTATION>; 67 CONSUMER_TYPE_ORIENTATION>;
64 template class DeviceSensorHost<device::mojom::OrientationAbsoluteSensor, 68 template class DeviceSensorHost<device::mojom::OrientationAbsoluteSensor,
65 CONSUMER_TYPE_ORIENTATION_ABSOLUTE>; 69 CONSUMER_TYPE_ORIENTATION_ABSOLUTE>;
66 70
67 } // namespace content 71 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/device_sensors/device_sensor_browsertest.cc ('k') | content/browser/device_sensors/sensor_manager_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698