OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "storage/browser/fileapi/file_system_usage_cache.h" | 5 #include "storage/browser/fileapi/file_system_usage_cache.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <utility> | 10 #include <utility> |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 } | 126 } |
127 | 127 |
128 bool FileSystemUsageCache::AtomicUpdateUsageByDelta( | 128 bool FileSystemUsageCache::AtomicUpdateUsageByDelta( |
129 const base::FilePath& usage_file_path, | 129 const base::FilePath& usage_file_path, |
130 int64_t delta) { | 130 int64_t delta) { |
131 TRACE_EVENT0("FileSystem", "UsageCache::AtomicUpdateUsageByDelta"); | 131 TRACE_EVENT0("FileSystem", "UsageCache::AtomicUpdateUsageByDelta"); |
132 DCHECK(CalledOnValidThread()); | 132 DCHECK(CalledOnValidThread()); |
133 bool is_valid = true; | 133 bool is_valid = true; |
134 uint32_t dirty = 0; | 134 uint32_t dirty = 0; |
135 int64_t usage = 0; | 135 int64_t usage = 0; |
136 ; | |
137 if (!Read(usage_file_path, &is_valid, &dirty, &usage)) | 136 if (!Read(usage_file_path, &is_valid, &dirty, &usage)) |
138 return false; | 137 return false; |
139 return Write(usage_file_path, is_valid, dirty, usage + delta); | 138 return Write(usage_file_path, is_valid, dirty, usage + delta); |
140 } | 139 } |
141 | 140 |
142 bool FileSystemUsageCache::UpdateUsage(const base::FilePath& usage_file_path, | 141 bool FileSystemUsageCache::UpdateUsage(const base::FilePath& usage_file_path, |
143 int64_t fs_usage) { | 142 int64_t fs_usage) { |
144 TRACE_EVENT0("FileSystem", "UsageCache::UpdateUsage"); | 143 TRACE_EVENT0("FileSystem", "UsageCache::UpdateUsage"); |
145 DCHECK(CalledOnValidThread()); | 144 DCHECK(CalledOnValidThread()); |
146 return Write(usage_file_path, true, 0, fs_usage); | 145 return Write(usage_file_path, true, 0, fs_usage); |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 return !task_runner_.get() || task_runner_->RunsTasksOnCurrentThread(); | 297 return !task_runner_.get() || task_runner_->RunsTasksOnCurrentThread(); |
299 } | 298 } |
300 | 299 |
301 bool FileSystemUsageCache::HasCacheFileHandle(const base::FilePath& file_path) { | 300 bool FileSystemUsageCache::HasCacheFileHandle(const base::FilePath& file_path) { |
302 DCHECK(CalledOnValidThread()); | 301 DCHECK(CalledOnValidThread()); |
303 DCHECK_LE(cache_files_.size(), kMaxHandleCacheSize); | 302 DCHECK_LE(cache_files_.size(), kMaxHandleCacheSize); |
304 return ContainsKey(cache_files_, file_path); | 303 return ContainsKey(cache_files_, file_path); |
305 } | 304 } |
306 | 305 |
307 } // namespace storage | 306 } // namespace storage |
OLD | NEW |