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

Side by Side Diff: extensions/browser/api/cast_channel/cast_socket.cc

Issue 845063002: Add result logging for TCP and SSL connection setup. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge with master Created 5 years, 11 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 | extensions/common/api/cast_channel/logging.proto » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "extensions/browser/api/cast_channel/cast_socket.h" 5 #include "extensions/browser/api/cast_channel/cast_socket.h"
6 6
7 #include <stdlib.h> 7 #include <stdlib.h>
8 #include <string.h> 8 #include <string.h>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 tcp_socket_ = CreateTcpSocket(); 372 tcp_socket_ = CreateTcpSocket();
373 373
374 int rv = tcp_socket_->Connect( 374 int rv = tcp_socket_->Connect(
375 base::Bind(&CastSocketImpl::DoConnectLoop, base::Unretained(this))); 375 base::Bind(&CastSocketImpl::DoConnectLoop, base::Unretained(this)));
376 logger_->LogSocketEventWithRv(channel_id_, proto::TCP_SOCKET_CONNECT, rv); 376 logger_->LogSocketEventWithRv(channel_id_, proto::TCP_SOCKET_CONNECT, rv);
377 return rv; 377 return rv;
378 } 378 }
379 379
380 int CastSocketImpl::DoTcpConnectComplete(int connect_result) { 380 int CastSocketImpl::DoTcpConnectComplete(int connect_result) {
381 VLOG_WITH_CONNECTION(1) << "DoTcpConnectComplete: " << connect_result; 381 VLOG_WITH_CONNECTION(1) << "DoTcpConnectComplete: " << connect_result;
382 logger_->LogSocketEventWithRv(channel_id_, proto::TCP_SOCKET_CONNECT_COMPLETE,
383 connect_result);
382 if (connect_result == net::OK) { 384 if (connect_result == net::OK) {
383 // Enable TCP-level keep-alive handling. 385 // Enable TCP-level keep-alive handling.
384 // TODO(kmarshall): Remove TCP keep-alive once protocol-level ping handling 386 // TODO(kmarshall): Remove TCP keep-alive once protocol-level ping handling
385 // is in place. 387 // is in place.
386 bool keep_alive = tcp_socket_->SetKeepAlive(true, kTcpKeepAliveDelaySecs); 388 bool keep_alive = tcp_socket_->SetKeepAlive(true, kTcpKeepAliveDelaySecs);
387 LOG_IF(WARNING, !keep_alive) << "Failed to SetKeepAlive."; 389 LOG_IF(WARNING, !keep_alive) << "Failed to SetKeepAlive.";
388 logger_->LogSocketEventWithRv(channel_id_, proto::TCP_SOCKET_SET_KEEP_ALIVE, 390 logger_->LogSocketEventWithRv(channel_id_, proto::TCP_SOCKET_SET_KEEP_ALIVE,
389 keep_alive ? 1 : 0); 391 keep_alive ? 1 : 0);
390 SetConnectState(proto::CONN_STATE_SSL_CONNECT); 392 SetConnectState(proto::CONN_STATE_SSL_CONNECT);
391 } else { 393 } else {
392 SetErrorState(CHANNEL_ERROR_CONNECT_ERROR); 394 SetErrorState(CHANNEL_ERROR_CONNECT_ERROR);
393 } 395 }
394 return connect_result; 396 return connect_result;
395 } 397 }
396 398
397 int CastSocketImpl::DoSslConnect() { 399 int CastSocketImpl::DoSslConnect() {
398 DCHECK(connect_loop_callback_.IsCancelled()); 400 DCHECK(connect_loop_callback_.IsCancelled());
399 VLOG_WITH_CONNECTION(1) << "DoSslConnect"; 401 VLOG_WITH_CONNECTION(1) << "DoSslConnect";
400 SetConnectState(proto::CONN_STATE_SSL_CONNECT_COMPLETE); 402 SetConnectState(proto::CONN_STATE_SSL_CONNECT_COMPLETE);
401 socket_ = CreateSslSocket(tcp_socket_.Pass()); 403 socket_ = CreateSslSocket(tcp_socket_.Pass());
402 404
403 int rv = socket_->Connect( 405 int rv = socket_->Connect(
404 base::Bind(&CastSocketImpl::DoConnectLoop, base::Unretained(this))); 406 base::Bind(&CastSocketImpl::DoConnectLoop, base::Unretained(this)));
405 logger_->LogSocketEventWithRv(channel_id_, proto::SSL_SOCKET_CONNECT, rv); 407 logger_->LogSocketEventWithRv(channel_id_, proto::SSL_SOCKET_CONNECT, rv);
406 return rv; 408 return rv;
407 } 409 }
408 410
409 int CastSocketImpl::DoSslConnectComplete(int result) { 411 int CastSocketImpl::DoSslConnectComplete(int result) {
412 logger_->LogSocketEventWithRv(channel_id_, proto::SSL_SOCKET_CONNECT_COMPLETE,
413 result);
410 VLOG_WITH_CONNECTION(1) << "DoSslConnectComplete: " << result; 414 VLOG_WITH_CONNECTION(1) << "DoSslConnectComplete: " << result;
411 if (result == net::ERR_CERT_AUTHORITY_INVALID && 415 if (result == net::ERR_CERT_AUTHORITY_INVALID &&
412 peer_cert_.empty() && ExtractPeerCert(&peer_cert_)) { 416 peer_cert_.empty() && ExtractPeerCert(&peer_cert_)) {
413 // Peer certificate fallback - try the connection again, from the top. 417 // Peer certificate fallback - try the connection again, from the top.
414 SetConnectState(proto::CONN_STATE_TCP_CONNECT); 418 SetConnectState(proto::CONN_STATE_TCP_CONNECT);
415 } else if (result == net::OK) { 419 } else if (result == net::OK) {
416 // SSL connection succeeded. 420 // SSL connection succeeded.
417 if (!transport_.get()) { 421 if (!transport_.get()) {
418 // Create a channel transport if one wasn't already set (e.g. by test 422 // Create a channel transport if one wasn't already set (e.g. by test
419 // code). 423 // code).
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 void CastSocketImpl::SetErrorState(ChannelError error_state) { 580 void CastSocketImpl::SetErrorState(ChannelError error_state) {
577 VLOG_WITH_CONNECTION(1) << "SetErrorState " << error_state; 581 VLOG_WITH_CONNECTION(1) << "SetErrorState " << error_state;
578 DCHECK_EQ(CHANNEL_ERROR_NONE, error_state_); 582 DCHECK_EQ(CHANNEL_ERROR_NONE, error_state_);
579 error_state_ = error_state; 583 error_state_ = error_state;
580 logger_->LogSocketErrorState(channel_id_, ErrorStateToProto(error_state_)); 584 logger_->LogSocketErrorState(channel_id_, ErrorStateToProto(error_state_));
581 } 585 }
582 } // namespace cast_channel 586 } // namespace cast_channel
583 } // namespace core_api 587 } // namespace core_api
584 } // namespace extensions 588 } // namespace extensions
585 #undef VLOG_WITH_CONNECTION 589 #undef VLOG_WITH_CONNECTION
OLDNEW
« no previous file with comments | « no previous file | extensions/common/api/cast_channel/logging.proto » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698