summaryrefslogtreecommitdiffstats
path: root/net/disk_cache
diff options
context:
space:
mode:
authorrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-08 18:35:56 +0000
committerrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-08 18:35:56 +0000
commitb56ccebe2ee52aaaac8f6ec68edc024235e7d478 (patch)
tree63d46a045f6fea4a263971812fd60ce06384b148 /net/disk_cache
parentd309b1dc4faf84c084d508ccb1a9e8b2dbfe382c (diff)
downloadchromium_src-b56ccebe2ee52aaaac8f6ec68edc024235e7d478.zip
chromium_src-b56ccebe2ee52aaaac8f6ec68edc024235e7d478.tar.gz
chromium_src-b56ccebe2ee52aaaac8f6ec68edc024235e7d478.tar.bz2
Disk cache: Pre-read file headers when opening files (posix).
BUG=128140 TEST=none Review URL: https://chromiumcodereview.appspot.com/10454093 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@141245 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/disk_cache')
-rw-r--r--net/disk_cache/mapped_file_posix.cc10
1 files changed, 8 insertions, 2 deletions
diff --git a/net/disk_cache/mapped_file_posix.cc b/net/disk_cache/mapped_file_posix.cc
index ce9ae89..46bbc24 100644
--- a/net/disk_cache/mapped_file_posix.cc
+++ b/net/disk_cache/mapped_file_posix.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -18,17 +18,23 @@ void* MappedFile::Init(const FilePath& name, size_t size) {
if (init_ || !File::Init(name))
return NULL;
+ size_t temp_len = size ? size : 4096;
if (!size)
size = GetLength();
buffer_ = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED,
platform_file(), 0);
init_ = true;
+ view_size_ = size;
DCHECK(reinterpret_cast<intptr_t>(buffer_) != -1);
if (reinterpret_cast<intptr_t>(buffer_) == -1)
buffer_ = 0;
- view_size_ = size;
+ // Make sure we detect hardware failures reading the headers.
+ scoped_array<char> temp(new char[temp_len]);
+ if (!Read(temp.get(), temp_len, 0))
+ return NULL;
+
return buffer_;
}