Commit c00e6859 authored by miket@chromium.org's avatar miket@chromium.org

Pass through readInfo.resultCode.

BUG=124498
TEST=added


Review URL: http://codereview.chromium.org/10168021

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133501 0039d316-1c4b-4281-b951-d872f2087c98
parent df8c170a
...@@ -16,6 +16,7 @@ namespace extensions { ...@@ -16,6 +16,7 @@ namespace extensions {
const char kBytesWrittenKey[] = "bytesWritten"; const char kBytesWrittenKey[] = "bytesWritten";
const char kDataKey[] = "data"; const char kDataKey[] = "data";
const char kResultCodeKey[] = "resultCode";
const char kSocketIdKey[] = "socketId"; const char kSocketIdKey[] = "socketId";
const char kTCPOption[] = "tcp"; const char kTCPOption[] = "tcp";
const char kUDPOption[] = "udp"; const char kUDPOption[] = "udp";
...@@ -147,6 +148,7 @@ void SocketReadFunction::Work() { ...@@ -147,6 +148,7 @@ void SocketReadFunction::Work() {
data_value->Set(i, Value::CreateIntegerValue(io_buffer_start[i])); data_value->Set(i, Value::CreateIntegerValue(io_buffer_start[i]));
} }
} }
result->SetInteger(kResultCodeKey, bytes_read);
result->Set(kDataKey, data_value); result->Set(kDataKey, data_value);
result_.reset(result); result_.reset(result);
} }
......
...@@ -14,8 +14,9 @@ ...@@ -14,8 +14,9 @@
// that blocked. // that blocked.
DOMString type; DOMString type;
// The result code, if the event type is writeComplete. The result code // The result code, if the event type is dataRead or writeComplete. The
// description matches that of <code>writeInfo.bytesWritten</code>. // result code description matches the resultCode field in the immediate
// callback for the call that led to this event.
long? resultCode; long? resultCode;
// The data read, if the event type is dataRead. // The data read, if the event type is dataRead.
...@@ -52,6 +53,9 @@ ...@@ -52,6 +53,9 @@
callback ConnectCallback = void (long result); callback ConnectCallback = void (long result);
dictionary ReadInfo { dictionary ReadInfo {
// The resultCode returned from the underlying read() call.
long resultCode;
// The data received. Warning: will probably become a blob or other // The data received. Warning: will probably become a blob or other
// appropriate binary-friendly type. // appropriate binary-friendly type.
// TODO(miket): [instanceOf=ArrayBuffer]object data; // TODO(miket): [instanceOf=ArrayBuffer]object data;
......
...@@ -76,6 +76,10 @@ var testSocketCreation = function() { ...@@ -76,6 +76,10 @@ var testSocketCreation = function() {
}; };
function onDataRead(readInfo) { function onDataRead(readInfo) {
if (readInfo.resultCode > 0 || readInfo.data.length > 0) {
chrome.test.assertEq(readInfo.resultCode, readInfo.data.length);
}
// TODO(miket): this isn't correct for multiple calls of onDataRead. // TODO(miket): this isn't correct for multiple calls of onDataRead.
arrayBuffer2String(arrayOfLongsToArrayBuffer(readInfo.data), function(s) { arrayBuffer2String(arrayOfLongsToArrayBuffer(readInfo.data), function(s) {
dataAsString = s; // save this for error reporting dataAsString = s; // save this for error reporting
...@@ -115,7 +119,7 @@ function onEvent(socketEvent) { ...@@ -115,7 +119,7 @@ function onEvent(socketEvent) {
if (socketEvent.type == "connectComplete") { if (socketEvent.type == "connectComplete") {
onConnectComplete(socketEvent.resultCode); onConnectComplete(socketEvent.resultCode);
} else if (socketEvent.type == "dataRead") { } else if (socketEvent.type == "dataRead") {
onDataRead({data: socketEvent.data}); onDataRead({resultCode: socketEvent.resultCode, data: socketEvent.data});
} else if (socketEvent.type == "writeComplete") { } else if (socketEvent.type == "writeComplete") {
onWriteComplete(socketEvent.resultCode); onWriteComplete(socketEvent.resultCode);
} else { } else {
......
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