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

Side by Side Diff: blimp/net/stream_packet_reader.cc

Issue 1538253002: Switch to standard integer types in blimp/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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
« no previous file with comments | « blimp/net/stream_packet_reader.h ('k') | blimp/net/stream_packet_writer.cc » ('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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "blimp/net/stream_packet_reader.h" 5 #include "blimp/net/stream_packet_reader.h"
6 6
7 #include <iostream> 7 #include <iostream>
8 8
9 #include "base/callback_helpers.h" 9 #include "base/callback_helpers.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 if (static_cast<size_t>(header_buffer_->offset()) < kPacketHeaderSizeBytes) { 104 if (static_cast<size_t>(header_buffer_->offset()) < kPacketHeaderSizeBytes) {
105 // There is more header to read. 105 // There is more header to read.
106 return socket_->Read(header_buffer_.get(), 106 return socket_->Read(header_buffer_.get(),
107 kPacketHeaderSizeBytes - header_buffer_->offset(), 107 kPacketHeaderSizeBytes - header_buffer_->offset(),
108 base::Bind(&StreamPacketReader::OnReadComplete, 108 base::Bind(&StreamPacketReader::OnReadComplete,
109 weak_factory_.GetWeakPtr())); 109 weak_factory_.GetWeakPtr()));
110 } 110 }
111 111
112 // Finished reading the header. Parse the size and prepare for payload read. 112 // Finished reading the header. Parse the size and prepare for payload read.
113 payload_size_ = base::NetToHost32( 113 payload_size_ = base::NetToHost32(
114 *reinterpret_cast<uint32*>(header_buffer_->StartOfBuffer())); 114 *reinterpret_cast<uint32_t*>(header_buffer_->StartOfBuffer()));
115 if (payload_size_ > static_cast<size_t>(payload_buffer_->capacity()) || 115 if (payload_size_ > static_cast<size_t>(payload_buffer_->capacity()) ||
116 payload_size_ == 0) { 116 payload_size_ == 0) {
117 DLOG(ERROR) << "Illegal payload size: " << payload_size_; 117 DLOG(ERROR) << "Illegal payload size: " << payload_size_;
118 return net::ERR_INVALID_RESPONSE; 118 return net::ERR_INVALID_RESPONSE;
119 } 119 }
120 read_state_ = ReadState::PAYLOAD; 120 read_state_ = ReadState::PAYLOAD;
121 return net::OK; 121 return net::OK;
122 } 122 }
123 123
124 int StreamPacketReader::DoReadPayload(int result) { 124 int StreamPacketReader::DoReadPayload(int result) {
(...skipping 23 matching lines...) Expand all
148 148
149 // If all reading completed, either successfully or by error, inform the 149 // If all reading completed, either successfully or by error, inform the
150 // caller. 150 // caller.
151 if (result != net::ERR_IO_PENDING) { 151 if (result != net::ERR_IO_PENDING) {
152 payload_buffer_ = nullptr; 152 payload_buffer_ = nullptr;
153 base::ResetAndReturn(&callback_).Run(result); 153 base::ResetAndReturn(&callback_).Run(result);
154 } 154 }
155 } 155 }
156 156
157 } // namespace blimp 157 } // namespace blimp
OLDNEW
« no previous file with comments | « blimp/net/stream_packet_reader.h ('k') | blimp/net/stream_packet_writer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698