1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679
|
// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "net/disk_cache/memory/mem_entry_impl.h"
#include <algorithm>
#include <memory>
#include <utility>
#include "base/check_op.h"
#include "base/format_macros.h"
#include "base/functional/bind.h"
#include "base/metrics/histogram_macros.h"
#include "base/numerics/safe_math.h"
#include "base/strings/stringprintf.h"
#include "base/values.h"
#include "net/base/interval.h"
#include "net/base/io_buffer.h"
#include "net/base/net_errors.h"
#include "net/disk_cache/memory/mem_backend_impl.h"
#include "net/disk_cache/net_log_parameters.h"
#include "net/log/net_log_event_type.h"
#include "net/log/net_log_source_type.h"
using base::Time;
namespace disk_cache {
namespace {
constexpr int kSparseData = 1;
// Maximum size of a child of sparse entry is 2 to the power of this number.
constexpr size_t kMaxChildEntryBits = 12;
// Sparse entry children have maximum size of 4KB.
constexpr size_t kMaxChildEntrySize = 1 << kMaxChildEntryBits;
// Convert global offset to child index.
uint64_t ToChildIndex(uint64_t offset) {
return offset >> kMaxChildEntryBits;
}
// Convert global offset to offset in child entry.
size_t ToChildOffset(uint64_t offset) {
return static_cast<size_t>(offset & (kMaxChildEntrySize - 1));
}
// Returns a name for a child entry given the base_name of the parent and the
// child_id. This name is only used for logging purposes.
// If the entry is called entry_name, child entries will be named something
// like Range_entry_name:YYY where YYY is the number of the particular child.
std::string GenerateChildName(const std::string& base_name, int64_t child_id) {
return base::StringPrintf("Range_%s:%" PRId64, base_name.c_str(), child_id);
}
// Returns NetLog parameters for the creation of a MemEntryImpl. A separate
// function is needed because child entries don't store their key().
base::Value::Dict NetLogEntryCreationParams(const MemEntryImpl* entry) {
base::Value::Dict dict;
std::string key;
switch (entry->type()) {
case MemEntryImpl::EntryType::kParent:
key = entry->key();
break;
case MemEntryImpl::EntryType::kChild:
key = GenerateChildName(entry->parent()->key(), entry->child_id());
break;
}
dict.Set("key", key);
dict.Set("created", true);
return dict;
}
} // namespace
MemEntryImpl::MemEntryImpl(base::WeakPtr<MemBackendImpl> backend,
const std::string& key,
net::NetLog* net_log)
: MemEntryImpl(backend,
key,
0, // child_id
nullptr, // parent
net_log) {
Open();
// Just creating the entry (without any data) could cause the storage to
// grow beyond capacity, but we allow such infractions.
backend_->ModifyStorageSize(GetStorageSize());
}
MemEntryImpl::MemEntryImpl(base::WeakPtr<MemBackendImpl> backend,
int64_t child_id,
MemEntryImpl* parent,
net::NetLog* net_log)
: MemEntryImpl(backend,
std::string(), // key
child_id,
parent,
net_log) {
(*parent_->children_)[child_id] = this;
}
void MemEntryImpl::Open() {
// Only a parent entry can be opened.
DCHECK_EQ(EntryType::kParent, type());
CHECK_NE(ref_count_, std::numeric_limits<uint32_t>::max());
++ref_count_;
DCHECK(!doomed_);
}
bool MemEntryImpl::InUse() const {
if (type() == EntryType::kChild)
return parent_->InUse();
return ref_count_ > 0;
}
int MemEntryImpl::GetStorageSize() const {
int storage_size = static_cast<int32_t>(key_.size());
for (const auto& i : data_)
storage_size += i.size();
return storage_size;
}
void MemEntryImpl::UpdateStateOnUse() {
if (!doomed_ && backend_)
backend_->OnEntryUpdated(this);
last_used_ = MemBackendImpl::Now(backend_);
}
void MemEntryImpl::Doom() {
if (!doomed_) {
doomed_ = true;
if (backend_)
backend_->OnEntryDoomed(this);
net_log_.AddEvent(net::NetLogEventType::ENTRY_DOOM);
}
if (!ref_count_)
delete this;
}
void MemEntryImpl::Close() {
DCHECK_EQ(EntryType::kParent, type());
CHECK_GT(ref_count_, 0u);
--ref_count_;
if (ref_count_ == 0 && !doomed_) {
// At this point the user is clearly done writing, so make sure there isn't
// wastage due to exponential growth of vector for main data stream.
Compact();
if (children_) {
for (const auto& child_info : *children_) {
if (child_info.second != this)
child_info.second->Compact();
}
}
}
if (!ref_count_ && doomed_)
delete this;
}
std::string MemEntryImpl::GetKey() const {
// A child entry doesn't have key so this method should not be called.
DCHECK_EQ(EntryType::kParent, type());
return key_;
}
Time MemEntryImpl::GetLastUsed() const {
return last_used_;
}
int32_t MemEntryImpl::GetDataSize(int index) const {
if (index < 0 || index >= kNumStreams)
return 0;
return data_[index].size();
}
int MemEntryImpl::ReadData(int index,
int offset,
IOBuffer* buf,
int buf_len,
CompletionOnceCallback callback) {
if (net_log_.IsCapturing()) {
NetLogReadWriteData(net_log_, net::NetLogEventType::ENTRY_READ_DATA,
net::NetLogEventPhase::BEGIN, index, offset, buf_len,
false);
}
int result = InternalReadData(index, offset, buf, buf_len);
if (net_log_.IsCapturing()) {
NetLogReadWriteComplete(net_log_, net::NetLogEventType::ENTRY_READ_DATA,
net::NetLogEventPhase::END, result);
}
return result;
}
int MemEntryImpl::WriteData(int index,
int offset,
IOBuffer* buf,
int buf_len,
CompletionOnceCallback callback,
bool truncate) {
if (net_log_.IsCapturing()) {
NetLogReadWriteData(net_log_, net::NetLogEventType::ENTRY_WRITE_DATA,
net::NetLogEventPhase::BEGIN, index, offset, buf_len,
truncate);
}
int result = InternalWriteData(index, offset, buf, buf_len, truncate);
if (net_log_.IsCapturing()) {
NetLogReadWriteComplete(net_log_, net::NetLogEventType::ENTRY_WRITE_DATA,
net::NetLogEventPhase::END, result);
}
return result;
}
int MemEntryImpl::ReadSparseData(int64_t offset,
IOBuffer* buf,
int buf_len,
CompletionOnceCallback callback) {
if (offset < 0 || buf_len < 0) {
if (net_log_.IsCapturing()) {
NetLogReadWriteComplete(net_log_, net::NetLogEventType::SPARSE_READ,
net::NetLogEventPhase::NONE,
net::ERR_INVALID_ARGUMENT);
}
return net::ERR_INVALID_ARGUMENT;
}
if (net_log_.IsCapturing()) {
NetLogSparseOperation(net_log_, net::NetLogEventType::SPARSE_READ,
net::NetLogEventPhase::BEGIN, offset, buf_len);
}
// Ensure that offset + buf_len does not overflow. This ensures that
// offset + io_buf->BytesConsumed() never overflows below.
// The result of std::min is guaranteed to fit into int since buf_len did.
size_t length = std::min(static_cast<int64_t>(buf_len),
std::numeric_limits<int64_t>::max() - offset);
int result =
InternalReadSparseData(base::checked_cast<uint64_t>(offset), buf, length);
if (net_log_.IsCapturing())
net_log_.EndEvent(net::NetLogEventType::SPARSE_READ);
return result;
}
int MemEntryImpl::WriteSparseData(int64_t offset,
IOBuffer* buf,
int buf_len,
CompletionOnceCallback callback) {
if (offset < 0 || buf_len < 0 || !base::CheckAdd(offset, buf_len).IsValid()) {
if (net_log_.IsCapturing()) {
NetLogReadWriteComplete(net_log_, net::NetLogEventType::SPARSE_WRITE,
net::NetLogEventPhase::NONE,
net::ERR_INVALID_ARGUMENT);
}
return net::ERR_INVALID_ARGUMENT;
}
if (net_log_.IsCapturing()) {
NetLogSparseOperation(net_log_, net::NetLogEventType::SPARSE_WRITE,
net::NetLogEventPhase::BEGIN, offset, buf_len);
}
int result =
InternalWriteSparseData(base::checked_cast<uint64_t>(offset), buf,
base::checked_cast<size_t>(buf_len));
if (net_log_.IsCapturing())
net_log_.EndEvent(net::NetLogEventType::SPARSE_WRITE);
return result;
}
RangeResult MemEntryImpl::GetAvailableRange(int64_t offset,
int len,
RangeResultCallback callback) {
if (offset < 0 || len < 0) {
if (net_log_.IsCapturing()) {
NetLogReadWriteComplete(net_log_, net::NetLogEventType::SPARSE_GET_RANGE,
net::NetLogEventPhase::NONE,
net::ERR_INVALID_ARGUMENT);
}
return RangeResult(net::ERR_INVALID_ARGUMENT);
}
if (net_log_.IsCapturing()) {
NetLogSparseOperation(net_log_, net::NetLogEventType::SPARSE_GET_RANGE,
net::NetLogEventPhase::BEGIN, offset, len);
}
// Truncate |len| to make sure that |offset + len| does not overflow.
// This is OK since one can't write that far anyway.
// The result of std::min is guaranteed to fit into int since |len| did.
size_t length = std::min(static_cast<int64_t>(len),
std::numeric_limits<int64_t>::max() - offset);
RangeResult result =
InternalGetAvailableRange(base::checked_cast<uint64_t>(offset), length);
if (net_log_.IsCapturing()) {
net_log_.EndEvent(net::NetLogEventType::SPARSE_GET_RANGE, [&] {
return CreateNetLogGetAvailableRangeResultParams(result);
});
}
return result;
}
bool MemEntryImpl::CouldBeSparse() const {
DCHECK_EQ(EntryType::kParent, type());
return (children_.get() != nullptr);
}
net::Error MemEntryImpl::ReadyForSparseIO(CompletionOnceCallback callback) {
return net::OK;
}
void MemEntryImpl::SetLastUsedTimeForTest(base::Time time) {
last_used_ = time;
}
// ------------------------------------------------------------------------
MemEntryImpl::MemEntryImpl(base::WeakPtr<MemBackendImpl> backend,
const ::std::string& key,
int64_t child_id,
MemEntryImpl* parent,
net::NetLog* net_log)
: key_(key),
child_id_(child_id),
parent_(parent),
last_used_(MemBackendImpl::Now(backend)),
backend_(backend) {
backend_->OnEntryInserted(this);
net_log_ = net::NetLogWithSource::Make(
net_log, net::NetLogSourceType::MEMORY_CACHE_ENTRY);
net_log_.BeginEvent(net::NetLogEventType::DISK_CACHE_MEM_ENTRY_IMPL,
[&] { return NetLogEntryCreationParams(this); });
}
MemEntryImpl::~MemEntryImpl() {
if (backend_)
backend_->ModifyStorageSize(-GetStorageSize());
if (type() == EntryType::kParent) {
if (children_) {
EntryMap children;
children_->swap(children);
for (auto& it : children) {
// Since |this| is stored in the map, it should be guarded against
// double dooming, which will result in double destruction.
if (it.second != this)
it.second->Doom();
}
}
} else {
parent_->children_->erase(child_id_);
}
net_log_.EndEvent(net::NetLogEventType::DISK_CACHE_MEM_ENTRY_IMPL);
}
int MemEntryImpl::InternalReadData(int index, int offset, IOBuffer* buf,
int buf_len) {
DCHECK(type() == EntryType::kParent || index == kSparseData);
if (index < 0 || index >= kNumStreams || offset < 0 || buf_len < 0) {
return net::ERR_INVALID_ARGUMENT;
}
int entry_size = data_[index].size();
if (offset >= entry_size || !buf_len) {
return 0;
}
unsigned u_offset = static_cast<unsigned>(offset);
int end_offset;
if (!base::CheckAdd(offset, buf_len).AssignIfValid(&end_offset) ||
end_offset > entry_size)
buf_len = entry_size - offset;
UpdateStateOnUse();
buf->span().copy_prefix_from(
base::as_byte_span(data_[index])
.subspan(u_offset, base::checked_cast<size_t>(buf_len)));
return buf_len;
}
int MemEntryImpl::InternalWriteData(int index, int offset, IOBuffer* buf,
int buf_len, bool truncate) {
DCHECK(type() == EntryType::kParent || index == kSparseData);
if (!backend_)
return net::ERR_INSUFFICIENT_RESOURCES;
if (index < 0 || index >= kNumStreams)
return net::ERR_INVALID_ARGUMENT;
if (offset < 0 || buf_len < 0)
return net::ERR_INVALID_ARGUMENT;
unsigned u_offset = static_cast<unsigned>(offset);
unsigned u_buf_len = static_cast<unsigned>(buf_len);
const int max_file_size = backend_->MaxFileSize();
int end_offset;
if (offset > max_file_size || buf_len > max_file_size ||
!base::CheckAdd(offset, buf_len).AssignIfValid(&end_offset) ||
end_offset > max_file_size) {
return net::ERR_FAILED;
}
// Trim to the portion of the buffer we're actually asked to work on.
// We need to be careful here since `buf` may be null if the length is 0;
// this may still affect the file if it gets truncated or extended.
base::span<uint8_t> to_write;
if (buf) {
to_write = buf->first(u_buf_len);
}
std::vector<char>& data = data_[index];
const int old_data_size = base::checked_cast<int>(data.size());
// Overwrite any data that fits inside the existing file.
if (u_offset < data.size() && !to_write.empty()) {
auto overwrite_chunk =
to_write.first(std::min(data.size() - u_offset, to_write.size()));
base::as_writable_byte_span(data).subspan(u_offset).copy_prefix_from(
overwrite_chunk);
}
const int delta = end_offset - old_data_size;
if (truncate && delta < 0) {
// We permit reducing the size even if the storage size has been exceeded,
// since it can only improve the situation. See https://crbug.com/331839344.
backend_->ModifyStorageSize(delta);
data.resize(end_offset);
} else if (delta > 0) {
backend_->ModifyStorageSize(delta);
if (backend_->HasExceededStorageSize()) {
backend_->ModifyStorageSize(-delta);
return net::ERR_INSUFFICIENT_RESOURCES;
}
// Zero fill any hole.
int current_size = old_data_size;
if (current_size < offset) {
data.resize(offset);
current_size = offset;
}
// Append any data after the old end of the file.
if (end_offset > current_size) {
auto append_chunk =
to_write.subspan(base::checked_cast<size_t>(current_size - offset));
data.insert(data.end(), append_chunk.begin(), append_chunk.end());
}
}
UpdateStateOnUse();
return buf_len;
}
int MemEntryImpl::InternalReadSparseData(uint64_t offset,
IOBuffer* buf,
size_t buf_len) {
DCHECK_EQ(EntryType::kParent, type());
if (!InitSparseInfo())
return net::ERR_CACHE_OPERATION_NOT_SUPPORTED;
// We will keep using this buffer and adjust the offset in this buffer.
scoped_refptr<net::DrainableIOBuffer> io_buf =
base::MakeRefCounted<net::DrainableIOBuffer>(buf, buf_len);
// Iterate until we have read enough.
while (io_buf->BytesRemaining()) {
MemEntryImpl* child = GetChild(offset + io_buf->BytesConsumed(), false);
// No child present for that offset.
if (!child)
break;
// We then need to prepare the child offset and len.
size_t child_offset = ToChildOffset(offset + io_buf->BytesConsumed());
// If we are trying to read from a position that the child entry has no data
// we should stop.
if (child_offset < child->child_first_pos_)
break;
if (net_log_.IsCapturing()) {
NetLogSparseReadWrite(net_log_,
net::NetLogEventType::SPARSE_READ_CHILD_DATA,
net::NetLogEventPhase::BEGIN,
child->net_log_.source(), io_buf->BytesRemaining());
}
int ret =
child->ReadData(kSparseData, child_offset, io_buf.get(),
io_buf->BytesRemaining(), CompletionOnceCallback());
if (net_log_.IsCapturing()) {
net_log_.EndEventWithNetErrorCode(
net::NetLogEventType::SPARSE_READ_CHILD_DATA, ret);
}
// If we encounter an error in one entry, return immediately.
if (ret < 0)
return ret;
else if (ret == 0)
break;
// Increment the counter by number of bytes read in the child entry.
io_buf->DidConsume(ret);
}
UpdateStateOnUse();
return io_buf->BytesConsumed();
}
int MemEntryImpl::InternalWriteSparseData(uint64_t offset,
IOBuffer* buf,
size_t buf_len) {
DCHECK_EQ(EntryType::kParent, type());
if (!InitSparseInfo())
return net::ERR_CACHE_OPERATION_NOT_SUPPORTED;
// We can't generally do this without the backend since we need it to create
// child entries.
if (!backend_)
return net::ERR_FAILED;
scoped_refptr<net::DrainableIOBuffer> io_buf =
base::MakeRefCounted<net::DrainableIOBuffer>(buf, buf_len);
// This loop walks through child entries continuously starting from |offset|
// and writes blocks of data (of maximum size kMaxChildEntrySize) into each
// child entry until all |buf_len| bytes are written. The write operation can
// start in the middle of an entry.
while (io_buf->BytesRemaining()) {
MemEntryImpl* child = GetChild(offset + io_buf->BytesConsumed(), true);
size_t child_offset = ToChildOffset(offset + io_buf->BytesConsumed());
// Find the right amount to write, this evaluates the remaining bytes to
// write and remaining capacity of this child entry.
size_t write_len = std::min(static_cast<size_t>(io_buf->BytesRemaining()),
kMaxChildEntrySize - child_offset);
// Keep a record of the last byte position (exclusive) in the child.
size_t data_size = child->GetDataSize(kSparseData);
if (net_log_.IsCapturing()) {
NetLogSparseReadWrite(
net_log_, net::NetLogEventType::SPARSE_WRITE_CHILD_DATA,
net::NetLogEventPhase::BEGIN, child->net_log_.source(), write_len);
}
// Always writes to the child entry. This operation may overwrite data
// previously written.
// TODO(hclam): if there is data in the entry and this write is not
// continuous we may want to discard this write.
int ret = child->WriteData(kSparseData, child_offset, io_buf.get(),
write_len, CompletionOnceCallback(), true);
if (net_log_.IsCapturing()) {
net_log_.EndEventWithNetErrorCode(
net::NetLogEventType::SPARSE_WRITE_CHILD_DATA, ret);
}
if (ret < 0)
return ret;
else if (ret == 0)
break;
// Keep a record of the first byte position in the child if the write was
// not aligned nor continuous. This is to enable witting to the middle
// of an entry and still keep track of data off the aligned edge.
if (data_size != child_offset)
child->child_first_pos_ = child_offset;
// Adjust the offset in the IO buffer.
io_buf->DidConsume(ret);
}
UpdateStateOnUse();
return io_buf->BytesConsumed();
}
RangeResult MemEntryImpl::InternalGetAvailableRange(uint64_t offset,
size_t len) {
DCHECK_EQ(EntryType::kParent, type());
if (!InitSparseInfo())
return RangeResult(net::ERR_CACHE_OPERATION_NOT_SUPPORTED);
net::Interval<uint64_t> requested(offset, offset + len);
// Find the first relevant child, if any --- may have to skip over
// one entry as it may be before the range (consider, for example,
// if the request is for [2048, 10000), while [0, 1024) is a valid range
// for the entry).
EntryMap::const_iterator i = children_->lower_bound(ToChildIndex(offset));
if (i != children_->cend() && !ChildInterval(i).Intersects(requested))
++i;
net::Interval<uint64_t> found;
if (i != children_->cend() &&
requested.Intersects(ChildInterval(i), &found)) {
// Found something relevant; now just need to expand this out if next
// children are contiguous and relevant to the request.
while (true) {
++i;
net::Interval<uint64_t> relevant_in_next_child;
if (i == children_->cend() ||
!requested.Intersects(ChildInterval(i), &relevant_in_next_child) ||
relevant_in_next_child.min() != found.max()) {
break;
}
found.SpanningUnion(relevant_in_next_child);
}
return RangeResult(found.min(), found.Length());
}
return RangeResult(offset, 0);
}
bool MemEntryImpl::InitSparseInfo() {
DCHECK_EQ(EntryType::kParent, type());
if (!children_) {
// If we already have some data in sparse stream but we are being
// initialized as a sparse entry, we should fail.
if (GetDataSize(kSparseData))
return false;
children_ = std::make_unique<EntryMap>();
// The parent entry stores data for the first block, so save this object to
// index 0.
(*children_)[0] = this;
}
return true;
}
MemEntryImpl* MemEntryImpl::GetChild(uint64_t offset, bool create) {
DCHECK_EQ(EntryType::kParent, type());
uint64_t index = ToChildIndex(offset);
auto i = children_->find(index);
if (i != children_->end())
return i->second;
if (create)
return new MemEntryImpl(backend_, index, this, net_log_.net_log());
return nullptr;
}
net::Interval<uint64_t> MemEntryImpl::ChildInterval(
MemEntryImpl::EntryMap::const_iterator i) {
DCHECK(i != children_->cend());
const MemEntryImpl* child = i->second;
// The valid range in child is [child_first_pos_, DataSize), since the child
// entry ops just use standard disk_cache::Entry API, so DataSize is
// not aware of any hole in the beginning.
int64_t child_responsibility_start = (i->first) * kMaxChildEntrySize;
return net::Interval<uint64_t>(
child_responsibility_start + child->child_first_pos_,
child_responsibility_start + child->GetDataSize(kSparseData));
}
void MemEntryImpl::Compact() {
// Stream 0 should already be fine since it's written out in a single WriteData().
data_[1].shrink_to_fit();
data_[2].shrink_to_fit();
}
} // namespace disk_cache
|