OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/websockets/websocket_stream.h" | 5 #include "net/websockets/websocket_stream.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/metrics/sparse_histogram.h" | 10 #include "base/metrics/sparse_histogram.h" |
11 #include "net/base/load_flags.h" | 11 #include "net/base/load_flags.h" |
12 #include "net/http/http_request_headers.h" | 12 #include "net/http/http_request_headers.h" |
13 #include "net/http/http_response_headers.h" | 13 #include "net/http/http_response_headers.h" |
14 #include "net/http/http_status_code.h" | 14 #include "net/http/http_status_code.h" |
| 15 #include "net/url_request/redirect_info.h" |
15 #include "net/url_request/url_request.h" | 16 #include "net/url_request/url_request.h" |
16 #include "net/url_request/url_request_context.h" | 17 #include "net/url_request/url_request_context.h" |
17 #include "net/websockets/websocket_errors.h" | 18 #include "net/websockets/websocket_errors.h" |
18 #include "net/websockets/websocket_event_interface.h" | 19 #include "net/websockets/websocket_event_interface.h" |
19 #include "net/websockets/websocket_handshake_constants.h" | 20 #include "net/websockets/websocket_handshake_constants.h" |
20 #include "net/websockets/websocket_handshake_stream_base.h" | 21 #include "net/websockets/websocket_handshake_stream_base.h" |
21 #include "net/websockets/websocket_handshake_stream_create_helper.h" | 22 #include "net/websockets/websocket_handshake_stream_create_helper.h" |
22 #include "net/websockets/websocket_test_util.h" | 23 #include "net/websockets/websocket_test_util.h" |
23 #include "url/gurl.h" | 24 #include "url/gurl.h" |
24 #include "url/origin.h" | 25 #include "url/origin.h" |
(...skipping 14 matching lines...) Expand all Loading... |
39 | 40 |
40 explicit Delegate(StreamRequestImpl* owner) | 41 explicit Delegate(StreamRequestImpl* owner) |
41 : owner_(owner), result_(INCOMPLETE) {} | 42 : owner_(owner), result_(INCOMPLETE) {} |
42 virtual ~Delegate() { | 43 virtual ~Delegate() { |
43 UMA_HISTOGRAM_ENUMERATION( | 44 UMA_HISTOGRAM_ENUMERATION( |
44 "Net.WebSocket.HandshakeResult", result_, NUM_HANDSHAKE_RESULT_TYPES); | 45 "Net.WebSocket.HandshakeResult", result_, NUM_HANDSHAKE_RESULT_TYPES); |
45 } | 46 } |
46 | 47 |
47 // Implementation of URLRequest::Delegate methods. | 48 // Implementation of URLRequest::Delegate methods. |
48 virtual void OnReceivedRedirect(URLRequest* request, | 49 virtual void OnReceivedRedirect(URLRequest* request, |
49 const GURL& new_url, | 50 const RedirectInfo& redirect_info, |
50 bool* defer_redirect) OVERRIDE { | 51 bool* defer_redirect) OVERRIDE { |
51 // HTTP status codes returned by HttpStreamParser are filtered by | 52 // HTTP status codes returned by HttpStreamParser are filtered by |
52 // WebSocketBasicHandshakeStream, and only 101, 401 and 407 are permitted | 53 // WebSocketBasicHandshakeStream, and only 101, 401 and 407 are permitted |
53 // back up the stack to HttpNetworkTransaction. In particular, redirect | 54 // back up the stack to HttpNetworkTransaction. In particular, redirect |
54 // codes are never allowed, and so URLRequest never sees a redirect on a | 55 // codes are never allowed, and so URLRequest never sees a redirect on a |
55 // WebSocket request. | 56 // WebSocket request. |
56 NOTREACHED(); | 57 NOTREACHED(); |
57 } | 58 } |
58 | 59 |
59 virtual void OnResponseStarted(URLRequest* request) OVERRIDE; | 60 virtual void OnResponseStarted(URLRequest* request) OVERRIDE; |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 connect_delegate->OnFinishOpeningHandshake(make_scoped_ptr( | 317 connect_delegate->OnFinishOpeningHandshake(make_scoped_ptr( |
317 new WebSocketHandshakeResponseInfo(url, | 318 new WebSocketHandshakeResponseInfo(url, |
318 headers->response_code(), | 319 headers->response_code(), |
319 headers->GetStatusText(), | 320 headers->GetStatusText(), |
320 headers, | 321 headers, |
321 response_time))); | 322 response_time))); |
322 } | 323 } |
323 } | 324 } |
324 | 325 |
325 } // namespace net | 326 } // namespace net |
OLD | NEW |