Commit 0999cb0a authored by rvargas@google.com's avatar rvargas@google.com

Disk cache: Detect hardware failures when reading the headers

of block mapped files.

BUG=90087
TEST=none
Review URL: http://codereview.chromium.org/7661006

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@96971 0039d316-1c4b-4281-b951-d872f2087c98
parent c64258bf
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "base/file_path.h" #include "base/file_path.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "net/disk_cache/disk_cache.h" #include "net/disk_cache/disk_cache.h"
namespace disk_cache { namespace disk_cache {
...@@ -26,6 +27,12 @@ void* MappedFile::Init(const FilePath& name, size_t size) { ...@@ -26,6 +27,12 @@ void* MappedFile::Init(const FilePath& name, size_t size) {
DCHECK(buffer_); DCHECK(buffer_);
view_size_ = size; view_size_ = size;
// Make sure we detect hardware failures reading the headers.
size_t temp_len = size ? size : 4096;
scoped_array<char> temp(new char[temp_len]);
if (!Read(temp.get(), temp_len, 0))
return NULL;
return buffer_; return buffer_;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment