| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "content/public/child/fixed_received_data.h" | 5 #include "content/public/child/fixed_received_data.h" |
| 6 | 6 |
| 7 namespace content { | 7 namespace content { |
| 8 | 8 |
| 9 FixedReceivedData::FixedReceivedData(const char* data, | 9 FixedReceivedData::FixedReceivedData(const char* data, |
| 10 size_t length, | 10 size_t length, |
| 11 int encoded_data_length, | 11 int encoded_data_length) |
| 12 int encoded_body_length) | 12 : data_(data, data + length), encoded_data_length_(encoded_data_length) {} |
| 13 : data_(data, data + length), | |
| 14 encoded_data_length_(encoded_data_length), | |
| 15 encoded_body_length_(encoded_body_length) {} | |
| 16 | 13 |
| 17 FixedReceivedData::FixedReceivedData(ReceivedData* data) | 14 FixedReceivedData::FixedReceivedData(ReceivedData* data) |
| 18 : FixedReceivedData(data->payload(), | 15 : FixedReceivedData(data->payload(), |
| 19 data->length(), | 16 data->length(), |
| 20 data->encoded_data_length(), | 17 data->encoded_data_length()) {} |
| 21 data->length()) {} | |
| 22 | 18 |
| 23 FixedReceivedData::FixedReceivedData(const std::vector<char>& data, | 19 FixedReceivedData::FixedReceivedData(const std::vector<char>& data, |
| 24 int encoded_data_length, | 20 int encoded_data_length) |
| 25 int encoded_body_length) | 21 : data_(data), encoded_data_length_(encoded_data_length) {} |
| 26 : data_(data), | |
| 27 encoded_data_length_(encoded_data_length), | |
| 28 encoded_body_length_(encoded_body_length) {} | |
| 29 | 22 |
| 30 FixedReceivedData::~FixedReceivedData() { | 23 FixedReceivedData::~FixedReceivedData() { |
| 31 } | 24 } |
| 32 | 25 |
| 33 const char* FixedReceivedData::payload() const { | 26 const char* FixedReceivedData::payload() const { |
| 34 return data_.empty() ? nullptr : &data_[0]; | 27 return data_.empty() ? nullptr : &data_[0]; |
| 35 } | 28 } |
| 36 | 29 |
| 37 int FixedReceivedData::length() const { | 30 int FixedReceivedData::length() const { |
| 38 return static_cast<int>(data_.size()); | 31 return static_cast<int>(data_.size()); |
| 39 } | 32 } |
| 40 | 33 |
| 41 int FixedReceivedData::encoded_data_length() const { | 34 int FixedReceivedData::encoded_data_length() const { |
| 42 return encoded_data_length_; | 35 return encoded_data_length_; |
| 43 } | 36 } |
| 44 | 37 |
| 45 int FixedReceivedData::encoded_body_length() const { | |
| 46 return encoded_body_length_; | |
| 47 } | |
| 48 | |
| 49 } // namespace content | 38 } // namespace content |
| OLD | NEW |