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