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

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

Issue 2950343002: Break down Net.WebSocket.ErrorCodes by localhost (Closed)
Patch Set: Created 3 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 | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
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_stream.h" 5 #include "net/websockets/websocket_stream.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "base/metrics/histogram_macros.h" 12 #include "base/metrics/histogram_macros.h"
13 #include "base/metrics/sparse_histogram.h" 13 #include "base/metrics/sparse_histogram.h"
14 #include "base/time/time.h" 14 #include "base/time/time.h"
15 #include "base/timer/timer.h" 15 #include "base/timer/timer.h"
16 #include "net/base/load_flags.h" 16 #include "net/base/load_flags.h"
17 #include "net/base/url_util.h"
17 #include "net/http/http_request_headers.h" 18 #include "net/http/http_request_headers.h"
18 #include "net/http/http_response_headers.h" 19 #include "net/http/http_response_headers.h"
19 #include "net/http/http_status_code.h" 20 #include "net/http/http_status_code.h"
20 #include "net/traffic_annotation/network_traffic_annotation.h" 21 #include "net/traffic_annotation/network_traffic_annotation.h"
21 #include "net/url_request/redirect_info.h" 22 #include "net/url_request/redirect_info.h"
22 #include "net/url_request/url_request.h" 23 #include "net/url_request/url_request.h"
23 #include "net/url_request/url_request_context.h" 24 #include "net/url_request/url_request_context.h"
24 #include "net/websockets/websocket_errors.h" 25 #include "net/websockets/websocket_errors.h"
25 #include "net/websockets/websocket_event_interface.h" 26 #include "net/websockets/websocket_event_interface.h"
26 #include "net/websockets/websocket_handshake_constants.h" 27 #include "net/websockets/websocket_handshake_constants.h"
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 << redirect_info.new_url.spec(); 309 << redirect_info.new_url.spec();
309 request->Cancel(); 310 request->Cancel();
310 } 311 }
311 } 312 }
312 313
313 void Delegate::OnResponseStarted(URLRequest* request, int net_error) { 314 void Delegate::OnResponseStarted(URLRequest* request, int net_error) {
314 DCHECK_NE(ERR_IO_PENDING, net_error); 315 DCHECK_NE(ERR_IO_PENDING, net_error);
315 // All error codes, including OK and ABORTED, as with 316 // All error codes, including OK and ABORTED, as with
316 // Net.ErrorCodesForMainFrame3 317 // Net.ErrorCodesForMainFrame3
317 UMA_HISTOGRAM_SPARSE_SLOWLY("Net.WebSocket.ErrorCodes", -net_error); 318 UMA_HISTOGRAM_SPARSE_SLOWLY("Net.WebSocket.ErrorCodes", -net_error);
319 if (net::IsLocalhost(request->url().HostNoBrackets())) {
320 UMA_HISTOGRAM_SPARSE_SLOWLY("Net.WebSocket.ErrorCodes_Localhost",
321 -net_error);
322 } else {
323 UMA_HISTOGRAM_SPARSE_SLOWLY("Net.WebSocket.ErrorCodes_NotLocalhost",
324 -net_error);
325 }
326
318 if (net_error != OK) { 327 if (net_error != OK) {
319 DVLOG(3) << "OnResponseStarted (request failed)"; 328 DVLOG(3) << "OnResponseStarted (request failed)";
320 owner_->ReportFailure(net_error); 329 owner_->ReportFailure(net_error);
321 return; 330 return;
322 } 331 }
323 const int response_code = request->GetResponseCode(); 332 const int response_code = request->GetResponseCode();
324 DVLOG(3) << "OnResponseStarted (response code " << response_code << ")"; 333 DVLOG(3) << "OnResponseStarted (response code " << response_code << ")";
325 switch (response_code) { 334 switch (response_code) {
326 case HTTP_SWITCHING_PROTOCOLS: 335 case HTTP_SWITCHING_PROTOCOLS:
327 result_ = CONNECTED; 336 result_ = CONNECTED;
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 DCHECK(connect_delegate); 441 DCHECK(connect_delegate);
433 if (headers.get()) { 442 if (headers.get()) {
434 connect_delegate->OnFinishOpeningHandshake( 443 connect_delegate->OnFinishOpeningHandshake(
435 base::MakeUnique<WebSocketHandshakeResponseInfo>( 444 base::MakeUnique<WebSocketHandshakeResponseInfo>(
436 url, headers->response_code(), headers->GetStatusText(), headers, 445 url, headers->response_code(), headers->GetStatusText(), headers,
437 response_time)); 446 response_time));
438 } 447 }
439 } 448 }
440 449
441 } // namespace net 450 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698