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

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

Issue 1549643002: Switch to standard integer types in extensions/browser/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@clean
Patch Set: Created 5 years 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 <stddef.h>
8 #include <stdint.h>
9
7 #include <string> 10 #include <string>
8 #include <utility> 11 #include <utility>
9 12
10 #include "base/bind.h" 13 #include "base/bind.h"
11 #include "base/format_macros.h" 14 #include "base/format_macros.h"
12 #include "base/message_loop/message_loop.h" 15 #include "base/message_loop/message_loop.h"
13 #include "base/numerics/safe_conversions.h" 16 #include "base/numerics/safe_conversions.h"
14 #include "base/strings/stringprintf.h" 17 #include "base/strings/stringprintf.h"
15 #include "extensions/browser/api/cast_channel/cast_framer.h" 18 #include "extensions/browser/api/cast_channel/cast_framer.h"
16 #include "extensions/browser/api/cast_channel/cast_message_util.h" 19 #include "extensions/browser/api/cast_channel/cast_message_util.h"
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 int CastTransportImpl::DoRead() { 405 int CastTransportImpl::DoRead() {
403 VLOG_WITH_CONNECTION(2) << "DoRead"; 406 VLOG_WITH_CONNECTION(2) << "DoRead";
404 SetReadState(READ_STATE_READ_COMPLETE); 407 SetReadState(READ_STATE_READ_COMPLETE);
405 408
406 // Determine how many bytes need to be read. 409 // Determine how many bytes need to be read.
407 size_t num_bytes_to_read = framer_->BytesRequested(); 410 size_t num_bytes_to_read = framer_->BytesRequested();
408 DCHECK_GT(num_bytes_to_read, 0u); 411 DCHECK_GT(num_bytes_to_read, 0u);
409 412
410 // Read up to num_bytes_to_read into |current_read_buffer_|. 413 // Read up to num_bytes_to_read into |current_read_buffer_|.
411 return socket_->Read( 414 return socket_->Read(
412 read_buffer_.get(), base::checked_cast<uint32>(num_bytes_to_read), 415 read_buffer_.get(), base::checked_cast<uint32_t>(num_bytes_to_read),
413 base::Bind(&CastTransportImpl::OnReadResult, base::Unretained(this))); 416 base::Bind(&CastTransportImpl::OnReadResult, base::Unretained(this)));
414 } 417 }
415 418
416 int CastTransportImpl::DoReadComplete(int result) { 419 int CastTransportImpl::DoReadComplete(int result) {
417 VLOG_WITH_CONNECTION(2) << "DoReadComplete result = " << result; 420 VLOG_WITH_CONNECTION(2) << "DoReadComplete result = " << result;
418 logger_->LogSocketEventWithRv(channel_id_, proto::SOCKET_READ, result); 421 logger_->LogSocketEventWithRv(channel_id_, proto::SOCKET_READ, result);
419 if (result <= 0) { 422 if (result <= 0) {
420 VLOG_WITH_CONNECTION(1) << "Read error, peer closed the socket."; 423 VLOG_WITH_CONNECTION(1) << "Read error, peer closed the socket.";
421 SetErrorState(CHANNEL_ERROR_SOCKET_ERROR); 424 SetErrorState(CHANNEL_ERROR_SOCKET_ERROR);
422 SetReadState(READ_STATE_HANDLE_ERROR); 425 SetReadState(READ_STATE_HANDLE_ERROR);
423 return result == 0 ? net::ERR_FAILED : result; 426 return result == 0 ? net::ERR_FAILED : result;
424 } 427 }
425 428
426 size_t message_size; 429 size_t message_size;
427 DCHECK(!current_message_); 430 DCHECK(!current_message_);
428 ChannelError framing_error; 431 ChannelError framing_error;
429 current_message_ = framer_->Ingest(result, &message_size, &framing_error); 432 current_message_ = framer_->Ingest(result, &message_size, &framing_error);
430 if (current_message_.get() && (framing_error == CHANNEL_ERROR_NONE)) { 433 if (current_message_.get() && (framing_error == CHANNEL_ERROR_NONE)) {
431 DCHECK_GT(message_size, static_cast<size_t>(0)); 434 DCHECK_GT(message_size, static_cast<size_t>(0));
432 logger_->LogSocketEventForMessage( 435 logger_->LogSocketEventForMessage(
433 channel_id_, proto::MESSAGE_READ, current_message_->namespace_(), 436 channel_id_, proto::MESSAGE_READ, current_message_->namespace_(),
434 base::StringPrintf("Message size: %u", 437 base::StringPrintf("Message size: %u",
435 static_cast<uint32>(message_size))); 438 static_cast<uint32_t>(message_size)));
436 SetReadState(READ_STATE_DO_CALLBACK); 439 SetReadState(READ_STATE_DO_CALLBACK);
437 } else if (framing_error != CHANNEL_ERROR_NONE) { 440 } else if (framing_error != CHANNEL_ERROR_NONE) {
438 DCHECK(!current_message_); 441 DCHECK(!current_message_);
439 SetErrorState(CHANNEL_ERROR_INVALID_MESSAGE); 442 SetErrorState(CHANNEL_ERROR_INVALID_MESSAGE);
440 SetReadState(READ_STATE_HANDLE_ERROR); 443 SetReadState(READ_STATE_HANDLE_ERROR);
441 } else { 444 } else {
442 DCHECK(!current_message_); 445 DCHECK(!current_message_);
443 SetReadState(READ_STATE_READ); 446 SetReadState(READ_STATE_READ);
444 } 447 }
445 return net::OK; 448 return net::OK;
(...skipping 16 matching lines...) Expand all
462 VLOG_WITH_CONNECTION(2) << "DoReadHandleError"; 465 VLOG_WITH_CONNECTION(2) << "DoReadHandleError";
463 DCHECK_NE(CHANNEL_ERROR_NONE, error_state_); 466 DCHECK_NE(CHANNEL_ERROR_NONE, error_state_);
464 DCHECK_LE(result, 0); 467 DCHECK_LE(result, 0);
465 SetReadState(READ_STATE_ERROR); 468 SetReadState(READ_STATE_ERROR);
466 return net::ERR_FAILED; 469 return net::ERR_FAILED;
467 } 470 }
468 471
469 } // namespace cast_channel 472 } // namespace cast_channel
470 } // namespace api 473 } // namespace api
471 } // namespace extensions 474 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/api/cast_channel/cast_transport.h ('k') | extensions/browser/api/cast_channel/cast_transport_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698