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,
SensorProviderProxy* provider,
Page* page)
: SensorProxy(sensor_type, provider, page),
client_binding_(this),
polling_timer_(
provider->GetSupplementable()->GetTaskRunner(TaskType::kSensor),
this,
......@@ -28,7 +27,7 @@ SensorProxyImpl::SensorProxyImpl(SensorType sensor_type,
SensorProxyImpl::~SensorProxyImpl() {}
void SensorProxyImpl::Dispose() {
client_binding_.Close();
client_receiver_.reset();
}
void SensorProxyImpl::Trace(blink::Visitor* visitor) {
......@@ -55,14 +54,15 @@ void SensorProxyImpl::AddConfiguration(
base::OnceCallback<void(bool)> callback) {
DCHECK(IsInitialized());
AddActiveFrequency(configuration->frequency);
sensor_->AddConfiguration(std::move(configuration), std::move(callback));
sensor_remote_->AddConfiguration(std::move(configuration),
std::move(callback));
}
void SensorProxyImpl::RemoveConfiguration(
SensorConfigurationPtr configuration) {
DCHECK(IsInitialized());
RemoveActiveFrequency(configuration->frequency);
sensor_->RemoveConfiguration(std::move(configuration));
sensor_remote_->RemoveConfiguration(std::move(configuration));
}
double SensorProxyImpl::GetDefaultFrequency() const {
......@@ -79,7 +79,7 @@ void SensorProxyImpl::Suspend() {
if (suspended_)
return;
sensor_->Suspend();
sensor_remote_->Suspend();
suspended_ = true;
UpdatePollingStatus();
}
......@@ -88,7 +88,7 @@ void SensorProxyImpl::Resume() {
if (!suspended_)
return;
sensor_->Resume();
sensor_remote_->Resume();
suspended_ = false;
UpdatePollingStatus();
}
......@@ -136,11 +136,11 @@ void SensorProxyImpl::ReportError(DOMExceptionCode code,
// The m_sensor.reset() will release all callbacks and its bound parameters,
// therefore, handleSensorError accepts messages by value.
sensor_.reset();
sensor_remote_.reset();
shared_buffer_reader_.reset();
default_frequency_ = 0.0;
frequency_limits_ = {0.0, 0.0};
client_binding_.Close();
client_receiver_.reset();
SensorProxy::ReportError(code, message);
}
......@@ -174,8 +174,8 @@ void SensorProxyImpl::OnSensorCreated(SensorCreationResult result,
default_frequency_ = params->default_configuration->frequency;
DCHECK_GT(default_frequency_, 0.0);
sensor_.Bind(std::move(params->sensor));
client_binding_.Bind(std::move(params->client_request));
sensor_remote_.Bind(std::move(params->sensor));
client_receiver_.Bind(std::move(params->client_request));
shared_buffer_reader_ = device::SensorReadingSharedBufferReader::Create(
std::move(params->memory), params->buffer_offset);
......@@ -197,7 +197,7 @@ void SensorProxyImpl::OnSensorCreated(SensorCreationResult result,
auto error_callback =
WTF::Bind(&SensorProxyImpl::HandleSensorError, WrapWeakPersistent(this),
SensorCreationResult::ERROR_NOT_AVAILABLE);
sensor_.set_connection_error_handler(std::move(error_callback));
sensor_remote_.set_disconnect_handler(std::move(error_callback));
state_ = kInitialized;
......
......@@ -7,7 +7,8 @@
#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/timer.h"
#include "third_party/blink/renderer/platform/wtf/vector.h"
......@@ -77,8 +78,8 @@ class SensorProxyImpl final : public SensorProxy,
device::mojom::blink::ReportingMode mode_ =
device::mojom::blink::ReportingMode::CONTINUOUS;
device::mojom::blink::SensorPtr sensor_;
mojo::Binding<device::mojom::blink::SensorClient> client_binding_;
mojo::Remote<device::mojom::blink::Sensor> sensor_remote_;
mojo::Receiver<device::mojom::blink::SensorClient> client_receiver_{this};
std::unique_ptr<device::SensorReadingSharedBufferReader>
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