OLD | NEW |
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 "webkit/fileapi/file_system_usage_cache.h" | 5 #include "webkit/fileapi/file_system_usage_cache.h" |
6 | 6 |
7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/pickle.h" | 9 #include "base/pickle.h" |
10 | 10 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 uint32 dirty = 0; | 78 uint32 dirty = 0; |
79 int64 fs_usage; | 79 int64 fs_usage; |
80 fs_usage = Read(usage_file_path, &is_valid, &dirty); | 80 fs_usage = Read(usage_file_path, &is_valid, &dirty); |
81 | 81 |
82 return fs_usage >= 0 && Write(usage_file_path, false, dirty, fs_usage); | 82 return fs_usage >= 0 && Write(usage_file_path, false, dirty, fs_usage); |
83 } | 83 } |
84 | 84 |
85 bool FileSystemUsageCache::IsValid(const FilePath& usage_file_path) { | 85 bool FileSystemUsageCache::IsValid(const FilePath& usage_file_path) { |
86 bool is_valid = true; | 86 bool is_valid = true; |
87 uint32 dirty = 0; | 87 uint32 dirty = 0; |
88 int64 fs_usage; | 88 Read(usage_file_path, &is_valid, &dirty); |
89 fs_usage = Read(usage_file_path, &is_valid, &dirty); | |
90 return is_valid; | 89 return is_valid; |
91 } | 90 } |
92 | 91 |
93 // static | 92 // static |
94 int FileSystemUsageCache::AtomicUpdateUsageByDelta( | 93 int FileSystemUsageCache::AtomicUpdateUsageByDelta( |
95 const FilePath& usage_file_path, int64 delta) { | 94 const FilePath& usage_file_path, int64 delta) { |
96 bool is_valid = true; | 95 bool is_valid = true; |
97 uint32 dirty = 0; | 96 uint32 dirty = 0; |
98 int64 fs_usage; | 97 int64 fs_usage; |
99 // TODO(dmikurube): Make sure that usage_file_path is available. | 98 // TODO(dmikurube): Make sure that usage_file_path is available. |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 if (bytes_written != kUsageFileSize) | 170 if (bytes_written != kUsageFileSize) |
172 return -1; | 171 return -1; |
173 | 172 |
174 if (file_util::ReplaceFile(temporary_usage_file_path, usage_file_path)) | 173 if (file_util::ReplaceFile(temporary_usage_file_path, usage_file_path)) |
175 return bytes_written; | 174 return bytes_written; |
176 else | 175 else |
177 return -1; | 176 return -1; |
178 } | 177 } |
179 | 178 |
180 } // namespace fileapi | 179 } // namespace fileapi |
OLD | NEW |