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

Unified Diff: content/browser/device_sensors/sensor_manager_android.cc

Issue 2452083002: [Device Sensors] Remove BrowserThread knowledge (Closed)
Patch Set: 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/device_sensors/sensor_manager_android.cc
diff --git a/content/browser/device_sensors/sensor_manager_android.cc b/content/browser/device_sensors/sensor_manager_android.cc
index a3928734aecfd2a0eb3271c7669f8f59757bcc80..7b542caefa2028ced62487592d4295e2b4d08ff1 100644
--- a/content/browser/device_sensors/sensor_manager_android.cc
+++ b/content/browser/device_sensors/sensor_manager_android.cc
@@ -11,7 +11,6 @@
#include "base/bind.h"
#include "base/memory/singleton.h"
#include "base/metrics/histogram_macros.h"
-#include "content/public/browser/browser_thread.h"
#include "jni/DeviceSensors_jni.h"
using base::android::AttachCurrentThread;
@@ -58,7 +57,7 @@ SensorManagerAndroid::SensorManagerAndroid()
motion_buffer_initialized_(false),
orientation_buffer_initialized_(false),
is_shutdown_(false) {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ DCHECK(thread_checker_.CalledOnValidThread());
timvolodine 2016/10/31 15:52:46 can we add an explicit UI thread check here? to av
blundell 2016/11/09 16:00:46 Done in GetInstance(), the initial entrypoint.
memset(received_motion_data_, 0, sizeof(received_motion_data_));
device_sensors_.Reset(Java_DeviceSensors_getInstance(
AttachCurrentThread(), base::android::GetApplicationContext()));
@@ -208,7 +207,7 @@ void SensorManagerAndroid::GotLight(JNIEnv*,
}
bool SensorManagerAndroid::Start(ConsumerType consumer_type) {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(!device_sensors_.is_null());
int rate_in_microseconds = (consumer_type == CONSUMER_TYPE_LIGHT)
? kLightSensorIntervalMicroseconds
@@ -219,14 +218,14 @@ bool SensorManagerAndroid::Start(ConsumerType consumer_type) {
}
void SensorManagerAndroid::Stop(ConsumerType consumer_type) {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(!device_sensors_.is_null());
Java_DeviceSensors_stop(AttachCurrentThread(), device_sensors_,
static_cast<jint>(consumer_type));
}
int SensorManagerAndroid::GetNumberActiveDeviceMotionSensors() {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(!device_sensors_.is_null());
return Java_DeviceSensors_getNumberActiveDeviceMotionSensors(
AttachCurrentThread(), device_sensors_);
@@ -234,7 +233,7 @@ int SensorManagerAndroid::GetNumberActiveDeviceMotionSensors() {
SensorManagerAndroid::OrientationSensorType
SensorManagerAndroid::GetOrientationSensorTypeUsed() {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(!device_sensors_.is_null());
return static_cast<SensorManagerAndroid::OrientationSensorType>(
Java_DeviceSensors_getOrientationSensorTypeUsed(AttachCurrentThread(),
@@ -247,7 +246,7 @@ SensorManagerAndroid::GetOrientationSensorTypeUsed() {
void SensorManagerAndroid::StartFetchingDeviceLightData(
DeviceLightHardwareBuffer* buffer) {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(buffer);
if (is_shutdown_)
return;
@@ -265,7 +264,7 @@ void SensorManagerAndroid::StartFetchingDeviceLightData(
}
void SensorManagerAndroid::StopFetchingDeviceLightData() {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ DCHECK(thread_checker_.CalledOnValidThread());
if (is_shutdown_)
return;
@@ -289,7 +288,7 @@ void SensorManagerAndroid::SetLightBufferValue(double lux) {
void SensorManagerAndroid::StartFetchingDeviceMotionData(
DeviceMotionHardwareBuffer* buffer) {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(buffer);
if (is_shutdown_)
return;
@@ -312,7 +311,7 @@ void SensorManagerAndroid::StartFetchingDeviceMotionData(
}
void SensorManagerAndroid::StopFetchingDeviceMotionData() {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ DCHECK(thread_checker_.CalledOnValidThread());
if (is_shutdown_)
return;
@@ -365,7 +364,7 @@ void SensorManagerAndroid::ClearInternalMotionBuffers() {
void SensorManagerAndroid::StartFetchingDeviceOrientationData(
DeviceOrientationHardwareBuffer* buffer) {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(buffer);
if (is_shutdown_)
return;
@@ -390,7 +389,7 @@ void SensorManagerAndroid::StartFetchingDeviceOrientationData(
}
void SensorManagerAndroid::StopFetchingDeviceOrientationData() {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ DCHECK(thread_checker_.CalledOnValidThread());
if (is_shutdown_)
return;
@@ -407,7 +406,7 @@ void SensorManagerAndroid::StopFetchingDeviceOrientationData() {
void SensorManagerAndroid::StartFetchingDeviceOrientationAbsoluteData(
DeviceOrientationHardwareBuffer* buffer) {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ DCHECK(thread_checker_.CalledOnValidThread());
DCHECK(buffer);
if (is_shutdown_)
return;
@@ -429,7 +428,7 @@ void SensorManagerAndroid::StartFetchingDeviceOrientationAbsoluteData(
}
void SensorManagerAndroid::StopFetchingDeviceOrientationAbsoluteData() {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ DCHECK(thread_checker_.CalledOnValidThread());
if (is_shutdown_)
return;
@@ -446,7 +445,7 @@ void SensorManagerAndroid::StopFetchingDeviceOrientationAbsoluteData() {
}
void SensorManagerAndroid::Shutdown() {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ DCHECK(thread_checker_.CalledOnValidThread());
is_shutdown_ = true;
}

Powered by Google App Engine
This is Rietveld 408576698