OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "core/fetch/CachedMetadata.h" |
| 6 |
| 7 namespace blink { |
| 8 |
| 9 CachedMetadata::CachedMetadata(const char* data, size_t size) |
| 10 { |
| 11 // We need to define a local variable to use the constant in DCHECK. |
| 12 constexpr auto kDataStart = CachedMetadata::kDataStart; |
| 13 // Serialized metadata should have non-empty data. |
| 14 DCHECK_GT(size, kDataStart); |
| 15 DCHECK(data); |
| 16 |
| 17 m_serializedData.reserveInitialCapacity(size); |
| 18 m_serializedData.append(data, size); |
| 19 } |
| 20 |
| 21 CachedMetadata::CachedMetadata(uint32_t dataTypeID, const char* data, size_t siz
e) |
| 22 { |
| 23 // Don't allow an ID of 0, it is used internally to indicate errors. |
| 24 DCHECK(dataTypeID); |
| 25 DCHECK(data); |
| 26 |
| 27 m_serializedData.reserveInitialCapacity(sizeof(uint32_t) + size); |
| 28 m_serializedData.append(reinterpret_cast<const char*>(&dataTypeID), sizeof(u
int32_t)); |
| 29 m_serializedData.append(data, size); |
| 30 } |
| 31 |
| 32 } // namespace blink |
OLD | NEW |