Commit e5aa7c72 authored by Gyuyoung Kim's avatar Gyuyoung Kim Committed by Commit Bot

Inline static Create() factory functions from renderer/modules/webmidi

This CL removes Create() factory functions in
//third_partyb/blink/renderer/modules/webmidi as much as possible, and
makes all callers use MakeGarbageCollected<Foo> instead.

This CL removes below factory functions,
  - MIDIAccess::Create
  - MIDIInput::Create
  - MIDIMessageEvent::Create
  - MIDIOutput::Create

Bug: 939691
Change-Id: Ic8342bd035c5b52c569bec574878db0e60b6f1af
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1946172Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Gyuyoung Kim <gyuyoung@igalia.com>
Cr-Commit-Position: refs/heads/master@{#720451}
parent 34976204
......@@ -41,6 +41,7 @@
#include "third_party/blink/renderer/modules/webmidi/midi_output.h"
#include "third_party/blink/renderer/modules/webmidi/midi_output_map.h"
#include "third_party/blink/renderer/modules/webmidi/midi_port.h"
#include "third_party/blink/renderer/platform/heap/heap.h"
namespace blink {
......@@ -70,11 +71,11 @@ MIDIAccess::MIDIAccess(
dispatcher_->SetClient(this);
for (const auto& port : ports) {
if (port.type == MIDIPort::kTypeInput) {
inputs_.push_back(MIDIInput::Create(this, port.id, port.manufacturer,
port.name, port.version,
ToDeviceState(port.state)));
inputs_.push_back(MakeGarbageCollected<MIDIInput>(
this, port.id, port.manufacturer, port.name, port.version,
ToDeviceState(port.state)));
} else {
outputs_.push_back(MIDIOutput::Create(
outputs_.push_back(MakeGarbageCollected<MIDIOutput>(
this, outputs_.size(), port.id, port.manufacturer, port.name,
port.version, ToDeviceState(port.state)));
}
......@@ -139,8 +140,8 @@ void MIDIAccess::DidAddInputPort(const String& id,
const String& version,
PortState state) {
DCHECK(IsMainThread());
MIDIInput* port = MIDIInput::Create(this, id, manufacturer, name, version,
ToDeviceState(state));
auto* port = MakeGarbageCollected<MIDIInput>(this, id, manufacturer, name,
version, ToDeviceState(state));
inputs_.push_back(port);
DispatchEvent(*MIDIConnectionEvent::Create(port));
}
......@@ -152,8 +153,8 @@ void MIDIAccess::DidAddOutputPort(const String& id,
PortState state) {
DCHECK(IsMainThread());
unsigned port_index = outputs_.size();
MIDIOutput* port = MIDIOutput::Create(this, port_index, id, manufacturer,
name, version, ToDeviceState(state));
auto* port = MakeGarbageCollected<MIDIOutput>(
this, port_index, id, manufacturer, name, version, ToDeviceState(state));
outputs_.push_back(port);
DispatchEvent(*MIDIConnectionEvent::Create(port));
}
......
......@@ -59,15 +59,6 @@ class MIDIAccess final : public EventTargetWithInlineData,
USING_PRE_FINALIZER(MIDIAccess, Dispose);
public:
static MIDIAccess* Create(
std::unique_ptr<MIDIDispatcher> dispatcher,
bool sysex_enabled,
const Vector<MIDIAccessInitializer::PortDescriptor>& ports,
ExecutionContext* execution_context) {
return MakeGarbageCollected<MIDIAccess>(
std::move(dispatcher), sysex_enabled, ports, execution_context);
}
MIDIAccess(std::unique_ptr<MIDIDispatcher>,
bool sysex_enabled,
const Vector<MIDIAccessInitializer::PortDescriptor>&,
......
......@@ -108,7 +108,7 @@ void MIDIAccessInitializer::DidStartSession(Result result) {
case Result::NOT_INITIALIZED:
break;
case Result::OK:
return Resolve(MIDIAccess::Create(
return Resolve(MakeGarbageCollected<MIDIAccess>(
std::move(dispatcher_), options_->hasSysex() && options_->sysex(),
port_descriptors_, GetExecutionContext()));
case Result::NOT_SUPPORTED:
......
......@@ -35,6 +35,7 @@
#include "third_party/blink/renderer/modules/webmidi/midi_access.h"
#include "third_party/blink/renderer/modules/webmidi/midi_message_event.h"
#include "third_party/blink/renderer/platform/heap/handle.h"
#include "third_party/blink/renderer/platform/heap/heap.h"
#include "third_party/blink/renderer/platform/instrumentation/use_counter.h"
#include "third_party/blink/renderer/platform/wtf/std_lib_extras.h"
......@@ -42,17 +43,6 @@ namespace blink {
using midi::mojom::PortState;
MIDIInput* MIDIInput::Create(MIDIAccess* access,
const String& id,
const String& manufacturer,
const String& name,
const String& version,
PortState state) {
DCHECK(access);
return MakeGarbageCollected<MIDIInput>(access, id, manufacturer, name,
version, state);
}
MIDIInput::MIDIInput(MIDIAccess* access,
const String& id,
const String& manufacturer,
......@@ -103,7 +93,7 @@ void MIDIInput::DidReceiveMIDIData(unsigned port_index,
return;
DOMUint8Array* array =
DOMUint8Array::Create(data, SafeCast<unsigned>(length));
DispatchEvent(*MIDIMessageEvent::Create(time_stamp, array));
DispatchEvent(*MakeGarbageCollected<MIDIMessageEvent>(time_stamp, array));
UseCounter::Count(*To<Document>(GetExecutionContext()),
WebFeature::kMIDIMessageEvent);
......
......@@ -43,13 +43,6 @@ class MIDIInput final : public MIDIPort {
DEFINE_WRAPPERTYPEINFO();
public:
static MIDIInput* Create(MIDIAccess*,
const String& id,
const String& manufacturer,
const String& name,
const String& version,
midi::mojom::PortState);
MIDIInput(MIDIAccess*,
const String& id,
const String& manufacturer,
......
......@@ -44,11 +44,6 @@ class MIDIMessageEvent final : public Event {
DEFINE_WRAPPERTYPEINFO();
public:
static MIDIMessageEvent* Create(base::TimeTicks time_stamp,
DOMUint8Array* data) {
return MakeGarbageCollected<MIDIMessageEvent>(time_stamp, data);
}
static MIDIMessageEvent* Create(const AtomicString& type,
const MIDIMessageEventInit* initializer) {
return MakeGarbageCollected<MIDIMessageEvent>(type, initializer);
......
......@@ -229,18 +229,6 @@ class MessageValidator {
} // namespace
MIDIOutput* MIDIOutput::Create(MIDIAccess* access,
unsigned port_index,
const String& id,
const String& manufacturer,
const String& name,
const String& version,
PortState state) {
DCHECK(access);
return MakeGarbageCollected<MIDIOutput>(access, port_index, id, manufacturer,
name, version, state);
}
MIDIOutput::MIDIOutput(MIDIAccess* access,
unsigned port_index,
const String& id,
......
......@@ -47,14 +47,6 @@ class MIDIOutput final : public MIDIPort {
DEFINE_WRAPPERTYPEINFO();
public:
static MIDIOutput* Create(MIDIAccess*,
unsigned port_index,
const String& id,
const String& manufacturer,
const String& name,
const String& version,
midi::mojom::PortState);
MIDIOutput(MIDIAccess*,
unsigned port_index,
const String& id,
......
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