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 "net/base/load_flags.h" | 11 #include "net/base/load_flags.h" |
11 #include "net/http/http_request_headers.h" | 12 #include "net/http/http_request_headers.h" |
12 #include "net/http/http_status_code.h" | 13 #include "net/http/http_status_code.h" |
13 #include "net/url_request/url_request.h" | 14 #include "net/url_request/url_request.h" |
14 #include "net/url_request/url_request_context.h" | 15 #include "net/url_request/url_request_context.h" |
15 #include "net/websockets/websocket_errors.h" | 16 #include "net/websockets/websocket_errors.h" |
16 #include "net/websockets/websocket_event_interface.h" | 17 #include "net/websockets/websocket_event_interface.h" |
17 #include "net/websockets/websocket_handshake_constants.h" | 18 #include "net/websockets/websocket_handshake_constants.h" |
18 #include "net/websockets/websocket_handshake_stream_base.h" | 19 #include "net/websockets/websocket_handshake_stream_base.h" |
19 #include "net/websockets/websocket_handshake_stream_create_helper.h" | 20 #include "net/websockets/websocket_handshake_stream_create_helper.h" |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 | 172 |
172 virtual void ContinueSSLRequest() OVERRIDE { | 173 virtual void ContinueSSLRequest() OVERRIDE { |
173 url_request_->ContinueDespiteLastError(); | 174 url_request_->ContinueDespiteLastError(); |
174 } | 175 } |
175 | 176 |
176 private: | 177 private: |
177 URLRequest* url_request_; | 178 URLRequest* url_request_; |
178 }; | 179 }; |
179 | 180 |
180 void Delegate::OnResponseStarted(URLRequest* request) { | 181 void Delegate::OnResponseStarted(URLRequest* request) { |
| 182 // All error codes, including OK and ABORTED, as with |
| 183 // Net.ErrorCodesForMainFrame3 |
| 184 UMA_HISTOGRAM_SPARSE_SLOWLY("Net.WebSocket.ErrorCodes", |
| 185 -request->status().error()); |
181 if (!request->status().is_success()) { | 186 if (!request->status().is_success()) { |
182 DVLOG(3) << "OnResponseStarted (request failed)"; | 187 DVLOG(3) << "OnResponseStarted (request failed)"; |
183 owner_->ReportFailure(); | 188 owner_->ReportFailure(); |
184 return; | 189 return; |
185 } | 190 } |
186 DVLOG(3) << "OnResponseStarted (response code " << request->GetResponseCode() | 191 const int response_code = request->GetResponseCode(); |
187 << ")"; | 192 DVLOG(3) << "OnResponseStarted (response code " << response_code << ")"; |
188 switch (request->GetResponseCode()) { | 193 switch (response_code) { |
189 case HTTP_SWITCHING_PROTOCOLS: | 194 case HTTP_SWITCHING_PROTOCOLS: |
190 result_ = CONNECTED; | 195 result_ = CONNECTED; |
191 owner_->PerformUpgrade(); | 196 owner_->PerformUpgrade(); |
192 return; | 197 return; |
193 | 198 |
194 case HTTP_UNAUTHORIZED: | 199 case HTTP_UNAUTHORIZED: |
195 case HTTP_PROXY_AUTHENTICATION_REQUIRED: | 200 case HTTP_PROXY_AUTHENTICATION_REQUIRED: |
196 return; | 201 return; |
197 | 202 |
198 default: | 203 default: |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 new StreamRequestImpl(socket_url, | 278 new StreamRequestImpl(socket_url, |
274 url_request_context, | 279 url_request_context, |
275 origin, | 280 origin, |
276 connect_delegate.Pass(), | 281 connect_delegate.Pass(), |
277 create_helper.Pass())); | 282 create_helper.Pass())); |
278 request->Start(); | 283 request->Start(); |
279 return request.PassAs<WebSocketStreamRequest>(); | 284 return request.PassAs<WebSocketStreamRequest>(); |
280 } | 285 } |
281 | 286 |
282 } // namespace net | 287 } // namespace net |
OLD | NEW |