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

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

Issue 171883002: Clear reserved flags on synthetic continuations. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 6 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
« no previous file with comments | « no previous file | net/websockets/websocket_basic_stream_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_basic_stream.h" 5 #include "net/websockets/websocket_basic_stream.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 // (containing the type and flags) or have the "final" bit set. 371 // (containing the type and flags) or have the "final" bit set.
372 if (is_final_chunk_in_message || data_size > 0 || 372 if (is_final_chunk_in_message || data_size > 0 ||
373 current_frame_header_->opcode != 373 current_frame_header_->opcode !=
374 WebSocketFrameHeader::kOpCodeContinuation) { 374 WebSocketFrameHeader::kOpCodeContinuation) {
375 result_frame.reset(new WebSocketFrame(opcode)); 375 result_frame.reset(new WebSocketFrame(opcode));
376 result_frame->header.CopyFrom(*current_frame_header_); 376 result_frame->header.CopyFrom(*current_frame_header_);
377 result_frame->header.final = is_final_chunk_in_message; 377 result_frame->header.final = is_final_chunk_in_message;
378 result_frame->header.payload_length = data_size; 378 result_frame->header.payload_length = data_size;
379 result_frame->data = data; 379 result_frame->data = data;
380 // Ensure that opcodes Text and Binary are only used for the first frame in 380 // Ensure that opcodes Text and Binary are only used for the first frame in
381 // the message. 381 // the message. Also clear the reserved bits.
382 if (WebSocketFrameHeader::IsKnownDataOpCode(opcode)) 382 // TODO(ricea): If a future extension requires the reserved bits to be
383 // retained on continuation frames, make this behaviour conditional on a
384 // flag set at construction time.
385 if (!is_final_chunk && WebSocketFrameHeader::IsKnownDataOpCode(opcode)) {
tyoshino (SeeGerritForStatus) 2014/02/19 05:19:19 addition of !is_final_chunk is just a small optimi
Adam Rice 2014/02/19 05:26:14 Yes, exactly.
383 current_frame_header_->opcode = WebSocketFrameHeader::kOpCodeContinuation; 386 current_frame_header_->opcode = WebSocketFrameHeader::kOpCodeContinuation;
387 current_frame_header_->reserved1 = false;
388 current_frame_header_->reserved2 = false;
389 current_frame_header_->reserved3 = false;
390 }
384 } 391 }
385 // Make sure that a frame header is not applied to any chunks that do not 392 // Make sure that a frame header is not applied to any chunks that do not
386 // belong to it. 393 // belong to it.
387 if (is_final_chunk) 394 if (is_final_chunk)
388 current_frame_header_.reset(); 395 current_frame_header_.reset();
389 return result_frame.Pass(); 396 return result_frame.Pass();
390 } 397 }
391 398
392 void WebSocketBasicStream::AddToIncompleteControlFrameBody( 399 void WebSocketBasicStream::AddToIncompleteControlFrameBody(
393 const scoped_refptr<IOBufferWithSize>& data_buffer) { 400 const scoped_refptr<IOBufferWithSize>& data_buffer) {
(...skipping 14 matching lines...) Expand all
408 const CompletionCallback& callback, 415 const CompletionCallback& callback,
409 int result) { 416 int result) {
410 result = HandleReadResult(result, frames); 417 result = HandleReadResult(result, frames);
411 if (result == ERR_IO_PENDING) 418 if (result == ERR_IO_PENDING)
412 result = ReadFrames(frames, callback); 419 result = ReadFrames(frames, callback);
413 if (result != ERR_IO_PENDING) 420 if (result != ERR_IO_PENDING)
414 callback.Run(result); 421 callback.Run(result);
415 } 422 }
416 423
417 } // namespace net 424 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/websockets/websocket_basic_stream_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698