diff options
author | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-16 17:44:25 +0000 |
---|---|---|
committer | rvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-16 17:44:25 +0000 |
commit | 0999cb0ab1dcc73b824ac57d4ef7e42473da12be (patch) | |
tree | 0da809e0d21802948af68c6f396eddb0cadf0976 /net | |
parent | c64258bfd6961e667df3bba6d14b23ebb75aed9e (diff) | |
download | chromium_src-0999cb0ab1dcc73b824ac57d4ef7e42473da12be.zip chromium_src-0999cb0ab1dcc73b824ac57d4ef7e42473da12be.tar.gz chromium_src-0999cb0ab1dcc73b824ac57d4ef7e42473da12be.tar.bz2 |
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
Diffstat (limited to 'net')
-rw-r--r-- | net/disk_cache/mapped_file_win.cc | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/net/disk_cache/mapped_file_win.cc b/net/disk_cache/mapped_file_win.cc index 69c13a4..9931e3e 100644 --- a/net/disk_cache/mapped_file_win.cc +++ b/net/disk_cache/mapped_file_win.cc @@ -1,4 +1,4 @@ -// 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 // found in the LICENSE file. @@ -6,6 +6,7 @@ #include "base/file_path.h" #include "base/logging.h" +#include "base/memory/scoped_ptr.h" #include "net/disk_cache/disk_cache.h" namespace disk_cache { @@ -26,6 +27,12 @@ void* MappedFile::Init(const FilePath& name, size_t size) { DCHECK(buffer_); 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_; } |