| 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_length) | 11 int encoded_length) |
| 12 : data_(data, data + length), encoded_length_(encoded_length) { | 12 : data_(data, data + length), encoded_length_(encoded_length) { |
| 13 } | 13 } |
| 14 | 14 |
| 15 FixedReceivedData::FixedReceivedData(ReceivedData* data) | 15 FixedReceivedData::FixedReceivedData(ReceivedData* data) |
| 16 : FixedReceivedData(data->payload(), | 16 : FixedReceivedData(data->payload(), |
| 17 data->encoded_length(), | 17 data->length(), |
| 18 data->encoded_length()) { | 18 data->encoded_length()) { |
| 19 } | 19 } |
| 20 | 20 |
| 21 FixedReceivedData::FixedReceivedData(const std::vector<char>& data, | 21 FixedReceivedData::FixedReceivedData(const std::vector<char>& data, |
| 22 int encoded_length) | 22 int encoded_length) |
| 23 : data_(data), encoded_length_(encoded_length) { | 23 : data_(data), encoded_length_(encoded_length) { |
| 24 } | 24 } |
| 25 | 25 |
| 26 FixedReceivedData::~FixedReceivedData() { | 26 FixedReceivedData::~FixedReceivedData() { |
| 27 } | 27 } |
| 28 | 28 |
| 29 const char* FixedReceivedData::payload() const { | 29 const char* FixedReceivedData::payload() const { |
| 30 return data_.empty() ? nullptr : &data_[0]; | 30 return data_.empty() ? nullptr : &data_[0]; |
| 31 } | 31 } |
| 32 | 32 |
| 33 int FixedReceivedData::length() const { | 33 int FixedReceivedData::length() const { |
| 34 return static_cast<int>(data_.size()); | 34 return static_cast<int>(data_.size()); |
| 35 } | 35 } |
| 36 | 36 |
| 37 int FixedReceivedData::encoded_length() const { | 37 int FixedReceivedData::encoded_length() const { |
| 38 return encoded_length_; | 38 return encoded_length_; |
| 39 } | 39 } |
| 40 | 40 |
| 41 } // namespace content | 41 } // namespace content |
| OLD | NEW |