Commit 4659bddd authored by Raphael Kubo da Costa's avatar Raphael Kubo da Costa Committed by Commit Bot

sensors: Remove PlatformSensorProviderLinux::SensorDeviceFound()

Its only call site was the function right above it. Merge them together for
simplicity.

While here, use base::MakeRefCounted<> rather than creating a
scoped_refptr<> and passing it to base::Callback::Run().

Change-Id: Id1ccce0493dfdcaccb3689d07b661e0267e2ba46
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2218068
Auto-Submit: Raphael Kubo da Costa <raphael.kubo.da.costa@intel.com>
Commit-Queue: Reilly Grant <reillyg@chromium.org>
Reviewed-by: default avatarReilly Grant <reillyg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#772275}
parent 1c51e7a7
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include <vector> #include <vector>
#include "base/bind.h" #include "base/bind.h"
#include "base/memory/ref_counted.h" #include "base/memory/scoped_refptr.h"
#include "base/task/post_task.h" #include "base/task/post_task.h"
#include "base/task/thread_pool.h" #include "base/task/thread_pool.h"
#include "base/task_runner_util.h" #include "base/task_runner_util.h"
...@@ -60,6 +60,8 @@ void PlatformSensorProviderLinux::CreateSensorInternal( ...@@ -60,6 +60,8 @@ void PlatformSensorProviderLinux::CreateSensorInternal(
mojom::SensorType type, mojom::SensorType type,
SensorReadingSharedBuffer* reading_buffer, SensorReadingSharedBuffer* reading_buffer,
CreateSensorCallback callback) { CreateSensorCallback callback) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
if (!sensor_nodes_enumerated_) { if (!sensor_nodes_enumerated_) {
if (!sensor_nodes_enumeration_started_) { if (!sensor_nodes_enumeration_started_) {
// Unretained() is safe because the deletion of |sensor_device_manager_| // Unretained() is safe because the deletion of |sensor_device_manager_|
...@@ -84,20 +86,8 @@ void PlatformSensorProviderLinux::CreateSensorInternal( ...@@ -84,20 +86,8 @@ void PlatformSensorProviderLinux::CreateSensorInternal(
return; return;
} }
SensorDeviceFound(type, reading_buffer, std::move(callback), sensor_device); std::move(callback).Run(base::MakeRefCounted<PlatformSensorLinux>(
} type, reading_buffer, this, sensor_device));
void PlatformSensorProviderLinux::SensorDeviceFound(
mojom::SensorType type,
SensorReadingSharedBuffer* reading_buffer,
PlatformSensorProviderBase::CreateSensorCallback callback,
const SensorInfoLinux* sensor_device) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
DCHECK(sensor_device);
scoped_refptr<PlatformSensorLinux> sensor =
new PlatformSensorLinux(type, reading_buffer, this, sensor_device);
std::move(callback).Run(sensor);
} }
void PlatformSensorProviderLinux::FreeResources() { void PlatformSensorProviderLinux::FreeResources() {
......
...@@ -42,12 +42,6 @@ class PlatformSensorProviderLinux : public PlatformSensorProvider, ...@@ -42,12 +42,6 @@ class PlatformSensorProviderLinux : public PlatformSensorProvider,
using SensorDeviceMap = using SensorDeviceMap =
std::unordered_map<mojom::SensorType, std::unique_ptr<SensorInfoLinux>>; std::unordered_map<mojom::SensorType, std::unique_ptr<SensorInfoLinux>>;
void SensorDeviceFound(
mojom::SensorType type,
SensorReadingSharedBuffer* reading_buffer,
PlatformSensorProviderBase::CreateSensorCallback callback,
const SensorInfoLinux* sensor_device);
// Returns SensorInfoLinux structure of a requested type. // Returns SensorInfoLinux structure of a requested type.
// If a request cannot be processed immediately, returns nullptr and // If a request cannot be processed immediately, returns nullptr and
// all the requests stored in |requests_map_| are processed after // all the requests stored in |requests_map_| are processed after
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment