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

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

Issue 1399303002: net/websockets: Convert int types from basictypes.h to the ones from stdint.h (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: websocket_deflate_stream.cc Created 5 years, 2 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 | « net/websockets/websocket_channel_test.cc ('k') | net/websockets/websocket_end_to_end_test.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 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_deflate_stream.h" 5 #include "net/websockets/websocket_deflate_stream.h"
6 6
7 #include <stdint.h>
7 #include <algorithm> 8 #include <algorithm>
8 #include <string> 9 #include <string>
9 10
10 #include "base/bind.h" 11 #include "base/bind.h"
11 #include "base/logging.h" 12 #include "base/logging.h"
12 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/scoped_vector.h" 15 #include "base/memory/scoped_vector.h"
15 #include "net/base/completion_callback.h" 16 #include "net/base/completion_callback.h"
16 #include "net/base/io_buffer.h" 17 #include "net/base/io_buffer.h"
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 236
236 const WebSocketFrameHeader::OpCode opcode = current_writing_opcode_; 237 const WebSocketFrameHeader::OpCode opcode = current_writing_opcode_;
237 scoped_refptr<IOBufferWithSize> compressed_payload = 238 scoped_refptr<IOBufferWithSize> compressed_payload =
238 deflater_.GetOutput(deflater_.CurrentOutputSize()); 239 deflater_.GetOutput(deflater_.CurrentOutputSize());
239 if (!compressed_payload.get()) { 240 if (!compressed_payload.get()) {
240 DVLOG(1) << "WebSocket protocol error. " 241 DVLOG(1) << "WebSocket protocol error. "
241 << "deflater_.GetOutput() returns an error."; 242 << "deflater_.GetOutput() returns an error.";
242 return ERR_WS_PROTOCOL_ERROR; 243 return ERR_WS_PROTOCOL_ERROR;
243 } 244 }
244 245
245 uint64 original_payload_length = 0; 246 uint64_t original_payload_length = 0;
246 for (size_t i = 0; i < frames->size(); ++i) { 247 for (size_t i = 0; i < frames->size(); ++i) {
247 WebSocketFrame* frame = (*frames)[i]; 248 WebSocketFrame* frame = (*frames)[i];
248 // Asserts checking that frames represent one whole data message. 249 // Asserts checking that frames represent one whole data message.
249 DCHECK(WebSocketFrameHeader::IsKnownDataOpCode(frame->header.opcode)); 250 DCHECK(WebSocketFrameHeader::IsKnownDataOpCode(frame->header.opcode));
250 DCHECK_EQ(i == 0, 251 DCHECK_EQ(i == 0,
251 WebSocketFrameHeader::kOpCodeContinuation != 252 WebSocketFrameHeader::kOpCodeContinuation !=
252 frame->header.opcode); 253 frame->header.opcode);
253 DCHECK_EQ(i == frames->size() - 1, frame->header.final); 254 DCHECK_EQ(i == frames->size() - 1, frame->header.final);
254 original_payload_length += frame->header.payload_length; 255 original_payload_length += frame->header.payload_length;
255 } 256 }
256 if (original_payload_length <= 257 if (original_payload_length <=
257 static_cast<uint64>(compressed_payload->size())) { 258 static_cast<uint64_t>(compressed_payload->size())) {
258 // Compression is not effective. Use the original frames. 259 // Compression is not effective. Use the original frames.
259 for (size_t i = 0; i < frames->size(); ++i) { 260 for (size_t i = 0; i < frames->size(); ++i) {
260 WebSocketFrame* frame = (*frames)[i]; 261 WebSocketFrame* frame = (*frames)[i];
261 frames_to_write->push_back(frame); 262 frames_to_write->push_back(frame);
262 predictor_->RecordWrittenDataFrame(frame); 263 predictor_->RecordWrittenDataFrame(frame);
263 (*frames)[i] = NULL; 264 (*frames)[i] = NULL;
264 } 265 }
265 frames->weak_clear(); 266 frames->weak_clear();
266 return OK; 267 return OK;
267 } 268 }
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 DCHECK(!frames->empty()); 390 DCHECK(!frames->empty());
390 391
391 result = Inflate(frames); 392 result = Inflate(frames);
392 } 393 }
393 if (result < 0) 394 if (result < 0)
394 frames->clear(); 395 frames->clear();
395 return result; 396 return result;
396 } 397 }
397 398
398 } // namespace net 399 } // namespace net
OLDNEW
« no previous file with comments | « net/websockets/websocket_channel_test.cc ('k') | net/websockets/websocket_end_to_end_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698