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

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

Issue 1157403005: Subsituting pattern ScopedVector push_back.(ptr.release()) with push_back(ptr.Pass()) in net/websoc… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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.cc ('k') | net/websockets/websocket_deflate_stream.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_channel.h" 5 #include "net/websockets/websocket_channel.h"
6 6
7 #include <limits.h> 7 #include <limits.h>
8 #include <string.h> 8 #include <string.h>
9 9
10 #include <iostream> 10 #include <iostream>
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 new WebSocketFrame(source_frame.opcode)); 327 new WebSocketFrame(source_frame.opcode));
328 size_t frame_length = source_frame.data ? strlen(source_frame.data) : 0; 328 size_t frame_length = source_frame.data ? strlen(source_frame.data) : 0;
329 WebSocketFrameHeader& result_header = result_frame->header; 329 WebSocketFrameHeader& result_header = result_frame->header;
330 result_header.final = (source_frame.final == FINAL_FRAME); 330 result_header.final = (source_frame.final == FINAL_FRAME);
331 result_header.masked = (source_frame.masked == MASKED); 331 result_header.masked = (source_frame.masked == MASKED);
332 result_header.payload_length = frame_length; 332 result_header.payload_length = frame_length;
333 if (source_frame.data) { 333 if (source_frame.data) {
334 result_frame->data = new IOBuffer(frame_length); 334 result_frame->data = new IOBuffer(frame_length);
335 memcpy(result_frame->data->data(), source_frame.data, frame_length); 335 memcpy(result_frame->data->data(), source_frame.data, frame_length);
336 } 336 }
337 result_frames.push_back(result_frame.release()); 337 result_frames.push_back(result_frame.Pass());
338 } 338 }
339 return result_frames.Pass(); 339 return result_frames.Pass();
340 } 340 }
341 341
342 // A GoogleMock action which can be used to respond to call to ReadFrames with 342 // A GoogleMock action which can be used to respond to call to ReadFrames with
343 // some frames. Use like ReadFrames(_, _).WillOnce(ReturnFrames(&frames)); 343 // some frames. Use like ReadFrames(_, _).WillOnce(ReturnFrames(&frames));
344 // |frames| is an array of InitFrame. |frames| needs to be passed by pointer 344 // |frames| is an array of InitFrame. |frames| needs to be passed by pointer
345 // because otherwise it will be treated as a pointer and the array size 345 // because otherwise it will be treated as a pointer and the array size
346 // information will be lost. 346 // information will be lost.
347 ACTION_P(ReturnFrames, source_frames) { 347 ACTION_P(ReturnFrames, source_frames) {
(...skipping 2503 matching lines...) Expand 10 before | Expand all | Expand 10 after
2851 // Test the read path for 8-bit cleanliness as well. 2851 // Test the read path for 8-bit cleanliness as well.
2852 TEST_F(WebSocketChannelEventInterfaceTest, ReadBinaryFramesAre8BitClean) { 2852 TEST_F(WebSocketChannelEventInterfaceTest, ReadBinaryFramesAre8BitClean) {
2853 scoped_ptr<WebSocketFrame> frame( 2853 scoped_ptr<WebSocketFrame> frame(
2854 new WebSocketFrame(WebSocketFrameHeader::kOpCodeBinary)); 2854 new WebSocketFrame(WebSocketFrameHeader::kOpCodeBinary));
2855 WebSocketFrameHeader& frame_header = frame->header; 2855 WebSocketFrameHeader& frame_header = frame->header;
2856 frame_header.final = true; 2856 frame_header.final = true;
2857 frame_header.payload_length = kBinaryBlobSize; 2857 frame_header.payload_length = kBinaryBlobSize;
2858 frame->data = new IOBuffer(kBinaryBlobSize); 2858 frame->data = new IOBuffer(kBinaryBlobSize);
2859 memcpy(frame->data->data(), kBinaryBlob, kBinaryBlobSize); 2859 memcpy(frame->data->data(), kBinaryBlob, kBinaryBlobSize);
2860 ScopedVector<WebSocketFrame> frames; 2860 ScopedVector<WebSocketFrame> frames;
2861 frames.push_back(frame.release()); 2861 frames.push_back(frame.Pass());
2862 scoped_ptr<ReadableFakeWebSocketStream> stream( 2862 scoped_ptr<ReadableFakeWebSocketStream> stream(
2863 new ReadableFakeWebSocketStream); 2863 new ReadableFakeWebSocketStream);
2864 stream->PrepareRawReadFrames( 2864 stream->PrepareRawReadFrames(
2865 ReadableFakeWebSocketStream::SYNC, OK, frames.Pass()); 2865 ReadableFakeWebSocketStream::SYNC, OK, frames.Pass());
2866 set_stream(stream.Pass()); 2866 set_stream(stream.Pass());
2867 EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _)); 2867 EXPECT_CALL(*event_interface_, OnAddChannelResponse(_, _));
2868 EXPECT_CALL(*event_interface_, OnFlowControl(_)); 2868 EXPECT_CALL(*event_interface_, OnFlowControl(_));
2869 EXPECT_CALL(*event_interface_, 2869 EXPECT_CALL(*event_interface_,
2870 OnDataFrame(true, 2870 OnDataFrame(true,
2871 WebSocketFrameHeader::kOpCodeBinary, 2871 WebSocketFrameHeader::kOpCodeBinary,
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
3412 channel_->StartClosingHandshake(kWebSocketNormalClosure, "OK"); 3412 channel_->StartClosingHandshake(kWebSocketNormalClosure, "OK");
3413 ASSERT_TRUE(read_frames); 3413 ASSERT_TRUE(read_frames);
3414 // Provide the "Close" message from the server. 3414 // Provide the "Close" message from the server.
3415 *read_frames = CreateFrameVector(frames); 3415 *read_frames = CreateFrameVector(frames);
3416 read_callback.Run(OK); 3416 read_callback.Run(OK);
3417 completion.WaitForResult(); 3417 completion.WaitForResult();
3418 } 3418 }
3419 3419
3420 } // namespace 3420 } // namespace
3421 } // namespace net 3421 } // namespace net
OLDNEW
« no previous file with comments | « net/websockets/websocket_channel.cc ('k') | net/websockets/websocket_deflate_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698