| OLD | NEW |
| 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 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 ScopedVector<WebSocketFrameChunk>* frame_chunks, | 256 ScopedVector<WebSocketFrameChunk>* frame_chunks, |
| 257 ScopedVector<WebSocketFrame>* frames) { | 257 ScopedVector<WebSocketFrame>* frames) { |
| 258 for (size_t i = 0; i < frame_chunks->size(); ++i) { | 258 for (size_t i = 0; i < frame_chunks->size(); ++i) { |
| 259 scoped_ptr<WebSocketFrame> frame; | 259 scoped_ptr<WebSocketFrame> frame; |
| 260 int result = ConvertChunkToFrame( | 260 int result = ConvertChunkToFrame( |
| 261 scoped_ptr<WebSocketFrameChunk>((*frame_chunks)[i]), &frame); | 261 scoped_ptr<WebSocketFrameChunk>((*frame_chunks)[i]), &frame); |
| 262 (*frame_chunks)[i] = NULL; | 262 (*frame_chunks)[i] = NULL; |
| 263 if (result != OK) | 263 if (result != OK) |
| 264 return result; | 264 return result; |
| 265 if (frame) | 265 if (frame) |
| 266 frames->push_back(frame.release()); | 266 frames->push_back(frame.Pass()); |
| 267 } | 267 } |
| 268 // All the elements of |frame_chunks| are now NULL, so there is no point in | 268 // All the elements of |frame_chunks| are now NULL, so there is no point in |
| 269 // calling delete on them all. | 269 // calling delete on them all. |
| 270 frame_chunks->weak_clear(); | 270 frame_chunks->weak_clear(); |
| 271 if (frames->empty()) | 271 if (frames->empty()) |
| 272 return ERR_IO_PENDING; | 272 return ERR_IO_PENDING; |
| 273 return OK; | 273 return OK; |
| 274 } | 274 } |
| 275 | 275 |
| 276 int WebSocketBasicStream::ConvertChunkToFrame( | 276 int WebSocketBasicStream::ConvertChunkToFrame( |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 const CompletionCallback& callback, | 415 const CompletionCallback& callback, |
| 416 int result) { | 416 int result) { |
| 417 result = HandleReadResult(result, frames); | 417 result = HandleReadResult(result, frames); |
| 418 if (result == ERR_IO_PENDING) | 418 if (result == ERR_IO_PENDING) |
| 419 result = ReadFrames(frames, callback); | 419 result = ReadFrames(frames, callback); |
| 420 if (result != ERR_IO_PENDING) | 420 if (result != ERR_IO_PENDING) |
| 421 callback.Run(result); | 421 callback.Run(result); |
| 422 } | 422 } |
| 423 | 423 |
| 424 } // namespace net | 424 } // namespace net |
| OLD | NEW |