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

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

Issue 843453002: Replace NULL with nullptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync w/master, code review feedback. Created 5 years, 10 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
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_transport.h" 5 #include "extensions/browser/api/cast_channel/cast_transport.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/format_macros.h" 10 #include "base/format_macros.h"
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 VLOG_WITH_CONNECTION(2) << "DoReadComplete result = " << result; 395 VLOG_WITH_CONNECTION(2) << "DoReadComplete result = " << result;
396 396
397 if (result <= 0) { 397 if (result <= 0) {
398 VLOG_WITH_CONNECTION(1) << "Read error, peer closed the socket."; 398 VLOG_WITH_CONNECTION(1) << "Read error, peer closed the socket.";
399 SetErrorState(CHANNEL_ERROR_SOCKET_ERROR); 399 SetErrorState(CHANNEL_ERROR_SOCKET_ERROR);
400 SetReadState(READ_STATE_ERROR); 400 SetReadState(READ_STATE_ERROR);
401 return result == 0 ? net::ERR_FAILED : result; 401 return result == 0 ? net::ERR_FAILED : result;
402 } 402 }
403 403
404 size_t message_size; 404 size_t message_size;
405 DCHECK(current_message_.get() == NULL); 405 DCHECK(!current_message_);
406 ChannelError framing_error; 406 ChannelError framing_error;
407 current_message_ = framer_->Ingest(result, &message_size, &framing_error); 407 current_message_ = framer_->Ingest(result, &message_size, &framing_error);
408 if (current_message_.get() && (framing_error == CHANNEL_ERROR_NONE)) { 408 if (current_message_.get() && (framing_error == CHANNEL_ERROR_NONE)) {
409 DCHECK_GT(message_size, static_cast<size_t>(0)); 409 DCHECK_GT(message_size, static_cast<size_t>(0));
410 logger_->LogSocketEventForMessage( 410 logger_->LogSocketEventForMessage(
411 channel_id_, proto::MESSAGE_READ, current_message_->namespace_(), 411 channel_id_, proto::MESSAGE_READ, current_message_->namespace_(),
412 base::StringPrintf("Message size: %u", 412 base::StringPrintf("Message size: %u",
413 static_cast<uint32>(message_size))); 413 static_cast<uint32>(message_size)));
414 SetReadState(READ_STATE_DO_CALLBACK); 414 SetReadState(READ_STATE_DO_CALLBACK);
415 } else if (framing_error != CHANNEL_ERROR_NONE) { 415 } else if (framing_error != CHANNEL_ERROR_NONE) {
416 DCHECK(current_message_.get() == NULL); 416 DCHECK(!current_message_);
417 SetErrorState(CHANNEL_ERROR_INVALID_MESSAGE); 417 SetErrorState(CHANNEL_ERROR_INVALID_MESSAGE);
418 SetReadState(READ_STATE_ERROR); 418 SetReadState(READ_STATE_ERROR);
419 } else { 419 } else {
420 DCHECK(current_message_.get() == NULL); 420 DCHECK(!current_message_);
421 SetReadState(READ_STATE_READ); 421 SetReadState(READ_STATE_READ);
422 } 422 }
423 return net::OK; 423 return net::OK;
424 } 424 }
425 425
426 int CastTransportImpl::DoReadCallback() { 426 int CastTransportImpl::DoReadCallback() {
427 VLOG_WITH_CONNECTION(2) << "DoReadCallback"; 427 VLOG_WITH_CONNECTION(2) << "DoReadCallback";
428 if (!IsCastMessageValid(*current_message_)) { 428 if (!IsCastMessageValid(*current_message_)) {
429 SetReadState(READ_STATE_ERROR); 429 SetReadState(READ_STATE_ERROR);
430 SetErrorState(CHANNEL_ERROR_INVALID_MESSAGE); 430 SetErrorState(CHANNEL_ERROR_INVALID_MESSAGE);
(...skipping 12 matching lines...) Expand all
443 int CastTransportImpl::DoReadError(int result) { 443 int CastTransportImpl::DoReadError(int result) {
444 VLOG_WITH_CONNECTION(2) << "DoReadError"; 444 VLOG_WITH_CONNECTION(2) << "DoReadError";
445 DCHECK_NE(CHANNEL_ERROR_NONE, error_state_); 445 DCHECK_NE(CHANNEL_ERROR_NONE, error_state_);
446 DCHECK_LE(result, 0); 446 DCHECK_LE(result, 0);
447 return net::ERR_FAILED; 447 return net::ERR_FAILED;
448 } 448 }
449 449
450 } // namespace cast_channel 450 } // namespace cast_channel
451 } // namespace core_api 451 } // namespace core_api
452 } // namespace extensions 452 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/api/cast_channel/cast_socket_unittest.cc ('k') | extensions/browser/api/cast_channel/logger.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698