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

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: It turns out we need to count net error codes in websocket_stream.cc after all. 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>
(...skipping 10 matching lines...) Expand all
21 #include "base/strings/string_util.h" 21 #include "base/strings/string_util.h"
22 #include "base/strings/stringprintf.h" 22 #include "base/strings/stringprintf.h"
23 #include "base/time/time.h" 23 #include "base/time/time.h"
24 #include "crypto/random.h" 24 #include "crypto/random.h"
25 #include "net/http/http_request_headers.h" 25 #include "net/http/http_request_headers.h"
26 #include "net/http/http_request_info.h" 26 #include "net/http/http_request_info.h"
27 #include "net/http/http_response_body_drainer.h" 27 #include "net/http/http_response_body_drainer.h"
28 #include "net/http/http_response_headers.h" 28 #include "net/http/http_response_headers.h"
29 #include "net/http/http_status_code.h" 29 #include "net/http/http_status_code.h"
30 #include "net/http/http_stream_parser.h" 30 #include "net/http/http_stream_parser.h"
31 #include "net/http/http_util.h"
31 #include "net/socket/client_socket_handle.h" 32 #include "net/socket/client_socket_handle.h"
32 #include "net/websockets/websocket_basic_stream.h" 33 #include "net/websockets/websocket_basic_stream.h"
33 #include "net/websockets/websocket_deflate_predictor.h" 34 #include "net/websockets/websocket_deflate_predictor.h"
34 #include "net/websockets/websocket_deflate_predictor_impl.h" 35 #include "net/websockets/websocket_deflate_predictor_impl.h"
35 #include "net/websockets/websocket_deflate_stream.h" 36 #include "net/websockets/websocket_deflate_stream.h"
36 #include "net/websockets/websocket_deflater.h" 37 #include "net/websockets/websocket_deflater.h"
37 #include "net/websockets/websocket_extension_parser.h" 38 #include "net/websockets/websocket_extension_parser.h"
38 #include "net/websockets/websocket_handshake_constants.h" 39 #include "net/websockets/websocket_handshake_constants.h"
39 #include "net/websockets/websocket_handshake_handler.h" 40 #include "net/websockets/websocket_handshake_handler.h"
40 #include "net/websockets/websocket_handshake_request_info.h" 41 #include "net/websockets/websocket_handshake_request_info.h"
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 headers->response_code(), 546 headers->response_code(),
546 headers->GetStatusText(), 547 headers->GetStatusText(),
547 headers, 548 headers,
548 http_response_info_->response_time)); 549 http_response_info_->response_time));
549 connect_delegate_->OnFinishOpeningHandshake(response.Pass()); 550 connect_delegate_->OnFinishOpeningHandshake(response.Pass());
550 } 551 }
551 } 552 }
552 553
553 int WebSocketBasicHandshakeStream::ValidateResponse(int rv) { 554 int WebSocketBasicHandshakeStream::ValidateResponse(int rv) {
554 DCHECK(http_response_info_); 555 DCHECK(http_response_info_);
555 const HttpResponseHeaders* headers = http_response_info_->headers.get(); 556 // Most net errors happen during connection, so they are not seen by this
557 // method. The histogram for error codes is created in
558 // Delegate::OnResponseStarted in websocket_stream.cc instead.
556 if (rv >= 0) { 559 if (rv >= 0) {
557 switch (headers->response_code()) { 560 const HttpResponseHeaders* headers = http_response_info_->headers.get();
561 const int response_code = headers->response_code();
562 UMA_HISTOGRAM_CUSTOM_ENUMERATION(
Alexei Svitkine (slow) 2014/06/17 15:34:27 Use UMA_HISTOGRAM_SPARSE_SLOWLY() here too. It's m
Adam Rice 2014/06/18 01:23:19 Done.
563 "Net.WebSocket.ResponseCode",
564 HttpUtil::MapStatusCodeForHistogram(response_code),
565 // The third argument is only evaluated once.
566 HttpUtil::GetStatusCodesForHistogram());
567 switch (response_code) {
558 case HTTP_SWITCHING_PROTOCOLS: 568 case HTTP_SWITCHING_PROTOCOLS:
559 OnFinishOpeningHandshake(); 569 OnFinishOpeningHandshake();
560 return ValidateUpgradeResponse(headers); 570 return ValidateUpgradeResponse(headers);
561 571
562 // We need to pass these through for authentication to work. 572 // We need to pass these through for authentication to work.
563 case HTTP_UNAUTHORIZED: 573 case HTTP_UNAUTHORIZED:
564 case HTTP_PROXY_AUTHENTICATION_REQUIRED: 574 case HTTP_PROXY_AUTHENTICATION_REQUIRED:
565 return OK; 575 return OK;
566 576
567 // Other status codes are potentially risky (see the warnings in the 577 // 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_, 622 &extensions_,
613 &failure_message_, 623 &failure_message_,
614 extension_params_.get())) { 624 extension_params_.get())) {
615 return OK; 625 return OK;
616 } 626 }
617 failure_message_ = "Error during WebSocket handshake: " + failure_message_; 627 failure_message_ = "Error during WebSocket handshake: " + failure_message_;
618 return ERR_INVALID_RESPONSE; 628 return ERR_INVALID_RESPONSE;
619 } 629 }
620 630
621 } // namespace net 631 } // 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