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

Side by Side Diff: net/websockets/websocket_basic_handshake_stream.cc

Issue 336753002: Add Net.WebSocket.ResponseCode and ErrorCodes UMA (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use sprae histogram for result code. Created 6 years, 6 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 unified diff | Download patch
« no previous file with comments | « no previous file | net/websockets/websocket_stream.cc » ('j') | net/websockets/websocket_stream.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_basic_handshake_stream.h" 5 #include "net/websockets/websocket_basic_handshake_stream.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <iterator> 8 #include <iterator>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/base64.h" 13 #include "base/base64.h"
14 #include "base/basictypes.h" 14 #include "base/basictypes.h"
15 #include "base/bind.h" 15 #include "base/bind.h"
16 #include "base/containers/hash_tables.h" 16 #include "base/containers/hash_tables.h"
17 #include "base/metrics/histogram.h" 17 #include "base/metrics/histogram.h"
18 #include "base/metrics/sparse_histogram.h"
18 #include "base/stl_util.h" 19 #include "base/stl_util.h"
19 #include "base/strings/string_number_conversions.h" 20 #include "base/strings/string_number_conversions.h"
20 #include "base/strings/string_piece.h" 21 #include "base/strings/string_piece.h"
21 #include "base/strings/string_util.h" 22 #include "base/strings/string_util.h"
22 #include "base/strings/stringprintf.h" 23 #include "base/strings/stringprintf.h"
23 #include "base/time/time.h" 24 #include "base/time/time.h"
24 #include "crypto/random.h" 25 #include "crypto/random.h"
25 #include "net/http/http_request_headers.h" 26 #include "net/http/http_request_headers.h"
26 #include "net/http/http_request_info.h" 27 #include "net/http/http_request_info.h"
27 #include "net/http/http_response_body_drainer.h" 28 #include "net/http/http_response_body_drainer.h"
28 #include "net/http/http_response_headers.h" 29 #include "net/http/http_response_headers.h"
29 #include "net/http/http_status_code.h" 30 #include "net/http/http_status_code.h"
30 #include "net/http/http_stream_parser.h" 31 #include "net/http/http_stream_parser.h"
32 #include "net/http/http_util.h"
31 #include "net/socket/client_socket_handle.h" 33 #include "net/socket/client_socket_handle.h"
32 #include "net/websockets/websocket_basic_stream.h" 34 #include "net/websockets/websocket_basic_stream.h"
33 #include "net/websockets/websocket_deflate_predictor.h" 35 #include "net/websockets/websocket_deflate_predictor.h"
34 #include "net/websockets/websocket_deflate_predictor_impl.h" 36 #include "net/websockets/websocket_deflate_predictor_impl.h"
35 #include "net/websockets/websocket_deflate_stream.h" 37 #include "net/websockets/websocket_deflate_stream.h"
36 #include "net/websockets/websocket_deflater.h" 38 #include "net/websockets/websocket_deflater.h"
37 #include "net/websockets/websocket_extension_parser.h" 39 #include "net/websockets/websocket_extension_parser.h"
38 #include "net/websockets/websocket_handshake_constants.h" 40 #include "net/websockets/websocket_handshake_constants.h"
39 #include "net/websockets/websocket_handshake_handler.h" 41 #include "net/websockets/websocket_handshake_handler.h"
40 #include "net/websockets/websocket_handshake_request_info.h" 42 #include "net/websockets/websocket_handshake_request_info.h"
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 headers->response_code(), 547 headers->response_code(),
546 headers->GetStatusText(), 548 headers->GetStatusText(),
547 headers, 549 headers,
548 http_response_info_->response_time)); 550 http_response_info_->response_time));
549 connect_delegate_->OnFinishOpeningHandshake(response.Pass()); 551 connect_delegate_->OnFinishOpeningHandshake(response.Pass());
550 } 552 }
551 } 553 }
552 554
553 int WebSocketBasicHandshakeStream::ValidateResponse(int rv) { 555 int WebSocketBasicHandshakeStream::ValidateResponse(int rv) {
554 DCHECK(http_response_info_); 556 DCHECK(http_response_info_);
555 const HttpResponseHeaders* headers = http_response_info_->headers.get(); 557 // Most net errors happen during connection, so they are not seen by this
558 // method. The histogram for error codes is created in
559 // Delegate::OnResponseStarted in websocket_stream.cc instead.
556 if (rv >= 0) { 560 if (rv >= 0) {
557 switch (headers->response_code()) { 561 const HttpResponseHeaders* headers = http_response_info_->headers.get();
562 const int response_code = headers->response_code();
563 UMA_HISTOGRAM_SPARSE_SLOWLY(
564 "Net.WebSocket.ResponseCode",
Alexei Svitkine (slow) 2014/06/18 16:50:41 Indent 2 more or don't wrap.
Adam Rice 2014/06/19 02:24:06 Done.
565 HttpUtil::MapStatusCodeForHistogram(response_code));
Alexei Svitkine (slow) 2014/06/18 16:50:41 You don't need MapStatusCodeForHistogram, just log
Adam Rice 2014/06/19 02:24:06 Done.
566 switch (response_code) {
558 case HTTP_SWITCHING_PROTOCOLS: 567 case HTTP_SWITCHING_PROTOCOLS:
559 OnFinishOpeningHandshake(); 568 OnFinishOpeningHandshake();
560 return ValidateUpgradeResponse(headers); 569 return ValidateUpgradeResponse(headers);
561 570
562 // We need to pass these through for authentication to work. 571 // We need to pass these through for authentication to work.
563 case HTTP_UNAUTHORIZED: 572 case HTTP_UNAUTHORIZED:
564 case HTTP_PROXY_AUTHENTICATION_REQUIRED: 573 case HTTP_PROXY_AUTHENTICATION_REQUIRED:
565 return OK; 574 return OK;
566 575
567 // Other status codes are potentially risky (see the warnings in the 576 // Other status codes are potentially risky (see the warnings in the
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 &extensions_, 621 &extensions_,
613 &failure_message_, 622 &failure_message_,
614 extension_params_.get())) { 623 extension_params_.get())) {
615 return OK; 624 return OK;
616 } 625 }
617 failure_message_ = "Error during WebSocket handshake: " + failure_message_; 626 failure_message_ = "Error during WebSocket handshake: " + failure_message_;
618 return ERR_INVALID_RESPONSE; 627 return ERR_INVALID_RESPONSE;
619 } 628 }
620 629
621 } // namespace net 630 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/websockets/websocket_stream.cc » ('j') | net/websockets/websocket_stream.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698