| 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_deflate_stream.h" | 5 #include "net/websockets/websocket_deflate_stream.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <deque> | 8 #include <deque> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 return; | 118 return; |
| 119 } | 119 } |
| 120 if (!frames_written_.empty()) { | 120 if (!frames_written_.empty()) { |
| 121 ADD_FAILURE() << "There are extra written frames."; | 121 ADD_FAILURE() << "There are extra written frames."; |
| 122 return; | 122 return; |
| 123 } | 123 } |
| 124 } | 124 } |
| 125 | 125 |
| 126 // WebSocketDeflatePredictor functions. | 126 // WebSocketDeflatePredictor functions. |
| 127 virtual Result Predict(const ScopedVector<WebSocketFrame>& frames, | 127 virtual Result Predict(const ScopedVector<WebSocketFrame>& frames, |
| 128 size_t frame_index) OVERRIDE { | 128 size_t frame_index) override { |
| 129 return result_; | 129 return result_; |
| 130 } | 130 } |
| 131 virtual void RecordInputDataFrame(const WebSocketFrame* frame) OVERRIDE { | 131 virtual void RecordInputDataFrame(const WebSocketFrame* frame) override { |
| 132 if (!WebSocketFrameHeader::IsKnownDataOpCode(frame->header.opcode)) { | 132 if (!WebSocketFrameHeader::IsKnownDataOpCode(frame->header.opcode)) { |
| 133 ADD_FAILURE() << "Control frames should not be recorded."; | 133 ADD_FAILURE() << "Control frames should not be recorded."; |
| 134 return; | 134 return; |
| 135 } | 135 } |
| 136 if (frame->header.reserved1) { | 136 if (frame->header.reserved1) { |
| 137 ADD_FAILURE() << "Input frame may not be compressed."; | 137 ADD_FAILURE() << "Input frame may not be compressed."; |
| 138 return; | 138 return; |
| 139 } | 139 } |
| 140 if (frames_to_be_input_.empty()) { | 140 if (frames_to_be_input_.empty()) { |
| 141 ADD_FAILURE() << "Unexpected input data frame"; | 141 ADD_FAILURE() << "Unexpected input data frame"; |
| 142 return; | 142 return; |
| 143 } | 143 } |
| 144 if (frame != frames_to_be_input_.front()) { | 144 if (frame != frames_to_be_input_.front()) { |
| 145 ADD_FAILURE() << "Input data frame does not match the expectation."; | 145 ADD_FAILURE() << "Input data frame does not match the expectation."; |
| 146 return; | 146 return; |
| 147 } | 147 } |
| 148 frames_to_be_input_.pop_front(); | 148 frames_to_be_input_.pop_front(); |
| 149 } | 149 } |
| 150 virtual void RecordWrittenDataFrame(const WebSocketFrame* frame) OVERRIDE { | 150 virtual void RecordWrittenDataFrame(const WebSocketFrame* frame) override { |
| 151 if (!WebSocketFrameHeader::IsKnownDataOpCode(frame->header.opcode)) { | 151 if (!WebSocketFrameHeader::IsKnownDataOpCode(frame->header.opcode)) { |
| 152 ADD_FAILURE() << "Control frames should not be recorded."; | 152 ADD_FAILURE() << "Control frames should not be recorded."; |
| 153 return; | 153 return; |
| 154 } | 154 } |
| 155 frames_written_.push_back(frame); | 155 frames_written_.push_back(frame); |
| 156 } | 156 } |
| 157 | 157 |
| 158 // Sets |result_| for the |Predict| return value. | 158 // Sets |result_| for the |Predict| return value. |
| 159 void set_result(Result result) { result_ = result; } | 159 void set_result(Result result) { result_ = result; } |
| 160 | 160 |
| (...skipping 1179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1340 const ScopedVector<WebSocketFrame>& frames_passed = *stub.frames(); | 1340 const ScopedVector<WebSocketFrame>& frames_passed = *stub.frames(); |
| 1341 ASSERT_EQ(1u, frames_passed.size()); | 1341 ASSERT_EQ(1u, frames_passed.size()); |
| 1342 EXPECT_EQ( | 1342 EXPECT_EQ( |
| 1343 std::string("r\xce(\xca\xcf\xcd,\xcdM\x1c\xe1\xc0\x19\x1a\x0e\0\0", 17), | 1343 std::string("r\xce(\xca\xcf\xcd,\xcdM\x1c\xe1\xc0\x19\x1a\x0e\0\0", 17), |
| 1344 ToString(frames_passed[0])); | 1344 ToString(frames_passed[0])); |
| 1345 } | 1345 } |
| 1346 | 1346 |
| 1347 } // namespace | 1347 } // namespace |
| 1348 | 1348 |
| 1349 } // namespace net | 1349 } // namespace net |
| OLD | NEW |