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

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

Issue 2410123002: Remove content::BrowserThread knowledge from Device Sensors (Closed)
Patch Set: Rebase, avoid object creation on startup 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/device_sensor_host.cc
diff --git a/content/browser/device_sensors/device_sensor_host.cc b/content/browser/device_sensors/device_sensor_host.cc
index e4b806967e5c16aac8448233141f422249d19874..81a0429c8b6f7d343c030dd3abfa4c8772b2c5d7 100644
--- a/content/browser/device_sensors/device_sensor_host.cc
+++ b/content/browser/device_sensors/device_sensor_host.cc
@@ -4,24 +4,32 @@
#include "content/browser/device_sensors/device_sensor_host.h"
+#include "base/message_loop/message_loop.h"
+#include "build/build_config.h"
#include "content/browser/device_sensors/device_sensor_service.h"
-#include "content/public/browser/browser_thread.h"
#include "mojo/public/cpp/bindings/strong_binding.h"
+#if defined(OS_ANDROID)
+#include "content/browser/device_sensors/sensor_manager_android.h"
+#endif
+
namespace content {
template <typename MojoInterface, ConsumerType consumer_type>
void DeviceSensorHost<MojoInterface, consumer_type>::Create(
+ scoped_refptr<base::SequencedTaskRunner> ui_task_runner,
mojo::InterfaceRequest<MojoInterface> request) {
mojo::MakeStrongBinding(
- base::WrapUnique(new DeviceSensorHost<MojoInterface, consumer_type>),
+ base::WrapUnique(
+ new DeviceSensorHost<MojoInterface, consumer_type>(ui_task_runner)),
std::move(request));
}
template <typename MojoInterface, ConsumerType consumer_type>
-DeviceSensorHost<MojoInterface, consumer_type>::DeviceSensorHost()
- : is_started_(false) {
- DCHECK_CURRENTLY_ON(BrowserThread::IO);
+DeviceSensorHost<MojoInterface, consumer_type>::DeviceSensorHost(
+ scoped_refptr<base::SequencedTaskRunner> ui_task_runner)
+ : is_started_(false), ui_task_runner_(ui_task_runner) {
+ DCHECK(base::MessageLoopForIO::IsCurrent());
}
template <typename MojoInterface, ConsumerType consumer_type>
@@ -39,6 +47,9 @@ void DeviceSensorHost<MojoInterface, consumer_type>::DeviceSensorHost::
if (is_started_)
return;
is_started_ = true;
+#if defined(OS_ANDROID)
+ SensorManagerAndroid::GetInstance()->SetUITaskRunner(ui_task_runner_);
+#endif
DeviceSensorService::GetInstance()->AddConsumer(consumer_type);
callback.Run(
DeviceSensorService::GetInstance()->GetSharedMemoryHandle(consumer_type));
« no previous file with comments | « content/browser/device_sensors/device_sensor_host.h ('k') | content/browser/device_sensors/device_sensor_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698