Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2654)

Unified Diff: chrome/browser/extensions/api/socket/socket_api.cc

Issue 15359007: Allow missing socketType in SocketInfo if socket is not connected (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Changes as per asargent Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/test/data/extensions/api_test/socket/api/background.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/api/socket/socket_api.cc
diff --git a/chrome/browser/extensions/api/socket/socket_api.cc b/chrome/browser/extensions/api/socket/socket_api.cc
index 49699d26b932aafe61c2bec7ef0062f6bbd045b7..03cc5a9885f21189eee607a2b55dc10bc9573370 100644
--- a/chrome/browser/extensions/api/socket/socket_api.cc
+++ b/chrome/browser/extensions/api/socket/socket_api.cc
@@ -616,38 +616,40 @@ bool SocketGetInfoFunction::Prepare() {
}
void SocketGetInfoFunction::Work() {
- api::socket::SocketInfo info;
Socket* socket = GetSocket(params_->socket_id);
- if (socket) {
- // This represents what we know about the socket, and does not call through
- // to the system.
- if (socket->GetSocketType() == Socket::TYPE_TCP)
- info.socket_type = extensions::api::socket::SOCKET_TYPE_TCP;
- else
- info.socket_type = extensions::api::socket::SOCKET_TYPE_UDP;
- info.connected = socket->IsConnected();
-
- // Grab the peer address as known by the OS. This and the call below will
- // always succeed while the socket is connected, even if the socket has
- // been remotely closed by the peer; only reading the socket will reveal
- // that it should be closed locally.
- net::IPEndPoint peerAddress;
- if (socket->GetPeerAddress(&peerAddress)) {
- info.peer_address.reset(
- new std::string(peerAddress.ToStringWithoutPort()));
- info.peer_port.reset(new int(peerAddress.port()));
- }
-
- // Grab the local address as known by the OS.
- net::IPEndPoint localAddress;
- if (socket->GetLocalAddress(&localAddress)) {
- info.local_address.reset(
- new std::string(localAddress.ToStringWithoutPort()));
- info.local_port.reset(new int(localAddress.port()));
- }
- } else {
+ if (!socket) {
error_ = kSocketNotFoundError;
+ return;
}
+
+ api::socket::SocketInfo info;
+ // This represents what we know about the socket, and does not call through
+ // to the system.
+ if (socket->GetSocketType() == Socket::TYPE_TCP)
+ info.socket_type = extensions::api::socket::SOCKET_TYPE_TCP;
+ else
+ info.socket_type = extensions::api::socket::SOCKET_TYPE_UDP;
+ info.connected = socket->IsConnected();
+
+ // Grab the peer address as known by the OS. This and the call below will
+ // always succeed while the socket is connected, even if the socket has
+ // been remotely closed by the peer; only reading the socket will reveal
+ // that it should be closed locally.
+ net::IPEndPoint peerAddress;
+ if (socket->GetPeerAddress(&peerAddress)) {
+ info.peer_address.reset(
+ new std::string(peerAddress.ToStringWithoutPort()));
+ info.peer_port.reset(new int(peerAddress.port()));
+ }
+
+ // Grab the local address as known by the OS.
+ net::IPEndPoint localAddress;
+ if (socket->GetLocalAddress(&localAddress)) {
+ info.local_address.reset(
+ new std::string(localAddress.ToStringWithoutPort()));
+ info.local_port.reset(new int(localAddress.port()));
+ }
+
SetResult(info.ToValue().release());
}
« no previous file with comments | « no previous file | chrome/test/data/extensions/api_test/socket/api/background.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698