Commit da421fab authored by sammc's avatar sammc Committed by Commit bot

Make some fields non-nullable in serial.mojom and data_stream.mojom.

This also removes some null checks for the now non-nullable fields.

BUG=407683

Review URL: https://codereview.chromium.org/562563002

Cr-Commit-Position: refs/heads/master@{#294277}
parent afd3e88b
......@@ -89,7 +89,7 @@ DataSinkReceiver::~DataSinkReceiver() {
}
void DataSinkReceiver::Init(mojo::ScopedDataPipeConsumerHandle handle) {
if (!handle.is_valid() || handle_.is_valid()) {
if (handle_.is_valid()) {
DispatchFatalError();
return;
}
......
......@@ -90,9 +90,8 @@ DataSourceSender::~DataSourceSender() {
void DataSourceSender::Init(mojo::ScopedDataPipeProducerHandle handle) {
// This should never occur. |handle_| is only valid and |pending_send_| is
// only set after Init is called. Receiving an invalid |handle| from the
// client is also unrecoverable.
if (pending_send_ || handle_.is_valid() || !handle.is_valid() || shut_down_) {
// only set after Init is called.
if (pending_send_ || handle_.is_valid() || shut_down_) {
DispatchFatalError();
return;
}
......
......@@ -8,7 +8,7 @@ module device.serial {
interface DataSource {
// Initializes this DataSource with a data pipe handle to use for data
// transmission.
Init(handle<data_pipe_producer>? producer_handle);
Init(handle<data_pipe_producer> producer_handle);
// Resumes sending data after it has been stopped due to an error.
Resume();
......@@ -25,7 +25,7 @@ interface DataSourceClient {
interface DataSink {
// Initializes this DataSink with a data pipe handle to use for data
// transmission.
Init(handle<data_pipe_consumer>? consumer_handle);
Init(handle<data_pipe_consumer> consumer_handle);
// Requests the cancellation of any data that has been written to the pipe,
// but has not yet been sent to the sink.
......
......@@ -7,7 +7,7 @@ import "data_stream.mojom"
module device.serial {
struct DeviceInfo {
string? path;
string path;
uint16 vendor_id;
bool has_vendor_id = false;
uint16 product_id;
......@@ -82,7 +82,7 @@ struct DeviceControlSignals {
};
interface SerialService {
GetDevices() => (DeviceInfo?[]? devices);
GetDevices() => (DeviceInfo[] devices);
// Creates a |Connection| to |path| with options specified by |options|,
// returning it via |connection|. Sending and receiving data over this
......@@ -90,17 +90,17 @@ interface SerialService {
// and |connection| will not be usable if |path| does not specify a valid
// serial device or there is an error connecting to or configuring the
// connection.
Connect(string? path,
Connect(string path,
ConnectionOptions? options,
Connection&? connection,
DataSink&? sink,
DataSource&? source);
Connection& connection,
DataSink& sink,
DataSource& source);
};
interface Connection {
GetInfo() => (ConnectionInfo? info);
SetOptions(ConnectionOptions? options) => (bool success);
SetControlSignals(HostControlSignals? signals) => (bool success);
SetOptions(ConnectionOptions options) => (bool success);
SetControlSignals(HostControlSignals signals) => (bool success);
GetControlSignals() => (DeviceControlSignals? signals);
Flush() => (bool success);
};
......
......@@ -33,6 +33,7 @@ class FakeSerialDeviceEnumerator : public device::SerialDeviceEnumerator {
result[1]->vendor_id = 1234;
result[1]->product_id = 5678;
result[2] = device::serial::DeviceInfo::New();
result[2]->path = "";
result[2]->display_name = "";
return result.Pass();
}
......
......@@ -30,7 +30,7 @@ define('serial_service', [
function getDevices() {
return service.getDevices().then(function(response) {
return $Array.map(response.devices, function(device) {
var result = {path: device.path || ''};
var result = {path: device.path};
if (device.has_vendor_id)
result.vendorId = device.vendor_id;
if (device.has_product_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