Allow missing socketType in SocketInfo if socket is not connected

BUG=242261

Review URL: https://chromiumcodereview.appspot.com/15359007

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@203036 0039d316-1c4b-4281-b951-d872f2087c98
parent 2ff3ed41
...@@ -616,9 +616,13 @@ bool SocketGetInfoFunction::Prepare() { ...@@ -616,9 +616,13 @@ bool SocketGetInfoFunction::Prepare() {
} }
void SocketGetInfoFunction::Work() { void SocketGetInfoFunction::Work() {
api::socket::SocketInfo info;
Socket* socket = GetSocket(params_->socket_id); Socket* socket = GetSocket(params_->socket_id);
if (socket) { if (!socket) {
error_ = kSocketNotFoundError;
return;
}
api::socket::SocketInfo info;
// This represents what we know about the socket, and does not call through // This represents what we know about the socket, and does not call through
// to the system. // to the system.
if (socket->GetSocketType() == Socket::TYPE_TCP) if (socket->GetSocketType() == Socket::TYPE_TCP)
...@@ -645,9 +649,7 @@ void SocketGetInfoFunction::Work() { ...@@ -645,9 +649,7 @@ void SocketGetInfoFunction::Work() {
new std::string(localAddress.ToStringWithoutPort())); new std::string(localAddress.ToStringWithoutPort()));
info.local_port.reset(new int(localAddress.port())); info.local_port.reset(new int(localAddress.port()));
} }
} else {
error_ = kSocketNotFoundError;
}
SetResult(info.ToValue().release()); SetResult(info.ToValue().release());
} }
......
...@@ -55,8 +55,10 @@ var testSocketCreation = function() { ...@@ -55,8 +55,10 @@ var testSocketCreation = function() {
} }
socket.destroy(socketInfo.socketId); socket.destroy(socketInfo.socketId);
socket.getInfo(socketInfo.socketId, function(info) {
chrome.test.assertEq(undefined, info);
chrome.test.succeed(); chrome.test.succeed();
});
} }
chrome.test.assertTrue(socketInfo.socketId > 0); chrome.test.assertTrue(socketInfo.socketId > 0);
......
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