Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(329)

Side by Side Diff: net/disk_cache/entry_impl.cc

Issue 8418034: Make string_util::WriteInto() DCHECK() that the supplied |length_with_null| > 1, meaning that the... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/base/x509_certificate_win.cc ('k') | net/http/http_mac_signature.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/disk_cache/entry_impl.h" 5 #include "net/disk_cache/entry_impl.h"
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "net/base/io_buffer.h" 10 #include "net/base/io_buffer.h"
(...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after
766 Addr address(entry->Data()->long_key); 766 Addr address(entry->Data()->long_key);
767 DCHECK(address.is_initialized()); 767 DCHECK(address.is_initialized());
768 size_t offset = 0; 768 size_t offset = 0;
769 if (address.is_block_file()) 769 if (address.is_block_file())
770 offset = address.start_block() * address.BlockSize() + kBlockHeaderSize; 770 offset = address.start_block() * address.BlockSize() + kBlockHeaderSize;
771 771
772 COMPILE_ASSERT(kNumStreams == kKeyFileIndex, invalid_key_index); 772 COMPILE_ASSERT(kNumStreams == kKeyFileIndex, invalid_key_index);
773 File* key_file = const_cast<EntryImpl*>(this)->GetBackingFile(address, 773 File* key_file = const_cast<EntryImpl*>(this)->GetBackingFile(address,
774 kKeyFileIndex); 774 kKeyFileIndex);
775 775
776 if (!offset && key_file->GetLength() != static_cast<size_t>(key_len + 1)) 776 ++key_len; // We store a trailing \0 on disk that we read back below.
777 if (!offset && key_file->GetLength() != static_cast<size_t>(key_len))
777 return std::string(); 778 return std::string();
778 779
779 if (!key_file || 780 if (!key_file || !key_file->Read(WriteInto(&key_, key_len), key_len, offset))
780 !key_file->Read(WriteInto(&key_, key_len + 1), key_len + 1, offset))
781 key_.clear(); 781 key_.clear();
782 return key_; 782 return key_;
783 } 783 }
784 784
785 Time EntryImpl::GetLastUsed() const { 785 Time EntryImpl::GetLastUsed() const {
786 CacheRankingsBlock* node = const_cast<CacheRankingsBlock*>(&node_); 786 CacheRankingsBlock* node = const_cast<CacheRankingsBlock*>(&node_);
787 return Time::FromInternalValue(node->Data()->last_used); 787 return Time::FromInternalValue(node->Data()->last_used);
788 } 788 }
789 789
790 Time EntryImpl::GetLastModified() const { 790 Time EntryImpl::GetLastModified() const {
(...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after
1492 Trace("%s 0x%p 0x%x 0x%x", msg, reinterpret_cast<void*>(this), 1492 Trace("%s 0x%p 0x%x 0x%x", msg, reinterpret_cast<void*>(this),
1493 entry_.address().value(), node_.address().value()); 1493 entry_.address().value(), node_.address().value());
1494 1494
1495 Trace(" data: 0x%x 0x%x 0x%x", entry_.Data()->data_addr[0], 1495 Trace(" data: 0x%x 0x%x 0x%x", entry_.Data()->data_addr[0],
1496 entry_.Data()->data_addr[1], entry_.Data()->long_key); 1496 entry_.Data()->data_addr[1], entry_.Data()->long_key);
1497 1497
1498 Trace(" doomed: %d 0x%x", doomed_, dirty); 1498 Trace(" doomed: %d 0x%x", doomed_, dirty);
1499 } 1499 }
1500 1500
1501 } // namespace disk_cache 1501 } // namespace disk_cache
OLDNEW
« no previous file with comments | « net/base/x509_certificate_win.cc ('k') | net/http/http_mac_signature.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698