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

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: 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
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
Adam Rice 2015/10/13 08:32:51 Need #include <stdint.h>
tfarina 2015/10/13 17:50:55 Done.
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/scoped_vector.h" 14 #include "base/memory/scoped_vector.h"
15 #include "net/base/completion_callback.h" 15 #include "net/base/completion_callback.h"
16 #include "net/base/io_buffer.h" 16 #include "net/base/io_buffer.h"
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 235
236 const WebSocketFrameHeader::OpCode opcode = current_writing_opcode_; 236 const WebSocketFrameHeader::OpCode opcode = current_writing_opcode_;
237 scoped_refptr<IOBufferWithSize> compressed_payload = 237 scoped_refptr<IOBufferWithSize> compressed_payload =
238 deflater_.GetOutput(deflater_.CurrentOutputSize()); 238 deflater_.GetOutput(deflater_.CurrentOutputSize());
239 if (!compressed_payload.get()) { 239 if (!compressed_payload.get()) {
240 DVLOG(1) << "WebSocket protocol error. " 240 DVLOG(1) << "WebSocket protocol error. "
241 << "deflater_.GetOutput() returns an error."; 241 << "deflater_.GetOutput() returns an error.";
242 return ERR_WS_PROTOCOL_ERROR; 242 return ERR_WS_PROTOCOL_ERROR;
243 } 243 }
244 244
245 uint64 original_payload_length = 0; 245 uint64_t original_payload_length = 0;
246 for (size_t i = 0; i < frames->size(); ++i) { 246 for (size_t i = 0; i < frames->size(); ++i) {
247 WebSocketFrame* frame = (*frames)[i]; 247 WebSocketFrame* frame = (*frames)[i];
248 // Asserts checking that frames represent one whole data message. 248 // Asserts checking that frames represent one whole data message.
249 DCHECK(WebSocketFrameHeader::IsKnownDataOpCode(frame->header.opcode)); 249 DCHECK(WebSocketFrameHeader::IsKnownDataOpCode(frame->header.opcode));
250 DCHECK_EQ(i == 0, 250 DCHECK_EQ(i == 0,
251 WebSocketFrameHeader::kOpCodeContinuation != 251 WebSocketFrameHeader::kOpCodeContinuation !=
252 frame->header.opcode); 252 frame->header.opcode);
253 DCHECK_EQ(i == frames->size() - 1, frame->header.final); 253 DCHECK_EQ(i == frames->size() - 1, frame->header.final);
254 original_payload_length += frame->header.payload_length; 254 original_payload_length += frame->header.payload_length;
255 } 255 }
256 if (original_payload_length <= 256 if (original_payload_length <=
257 static_cast<uint64>(compressed_payload->size())) { 257 static_cast<uint64_t>(compressed_payload->size())) {
258 // Compression is not effective. Use the original frames. 258 // Compression is not effective. Use the original frames.
259 for (size_t i = 0; i < frames->size(); ++i) { 259 for (size_t i = 0; i < frames->size(); ++i) {
260 WebSocketFrame* frame = (*frames)[i]; 260 WebSocketFrame* frame = (*frames)[i];
261 frames_to_write->push_back(frame); 261 frames_to_write->push_back(frame);
262 predictor_->RecordWrittenDataFrame(frame); 262 predictor_->RecordWrittenDataFrame(frame);
263 (*frames)[i] = NULL; 263 (*frames)[i] = NULL;
264 } 264 }
265 frames->weak_clear(); 265 frames->weak_clear();
266 return OK; 266 return OK;
267 } 267 }
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 DCHECK(!frames->empty()); 389 DCHECK(!frames->empty());
390 390
391 result = Inflate(frames); 391 result = Inflate(frames);
392 } 392 }
393 if (result < 0) 393 if (result < 0)
394 frames->clear(); 394 frames->clear();
395 return result; 395 return result;
396 } 396 }
397 397
398 } // namespace net 398 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698