Commit 5d4eccac authored by Gyuyoung Kim's avatar Gyuyoung Kim Committed by Commit Bot

Migrate SensorProxyImpl to the new Mojo types

This CL converts |client_biding_| from mojo::Binding to mojo::Receiver.
Then, the name is also changed to |client_receiver_|.

Besides, this CL converts the type of |sensor_| to mojo::Remote as well.

Bug: 955171
Change-Id: Ic7b14f718fe1229fb19a6f1fa68618f8707d2e6e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1757953Reviewed-by: default avatarKen Rockot <rockot@google.com>
Reviewed-by: default avatarReilly Grant <reillyg@chromium.org>
Commit-Queue: Gyuyoung Kim <gyuyoung@igalia.com>
Cr-Commit-Position: refs/heads/master@{#688365}
parent cc53c3e8
...@@ -19,7 +19,6 @@ SensorProxyImpl::SensorProxyImpl(SensorType sensor_type, ...@@ -19,7 +19,6 @@ SensorProxyImpl::SensorProxyImpl(SensorType sensor_type,
SensorProviderProxy* provider, SensorProviderProxy* provider,
Page* page) Page* page)
: SensorProxy(sensor_type, provider, page), : SensorProxy(sensor_type, provider, page),
client_binding_(this),
polling_timer_( polling_timer_(
provider->GetSupplementable()->GetTaskRunner(TaskType::kSensor), provider->GetSupplementable()->GetTaskRunner(TaskType::kSensor),
this, this,
...@@ -28,7 +27,7 @@ SensorProxyImpl::SensorProxyImpl(SensorType sensor_type, ...@@ -28,7 +27,7 @@ SensorProxyImpl::SensorProxyImpl(SensorType sensor_type,
SensorProxyImpl::~SensorProxyImpl() {} SensorProxyImpl::~SensorProxyImpl() {}
void SensorProxyImpl::Dispose() { void SensorProxyImpl::Dispose() {
client_binding_.Close(); client_receiver_.reset();
} }
void SensorProxyImpl::Trace(blink::Visitor* visitor) { void SensorProxyImpl::Trace(blink::Visitor* visitor) {
...@@ -55,14 +54,15 @@ void SensorProxyImpl::AddConfiguration( ...@@ -55,14 +54,15 @@ void SensorProxyImpl::AddConfiguration(
base::OnceCallback<void(bool)> callback) { base::OnceCallback<void(bool)> callback) {
DCHECK(IsInitialized()); DCHECK(IsInitialized());
AddActiveFrequency(configuration->frequency); AddActiveFrequency(configuration->frequency);
sensor_->AddConfiguration(std::move(configuration), std::move(callback)); sensor_remote_->AddConfiguration(std::move(configuration),
std::move(callback));
} }
void SensorProxyImpl::RemoveConfiguration( void SensorProxyImpl::RemoveConfiguration(
SensorConfigurationPtr configuration) { SensorConfigurationPtr configuration) {
DCHECK(IsInitialized()); DCHECK(IsInitialized());
RemoveActiveFrequency(configuration->frequency); RemoveActiveFrequency(configuration->frequency);
sensor_->RemoveConfiguration(std::move(configuration)); sensor_remote_->RemoveConfiguration(std::move(configuration));
} }
double SensorProxyImpl::GetDefaultFrequency() const { double SensorProxyImpl::GetDefaultFrequency() const {
...@@ -79,7 +79,7 @@ void SensorProxyImpl::Suspend() { ...@@ -79,7 +79,7 @@ void SensorProxyImpl::Suspend() {
if (suspended_) if (suspended_)
return; return;
sensor_->Suspend(); sensor_remote_->Suspend();
suspended_ = true; suspended_ = true;
UpdatePollingStatus(); UpdatePollingStatus();
} }
...@@ -88,7 +88,7 @@ void SensorProxyImpl::Resume() { ...@@ -88,7 +88,7 @@ void SensorProxyImpl::Resume() {
if (!suspended_) if (!suspended_)
return; return;
sensor_->Resume(); sensor_remote_->Resume();
suspended_ = false; suspended_ = false;
UpdatePollingStatus(); UpdatePollingStatus();
} }
...@@ -136,11 +136,11 @@ void SensorProxyImpl::ReportError(DOMExceptionCode code, ...@@ -136,11 +136,11 @@ void SensorProxyImpl::ReportError(DOMExceptionCode code,
// The m_sensor.reset() will release all callbacks and its bound parameters, // The m_sensor.reset() will release all callbacks and its bound parameters,
// therefore, handleSensorError accepts messages by value. // therefore, handleSensorError accepts messages by value.
sensor_.reset(); sensor_remote_.reset();
shared_buffer_reader_.reset(); shared_buffer_reader_.reset();
default_frequency_ = 0.0; default_frequency_ = 0.0;
frequency_limits_ = {0.0, 0.0}; frequency_limits_ = {0.0, 0.0};
client_binding_.Close(); client_receiver_.reset();
SensorProxy::ReportError(code, message); SensorProxy::ReportError(code, message);
} }
...@@ -174,8 +174,8 @@ void SensorProxyImpl::OnSensorCreated(SensorCreationResult result, ...@@ -174,8 +174,8 @@ void SensorProxyImpl::OnSensorCreated(SensorCreationResult result,
default_frequency_ = params->default_configuration->frequency; default_frequency_ = params->default_configuration->frequency;
DCHECK_GT(default_frequency_, 0.0); DCHECK_GT(default_frequency_, 0.0);
sensor_.Bind(std::move(params->sensor)); sensor_remote_.Bind(std::move(params->sensor));
client_binding_.Bind(std::move(params->client_request)); client_receiver_.Bind(std::move(params->client_request));
shared_buffer_reader_ = device::SensorReadingSharedBufferReader::Create( shared_buffer_reader_ = device::SensorReadingSharedBufferReader::Create(
std::move(params->memory), params->buffer_offset); std::move(params->memory), params->buffer_offset);
...@@ -197,7 +197,7 @@ void SensorProxyImpl::OnSensorCreated(SensorCreationResult result, ...@@ -197,7 +197,7 @@ void SensorProxyImpl::OnSensorCreated(SensorCreationResult result,
auto error_callback = auto error_callback =
WTF::Bind(&SensorProxyImpl::HandleSensorError, WrapWeakPersistent(this), WTF::Bind(&SensorProxyImpl::HandleSensorError, WrapWeakPersistent(this),
SensorCreationResult::ERROR_NOT_AVAILABLE); SensorCreationResult::ERROR_NOT_AVAILABLE);
sensor_.set_connection_error_handler(std::move(error_callback)); sensor_remote_.set_disconnect_handler(std::move(error_callback));
state_ = kInitialized; state_ = kInitialized;
......
...@@ -7,7 +7,8 @@ ...@@ -7,7 +7,8 @@
#include "third_party/blink/renderer/modules/sensor/sensor_proxy.h" #include "third_party/blink/renderer/modules/sensor/sensor_proxy.h"
#include "mojo/public/cpp/bindings/binding.h" #include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "third_party/blink/renderer/platform/heap/handle.h" #include "third_party/blink/renderer/platform/heap/handle.h"
#include "third_party/blink/renderer/platform/timer.h" #include "third_party/blink/renderer/platform/timer.h"
#include "third_party/blink/renderer/platform/wtf/vector.h" #include "third_party/blink/renderer/platform/wtf/vector.h"
...@@ -77,8 +78,8 @@ class SensorProxyImpl final : public SensorProxy, ...@@ -77,8 +78,8 @@ class SensorProxyImpl final : public SensorProxy,
device::mojom::blink::ReportingMode mode_ = device::mojom::blink::ReportingMode mode_ =
device::mojom::blink::ReportingMode::CONTINUOUS; device::mojom::blink::ReportingMode::CONTINUOUS;
device::mojom::blink::SensorPtr sensor_; mojo::Remote<device::mojom::blink::Sensor> sensor_remote_;
mojo::Binding<device::mojom::blink::SensorClient> client_binding_; mojo::Receiver<device::mojom::blink::SensorClient> client_receiver_{this};
std::unique_ptr<device::SensorReadingSharedBufferReader> std::unique_ptr<device::SensorReadingSharedBufferReader>
shared_buffer_reader_; shared_buffer_reader_;
......
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