Commit 483de1b0 authored by Findit's avatar Findit

Revert "Migrate hid.mojom and related classes to the new Mojo types"

This reverts commit fd82f584.

Reason for revert:

Findit (https://goo.gl/kROfz5) identified CL at revision 689336 as the
culprit for failures in the build cycles as shown on:
https://analysis.chromium.org/waterfall/culprit?key=ag9zfmZpbmRpdC1mb3ItbWVyRAsSDVdmU3VzcGVjdGVkQ0wiMWNocm9taXVtL2ZkODJmNTg0Y2MzMDhkZDkxYWExMTIwNjNhODRhZDQ5ZWQ2YjhkYTMM

Sample Failed Build: https://ci.chromium.org/buildbot/chromium.chromiumos/linux-chromeos-rel/28411

Sample Failed Step: compile

Original change's description:
> Migrate hid.mojom and related classes to the new Mojo types
> 
> This CL converts hid.mojom and related classes from old Mojo types
> to the new types. Major changes are as below,
> 
>  - Apply PendingRemote to HidConnectionClientPtr.
>  - Replace InterfacePtr with mojo::Remote
>  - Replace mojo::Binding with mojo::Receiver
> 
> Bug: 955171
> Change-Id: If4b686844272cd1763be50ff7620e00e1084a108
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1761874
> Reviewed-by: Kinuko Yasuda <kinuko@chromium.org>
> Reviewed-by: Ken Rockot <rockot@google.com>
> Commit-Queue: Gyuyoung Kim <gyuyoung@igalia.com>
> Cr-Commit-Position: refs/heads/master@{#689336}


Change-Id: I9444d50f890dfd4b84ecdf78bd8d7a78dd6c83f5
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 955171
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1764556
Cr-Commit-Position: refs/heads/master@{#689349}
parent 794aa5f9
......@@ -71,10 +71,9 @@ void HidService::RequestDevice(
weak_factory_.GetWeakPtr(), std::move(callback)));
}
void HidService::Connect(
const std::string& device_guid,
mojo::PendingRemote<device::mojom::HidConnectionClient> client,
ConnectCallback callback) {
void HidService::Connect(const std::string& device_guid,
device::mojom::HidConnectionClientPtr client,
ConnectCallback callback) {
GetContentClient()
->browser()
->GetHidDelegate()
......
......@@ -13,7 +13,6 @@
#include "base/memory/weak_ptr.h"
#include "content/public/browser/frame_service_base.h"
#include "mojo/public/cpp/bindings/binding_set.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "services/device/public/mojom/hid.mojom.h"
#include "third_party/blink/public/mojom/hid/hid.mojom.h"
......@@ -33,7 +32,7 @@ class HidService : public content::FrameServiceBase<blink::mojom::HidService> {
void RequestDevice(std::vector<blink::mojom::HidDeviceFilterPtr> filters,
RequestDeviceCallback callback) override;
void Connect(const std::string& device_guid,
mojo::PendingRemote<device::mojom::HidConnectionClient> client,
device::mojom::HidConnectionClientPtr client,
ConnectCallback callback) override;
private:
......
......@@ -172,9 +172,8 @@ TEST_F(HidServiceTest, OpenAndCloseHidConnection) {
device_info->guid = kTestGuid;
hid_manager()->AddDevice(std::move(device_info));
mojo::PendingRemote<device::mojom::HidConnectionClient> hid_connection_client;
connection_client()->Bind(
hid_connection_client.InitWithNewPipeAndPassReceiver());
device::mojom::HidConnectionClientPtr hid_connection_client;
connection_client()->Bind(mojo::MakeRequest(&hid_connection_client));
base::RunLoop run_loop;
device::mojom::HidConnectionPtr connection;
......
......@@ -170,7 +170,7 @@ void FakeFidoHidManager::GetDevices(GetDevicesCallback callback) {
void FakeFidoHidManager::Connect(
const std::string& device_guid,
mojo::PendingRemote<mojom::HidConnectionClient> connection_client,
mojom::HidConnectionClientPtr connection_client,
ConnectCallback callback) {
auto device_it = devices_.find(device_guid);
auto connection_it = connections_.find(device_guid);
......
......@@ -107,10 +107,9 @@ class FakeFidoHidManager : public device::mojom::HidManager {
device::mojom::HidManagerClientAssociatedPtrInfo client,
GetDevicesCallback callback) override;
void GetDevices(GetDevicesCallback callback) override;
void Connect(
const std::string& device_guid,
mojo::PendingRemote<mojom::HidConnectionClient> connection_client,
ConnectCallback callback) override;
void Connect(const std::string& device_guid,
mojom::HidConnectionClientPtr connection_client,
ConnectCallback callback) override;
void AddBinding(mojo::ScopedMessagePipeHandle handle);
void AddBinding2(device::mojom::HidManagerRequest request);
void AddDevice(device::mojom::HidDeviceInfoPtr device);
......
......@@ -174,8 +174,7 @@ FidoHidDevice::PendingTransaction::~PendingTransaction() = default;
void FidoHidDevice::Connect(
device::mojom::HidManager::ConnectCallback callback) {
DCHECK(hid_manager_);
hid_manager_->Connect(device_info_->guid,
mojo::PendingRemote<mojom::HidConnectionClient>(),
hid_manager_->Connect(device_info_->guid, /*connection_client=*/nullptr,
std::move(callback));
}
......
......@@ -1122,8 +1122,7 @@ void NintendoController::UpdateRightGamepadState(Gamepad& pad,
void NintendoController::Connect(mojom::HidManager::ConnectCallback callback) {
DCHECK(!is_composite_);
DCHECK(hid_manager_);
hid_manager_->Connect(device_info_->guid,
mojo::PendingRemote<mojom::HidConnectionClient>(),
hid_manager_->Connect(device_info_->guid, /*connection_client=*/nullptr,
std::move(callback));
}
......
......@@ -24,11 +24,9 @@
#include "extensions/common/permissions/usb_device_permission.h"
#include "mojo/public/cpp/bindings/callback_helpers.h"
#include "mojo/public/cpp/bindings/interface_request.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "services/device/public/cpp/hid/hid_device_filter.h"
#include "services/device/public/cpp/hid/hid_usage_and_page.h"
#include "services/device/public/mojom/constants.mojom.h"
#include "services/device/public/mojom/hid.mojom-blink.h"
#include "services/service_manager/public/cpp/connector.h"
namespace hid = extensions::api::hid;
......@@ -172,10 +170,9 @@ void HidDeviceManager::Connect(const std::string& device_guid,
ConnectCallback callback) {
DCHECK(initialized_);
hid_manager_->Connect(
device_guid, mojo::PendingRemote<device::mojom::HidConnectionClient>(),
mojo::WrapCallbackWithDefaultInvokeIfNotRun(std::move(callback),
nullptr));
hid_manager_->Connect(device_guid, /*connection_client=*/nullptr,
mojo::WrapCallbackWithDefaultInvokeIfNotRun(
std::move(callback), nullptr));
}
bool HidDeviceManager::HasPermission(
......
......@@ -11,11 +11,11 @@ namespace device {
HidConnectionImpl::HidConnectionImpl(
scoped_refptr<device::HidConnection> connection,
mojo::PendingRemote<mojom::HidConnectionClient> connection_client)
mojom::HidConnectionClientPtr connection_client)
: hid_connection_(std::move(connection)) {
if (connection_client) {
hid_connection_->SetClient(this);
client_.Bind(std::move(connection_client));
client_ = std::move(connection_client);
}
}
......
......@@ -6,7 +6,7 @@
#define SERVICES_DEVICE_HID_HID_CONNECTION_IMPL_H_
#include "base/memory/ref_counted.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "mojo/public/cpp/bindings/interface_ptr.h"
#include "services/device/hid/hid_connection.h"
#include "services/device/public/mojom/hid.mojom.h"
......@@ -18,9 +18,8 @@ namespace device {
class HidConnectionImpl : public mojom::HidConnection,
public HidConnection::Client {
public:
HidConnectionImpl(
scoped_refptr<device::HidConnection> connection,
mojo::PendingRemote<mojom::HidConnectionClient> connection_client);
HidConnectionImpl(scoped_refptr<device::HidConnection> connection,
mojom::HidConnectionClientPtr connection_client);
~HidConnectionImpl() final;
// HidConnection::Client implementation:
......@@ -51,7 +50,7 @@ class HidConnectionImpl : public mojom::HidConnection,
void OnSendFeatureReport(SendFeatureReportCallback callback, bool success);
scoped_refptr<device::HidConnection> hid_connection_;
mojo::Remote<mojom::HidConnectionClient> client_;
mojo::InterfacePtr<mojom::HidConnectionClient> client_;
base::WeakPtrFactory<HidConnectionImpl> weak_factory_{this};
......
......@@ -156,11 +156,10 @@ class HidConnectionImplTest : public DeviceServiceTestBase {
}
void CreateHidConnection(bool with_connection_client) {
mojo::PendingRemote<mojom::HidConnectionClient> hid_connection_client;
mojom::HidConnectionClientPtr hid_connection_client;
if (with_connection_client) {
connection_client_ = std::make_unique<TestHidConnectionClient>();
connection_client_->Bind(
hid_connection_client.InitWithNewPipeAndPassReceiver());
connection_client_->Bind(mojo::MakeRequest(&hid_connection_client));
}
fake_connection_ = new FakeHidConnection(CreateTestDevice());
hid_connection_impl_ = std::make_unique<HidConnectionImpl>(
......
......@@ -68,10 +68,9 @@ void HidManagerImpl::CreateDeviceList(
clients_.AddPtr(std::move(client_ptr));
}
void HidManagerImpl::Connect(
const std::string& device_guid,
mojo::PendingRemote<mojom::HidConnectionClient> connection_client,
ConnectCallback callback) {
void HidManagerImpl::Connect(const std::string& device_guid,
mojom::HidConnectionClientPtr connection_client,
ConnectCallback callback) {
hid_service_->Connect(
device_guid,
base::AdaptCallbackForRepeating(base::BindOnce(
......@@ -81,7 +80,7 @@ void HidManagerImpl::Connect(
void HidManagerImpl::CreateConnection(
ConnectCallback callback,
mojo::PendingRemote<mojom::HidConnectionClient> connection_client,
mojom::HidConnectionClientPtr connection_client,
scoped_refptr<HidConnection> connection) {
if (!connection) {
std::move(callback).Run(nullptr);
......
......@@ -36,20 +36,18 @@ class HidManagerImpl : public mojom::HidManager, public HidService::Observer {
void GetDevicesAndSetClient(mojom::HidManagerClientAssociatedPtrInfo client,
GetDevicesCallback callback) override;
void GetDevices(GetDevicesCallback callback) override;
void Connect(
const std::string& device_guid,
mojo::PendingRemote<mojom::HidConnectionClient> connection_client,
ConnectCallback callback) override;
void Connect(const std::string& device_guid,
mojom::HidConnectionClientPtr connection_client,
ConnectCallback callback) override;
private:
void CreateDeviceList(GetDevicesCallback callback,
mojom::HidManagerClientAssociatedPtrInfo client,
std::vector<mojom::HidDeviceInfoPtr> devices);
void CreateConnection(
ConnectCallback callback,
mojo::PendingRemote<mojom::HidConnectionClient> connection_client,
scoped_refptr<HidConnection> connection);
void CreateConnection(ConnectCallback callback,
mojom::HidConnectionClientPtr connection_client,
scoped_refptr<HidConnection> connection);
// HidService::Observer:
void OnDeviceAdded(mojom::HidDeviceInfoPtr device_info) override;
......
......@@ -245,8 +245,7 @@ TEST_F(HidManagerTest, TestHidConnectionInterface) {
{
base::RunLoop run_loop;
hid_manager_->Connect(
device0->device_guid(),
mojo::PendingRemote<mojom::HidConnectionClient>(),
device0->device_guid(), /*connection_client=*/nullptr,
base::BindOnce(&OnConnect, run_loop.QuitClosure(), client.get()));
run_loop.Run();
}
......
......@@ -117,10 +117,9 @@ void FakeHidManager::GetDevices(GetDevicesCallback callback) {
std::move(callback).Run(std::move(device_list));
}
void FakeHidManager::Connect(
const std::string& device_guid,
mojo::PendingRemote<mojom::HidConnectionClient> connection_client,
ConnectCallback callback) {
void FakeHidManager::Connect(const std::string& device_guid,
mojom::HidConnectionClientPtr connection_client,
ConnectCallback callback) {
if (!base::Contains(devices_, device_guid)) {
std::move(callback).Run(nullptr);
return;
......
......@@ -11,7 +11,6 @@
#include "mojo/public/cpp/bindings/binding_set.h"
#include "mojo/public/cpp/bindings/interface_ptr_set.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "services/device/public/mojom/hid.mojom.h"
namespace device {
......@@ -48,10 +47,9 @@ class FakeHidManager : public mojom::HidManager {
void GetDevicesAndSetClient(mojom::HidManagerClientAssociatedPtrInfo client,
GetDevicesCallback callback) override;
void GetDevices(GetDevicesCallback callback) override;
void Connect(
const std::string& device_guid,
mojo::PendingRemote<mojom::HidConnectionClient> connection_client,
ConnectCallback callback) override;
void Connect(const std::string& device_guid,
mojom::HidConnectionClientPtr connection_client,
ConnectCallback callback) override;
mojom::HidDeviceInfoPtr CreateAndAddDevice(uint16_t vendor_id,
uint16_t product_id,
......
......@@ -323,8 +323,7 @@ interface HidManager {
// Opens a connection to a device by given guid. The callback will be run
// with null on failure. If a connection client is provided, it will be
// notified when input reports are received.
Connect(string device_guid,
pending_remote<HidConnectionClient>? connection_client)
Connect(string device_guid, HidConnectionClient? connection_client)
=> (HidConnection? connection);
};
......
......@@ -85,6 +85,6 @@ interface HidService {
// will be notified when an input report is received from the device.
// |connection| contains the opened connection, or nullptr if the device could
// not be opened.
Connect(string device_guid, pending_remote<device.mojom.HidConnectionClient> client)
Connect(string device_guid, device.mojom.HidConnectionClient client)
=> (device.mojom.HidConnection? connection);
};
......@@ -175,10 +175,9 @@ ScriptPromise HID::requestDevice(ScriptState* script_state,
return promise;
}
void HID::Connect(
const String& device_guid,
mojo::PendingRemote<device::mojom::blink::HidConnectionClient> client,
device::mojom::blink::HidManager::ConnectCallback callback) {
void HID::Connect(const String& device_guid,
device::mojom::blink::HidConnectionClientPtr client,
device::mojom::blink::HidManager::ConnectCallback callback) {
EnsureServiceConnection();
service_->Connect(device_guid, std::move(client), std::move(callback));
}
......@@ -231,8 +230,8 @@ void HID::EnsureServiceConnection() {
auto task_runner =
GetExecutionContext()->GetTaskRunner(TaskType::kMiscPlatformAPI);
GetExecutionContext()->GetInterfaceProvider()->GetInterface(
service_.BindNewPipeAndPassReceiver(task_runner));
service_.set_disconnect_handler(
mojo::MakeRequest(&service_, task_runner));
service_.set_connection_error_handler(
WTF::Bind(&HID::OnServiceConnectionError, WrapWeakPersistent(this)));
}
......
......@@ -5,7 +5,6 @@
#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_HID_HID_H_
#define THIRD_PARTY_BLINK_RENDERER_MODULES_HID_HID_H_
#include "mojo/public/cpp/bindings/remote.h"
#include "services/device/public/mojom/hid.mojom-blink.h"
#include "third_party/blink/public/mojom/hid/hid.mojom-blink.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise.h"
......@@ -41,8 +40,7 @@ class HID : public EventTargetWithInlineData, public ContextLifecycleObserver {
ScriptPromise requestDevice(ScriptState*, const HIDDeviceRequestOptions*);
void Connect(const String& device_guid,
mojo::PendingRemote<device::mojom::blink::HidConnectionClient>
connection_client,
device::mojom::blink::HidConnectionClientPtr connection_client,
device::mojom::blink::HidManager::ConnectCallback callback);
void Trace(blink::Visitor*) override;
......@@ -66,7 +64,7 @@ class HID : public EventTargetWithInlineData, public ContextLifecycleObserver {
void FinishRequestDevice(ScriptPromiseResolver*,
device::mojom::blink::HidDeviceInfoPtr);
mojo::Remote<mojom::blink::HidService> service_;
mojom::blink::HidServicePtr service_;
HeapHashSet<Member<ScriptPromiseResolver>> get_devices_promises_;
HeapHashSet<Member<ScriptPromiseResolver>> request_device_promises_;
HeapHashMap<String, WeakMember<HIDDevice>> device_cache_;
......
......@@ -87,7 +87,8 @@ HIDDevice::HIDDevice(HID* parent,
ExecutionContext* context)
: ContextLifecycleObserver(context),
parent_(parent),
device_info_(std::move(info)) {
device_info_(std::move(info)),
binding_(this) {
DCHECK(device_info_);
for (const auto& collection : device_info_->collections) {
// Omit information about top-level collections with protected usages.
......@@ -149,8 +150,8 @@ ScriptPromise HIDDevice::open(ScriptState* script_state) {
return promise;
}
mojo::PendingRemote<device::mojom::blink::HidConnectionClient> client;
receiver_.Bind(client.InitWithNewPipeAndPassReceiver());
device::mojom::blink::HidConnectionClientPtr client;
binding_.Bind(mojo::MakeRequest(&client));
device_state_change_in_progress_ = true;
device_requests_.insert(resolver);
......@@ -242,7 +243,8 @@ ScriptPromise HIDDevice::receiveFeatureReport(ScriptState* script_state,
void HIDDevice::ContextDestroyed(ExecutionContext*) {
connection_.reset();
device_requests_.clear();
receiver_.reset();
if (binding_)
binding_.Close();
}
void HIDDevice::Trace(blink::Visitor* visitor) {
......@@ -257,7 +259,8 @@ void HIDDevice::Trace(blink::Visitor* visitor) {
void HIDDevice::Dispose() {
// The connection client binding holds a raw pointer to this object which must
// be released when it becomes garbage.
receiver_.reset();
if (binding_)
binding_.Close();
}
bool HIDDevice::EnsureNoDeviceChangeInProgress(
......
......@@ -5,7 +5,7 @@
#ifndef THIRD_PARTY_BLINK_RENDERER_MODULES_HID_HID_DEVICE_H_
#define THIRD_PARTY_BLINK_RENDERER_MODULES_HID_HID_DEVICE_H_
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "services/device/public/mojom/hid.mojom-blink.h"
#include "third_party/blink/public/mojom/hid/hid.mojom-blink.h"
#include "third_party/blink/renderer/bindings/core/v8/array_buffer_or_array_buffer_view.h"
......@@ -96,7 +96,7 @@ class MODULES_EXPORT HIDDevice
Member<HID> parent_;
device::mojom::blink::HidDeviceInfoPtr device_info_;
device::mojom::blink::HidConnectionPtr connection_;
mojo::Receiver<device::mojom::blink::HidConnectionClient> receiver_{this};
mojo::Binding<device::mojom::blink::HidConnectionClient> binding_;
HeapHashSet<Member<ScriptPromiseResolver>> device_requests_;
HeapVector<Member<HIDCollectionInfo>> collections_;
bool device_state_change_in_progress_ = false;
......
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