Commit 1e46ff62 authored by tzik@chromium.org's avatar tzik@chromium.org

Handle invalid usage cache file path

usage_file_path can be empty when a FileSystem is accessed after DeleteFileSystem call.

BUG=


Review URL: https://chromiumcodereview.appspot.com/10832316

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@151692 0039d316-1c4b-4281-b951-d872f2087c98
parent e059844f
...@@ -130,9 +130,9 @@ int64 FileSystemUsageCache::Read(const FilePath& usage_file_path, ...@@ -130,9 +130,9 @@ int64 FileSystemUsageCache::Read(const FilePath& usage_file_path,
uint32* dirty) { uint32* dirty) {
char buffer[kUsageFileSize]; char buffer[kUsageFileSize];
const char *header; const char *header;
DCHECK(!usage_file_path.empty()); if (usage_file_path.empty() ||
if (kUsageFileSize != kUsageFileSize != file_util::ReadFile(usage_file_path,
file_util::ReadFile(usage_file_path, buffer, kUsageFileSize)) buffer, kUsageFileSize))
return -1; return -1;
Pickle read_pickle(buffer, kUsageFileSize); Pickle read_pickle(buffer, kUsageFileSize);
PickleIterator iter(read_pickle); PickleIterator iter(read_pickle);
...@@ -164,9 +164,9 @@ int FileSystemUsageCache::Write(const FilePath& usage_file_path, ...@@ -164,9 +164,9 @@ int FileSystemUsageCache::Write(const FilePath& usage_file_path,
write_pickle.WriteUInt32(dirty); write_pickle.WriteUInt32(dirty);
write_pickle.WriteInt64(fs_usage); write_pickle.WriteInt64(fs_usage);
DCHECK(!usage_file_path.empty());
FilePath temporary_usage_file_path; FilePath temporary_usage_file_path;
if (!file_util::CreateTemporaryFileInDir(usage_file_path.DirName(), if (usage_file_path.empty() ||
!file_util::CreateTemporaryFileInDir(usage_file_path.DirName(),
&temporary_usage_file_path)) { &temporary_usage_file_path)) {
return -1; return -1;
} }
......
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