summaryrefslogtreecommitdiffstats
path: root/net/websockets
diff options
context:
space:
mode:
authorttuttle <ttuttle@chromium.org>2015-09-29 13:00:59 -0700
committerCommit bot <commit-bot@chromium.org>2015-09-29 20:01:47 +0000
commitd9dbc65205e077bb161573a51995710b767fc061 (patch)
treeeaaad21a497674368aaccc6ff624d1d3ae04aade /net/websockets
parent89af42256eff731920d276ae4d4b8ffacecbb336 (diff)
downloadchromium_src-d9dbc65205e077bb161573a51995710b767fc061.zip
chromium_src-d9dbc65205e077bb161573a51995710b767fc061.tar.gz
chromium_src-d9dbc65205e077bb161573a51995710b767fc061.tar.bz2
Expose currently-connected socket address in URLRequest
URLRequest has a GetSocketAddress method, but it returns the socket address stored in HttpResponseInfo, which is only updated after a response is received (and is pre-populated from the cache when validating a cached resource). This means that it can fail to return an address when the net stack is actually connected, or it can return a stale address during cache revalidation. Plumb through a new GetRemoteEndpoint method that specifically gets the address straight from the socket layer (with a stop to cache it in the HttpNetworkTransaction). (This is intended for Domain Reliability, but can be used elsewhere.) BUG=480565 Review URL: https://codereview.chromium.org/1270093005 Cr-Commit-Position: refs/heads/master@{#351383}
Diffstat (limited to 'net/websockets')
-rw-r--r--net/websockets/websocket_basic_handshake_stream.cc7
-rw-r--r--net/websockets/websocket_basic_handshake_stream.h1
2 files changed, 8 insertions, 0 deletions
diff --git a/net/websockets/websocket_basic_handshake_stream.cc b/net/websockets/websocket_basic_handshake_stream.cc
index d359406..a909892 100644
--- a/net/websockets/websocket_basic_handshake_stream.cc
+++ b/net/websockets/websocket_basic_handshake_stream.cc
@@ -431,6 +431,13 @@ void WebSocketBasicHandshakeStream::GetSSLCertRequestInfo(
parser()->GetSSLCertRequestInfo(cert_request_info);
}
+bool WebSocketBasicHandshakeStream::GetRemoteEndpoint(IPEndPoint* endpoint) {
+ if (!state_.connection() || !state_.connection()->socket())
+ return false;
+
+ return state_.connection()->socket()->GetPeerAddress(endpoint) == OK;
+}
+
void WebSocketBasicHandshakeStream::Drain(HttpNetworkSession* session) {
HttpResponseBodyDrainer* drainer = new HttpResponseBodyDrainer(this);
drainer->Start(session);
diff --git a/net/websockets/websocket_basic_handshake_stream.h b/net/websockets/websocket_basic_handshake_stream.h
index 7f03fb1..1984f3c 100644
--- a/net/websockets/websocket_basic_handshake_stream.h
+++ b/net/websockets/websocket_basic_handshake_stream.h
@@ -62,6 +62,7 @@ class NET_EXPORT_PRIVATE WebSocketBasicHandshakeStream
bool GetLoadTimingInfo(LoadTimingInfo* load_timing_info) const override;
void GetSSLInfo(SSLInfo* ssl_info) override;
void GetSSLCertRequestInfo(SSLCertRequestInfo* cert_request_info) override;
+ bool GetRemoteEndpoint(IPEndPoint* endpoint) override;
void Drain(HttpNetworkSession* session) override;
void SetPriority(RequestPriority priority) override;
UploadProgress GetUploadProgress() const override;