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 @@ ...@@ -41,6 +41,7 @@
#include "third_party/blink/renderer/modules/webmidi/midi_output.h" #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_output_map.h"
#include "third_party/blink/renderer/modules/webmidi/midi_port.h" #include "third_party/blink/renderer/modules/webmidi/midi_port.h"
#include "third_party/blink/renderer/platform/heap/heap.h"
namespace blink { namespace blink {
...@@ -70,11 +71,11 @@ MIDIAccess::MIDIAccess( ...@@ -70,11 +71,11 @@ MIDIAccess::MIDIAccess(
dispatcher_->SetClient(this); dispatcher_->SetClient(this);
for (const auto& port : ports) { for (const auto& port : ports) {
if (port.type == MIDIPort::kTypeInput) { if (port.type == MIDIPort::kTypeInput) {
inputs_.push_back(MIDIInput::Create(this, port.id, port.manufacturer, inputs_.push_back(MakeGarbageCollected<MIDIInput>(
port.name, port.version, this, port.id, port.manufacturer, port.name, port.version,
ToDeviceState(port.state))); ToDeviceState(port.state)));
} else { } else {
outputs_.push_back(MIDIOutput::Create( outputs_.push_back(MakeGarbageCollected<MIDIOutput>(
this, outputs_.size(), port.id, port.manufacturer, port.name, this, outputs_.size(), port.id, port.manufacturer, port.name,
port.version, ToDeviceState(port.state))); port.version, ToDeviceState(port.state)));
} }
...@@ -139,8 +140,8 @@ void MIDIAccess::DidAddInputPort(const String& id, ...@@ -139,8 +140,8 @@ void MIDIAccess::DidAddInputPort(const String& id,
const String& version, const String& version,
PortState state) { PortState state) {
DCHECK(IsMainThread()); DCHECK(IsMainThread());
MIDIInput* port = MIDIInput::Create(this, id, manufacturer, name, version, auto* port = MakeGarbageCollected<MIDIInput>(this, id, manufacturer, name,
ToDeviceState(state)); version, ToDeviceState(state));
inputs_.push_back(port); inputs_.push_back(port);
DispatchEvent(*MIDIConnectionEvent::Create(port)); DispatchEvent(*MIDIConnectionEvent::Create(port));
} }
...@@ -152,8 +153,8 @@ void MIDIAccess::DidAddOutputPort(const String& id, ...@@ -152,8 +153,8 @@ void MIDIAccess::DidAddOutputPort(const String& id,
PortState state) { PortState state) {
DCHECK(IsMainThread()); DCHECK(IsMainThread());
unsigned port_index = outputs_.size(); unsigned port_index = outputs_.size();
MIDIOutput* port = MIDIOutput::Create(this, port_index, id, manufacturer, auto* port = MakeGarbageCollected<MIDIOutput>(
name, version, ToDeviceState(state)); this, port_index, id, manufacturer, name, version, ToDeviceState(state));
outputs_.push_back(port); outputs_.push_back(port);
DispatchEvent(*MIDIConnectionEvent::Create(port)); DispatchEvent(*MIDIConnectionEvent::Create(port));
} }
......
...@@ -59,15 +59,6 @@ class MIDIAccess final : public EventTargetWithInlineData, ...@@ -59,15 +59,6 @@ class MIDIAccess final : public EventTargetWithInlineData,
USING_PRE_FINALIZER(MIDIAccess, Dispose); USING_PRE_FINALIZER(MIDIAccess, Dispose);
public: 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>, MIDIAccess(std::unique_ptr<MIDIDispatcher>,
bool sysex_enabled, bool sysex_enabled,
const Vector<MIDIAccessInitializer::PortDescriptor>&, const Vector<MIDIAccessInitializer::PortDescriptor>&,
......
...@@ -108,7 +108,7 @@ void MIDIAccessInitializer::DidStartSession(Result result) { ...@@ -108,7 +108,7 @@ void MIDIAccessInitializer::DidStartSession(Result result) {
case Result::NOT_INITIALIZED: case Result::NOT_INITIALIZED:
break; break;
case Result::OK: case Result::OK:
return Resolve(MIDIAccess::Create( return Resolve(MakeGarbageCollected<MIDIAccess>(
std::move(dispatcher_), options_->hasSysex() && options_->sysex(), std::move(dispatcher_), options_->hasSysex() && options_->sysex(),
port_descriptors_, GetExecutionContext())); port_descriptors_, GetExecutionContext()));
case Result::NOT_SUPPORTED: case Result::NOT_SUPPORTED:
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include "third_party/blink/renderer/modules/webmidi/midi_access.h" #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/modules/webmidi/midi_message_event.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/heap/heap.h"
#include "third_party/blink/renderer/platform/instrumentation/use_counter.h" #include "third_party/blink/renderer/platform/instrumentation/use_counter.h"
#include "third_party/blink/renderer/platform/wtf/std_lib_extras.h" #include "third_party/blink/renderer/platform/wtf/std_lib_extras.h"
...@@ -42,17 +43,6 @@ namespace blink { ...@@ -42,17 +43,6 @@ namespace blink {
using midi::mojom::PortState; 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, MIDIInput::MIDIInput(MIDIAccess* access,
const String& id, const String& id,
const String& manufacturer, const String& manufacturer,
...@@ -103,7 +93,7 @@ void MIDIInput::DidReceiveMIDIData(unsigned port_index, ...@@ -103,7 +93,7 @@ void MIDIInput::DidReceiveMIDIData(unsigned port_index,
return; return;
DOMUint8Array* array = DOMUint8Array* array =
DOMUint8Array::Create(data, SafeCast<unsigned>(length)); DOMUint8Array::Create(data, SafeCast<unsigned>(length));
DispatchEvent(*MIDIMessageEvent::Create(time_stamp, array)); DispatchEvent(*MakeGarbageCollected<MIDIMessageEvent>(time_stamp, array));
UseCounter::Count(*To<Document>(GetExecutionContext()), UseCounter::Count(*To<Document>(GetExecutionContext()),
WebFeature::kMIDIMessageEvent); WebFeature::kMIDIMessageEvent);
......
...@@ -43,13 +43,6 @@ class MIDIInput final : public MIDIPort { ...@@ -43,13 +43,6 @@ class MIDIInput final : public MIDIPort {
DEFINE_WRAPPERTYPEINFO(); DEFINE_WRAPPERTYPEINFO();
public: public:
static MIDIInput* Create(MIDIAccess*,
const String& id,
const String& manufacturer,
const String& name,
const String& version,
midi::mojom::PortState);
MIDIInput(MIDIAccess*, MIDIInput(MIDIAccess*,
const String& id, const String& id,
const String& manufacturer, const String& manufacturer,
......
...@@ -44,11 +44,6 @@ class MIDIMessageEvent final : public Event { ...@@ -44,11 +44,6 @@ class MIDIMessageEvent final : public Event {
DEFINE_WRAPPERTYPEINFO(); DEFINE_WRAPPERTYPEINFO();
public: public:
static MIDIMessageEvent* Create(base::TimeTicks time_stamp,
DOMUint8Array* data) {
return MakeGarbageCollected<MIDIMessageEvent>(time_stamp, data);
}
static MIDIMessageEvent* Create(const AtomicString& type, static MIDIMessageEvent* Create(const AtomicString& type,
const MIDIMessageEventInit* initializer) { const MIDIMessageEventInit* initializer) {
return MakeGarbageCollected<MIDIMessageEvent>(type, initializer); return MakeGarbageCollected<MIDIMessageEvent>(type, initializer);
......
...@@ -229,18 +229,6 @@ class MessageValidator { ...@@ -229,18 +229,6 @@ class MessageValidator {
} // namespace } // 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, MIDIOutput::MIDIOutput(MIDIAccess* access,
unsigned port_index, unsigned port_index,
const String& id, const String& id,
......
...@@ -47,14 +47,6 @@ class MIDIOutput final : public MIDIPort { ...@@ -47,14 +47,6 @@ class MIDIOutput final : public MIDIPort {
DEFINE_WRAPPERTYPEINFO(); DEFINE_WRAPPERTYPEINFO();
public: 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*, MIDIOutput(MIDIAccess*,
unsigned port_index, unsigned port_index,
const String& id, 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