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 |
11 namespace fileapi { | 11 namespace fileapi { |
12 | 12 |
13 const char FileSystemUsageCache::kUsageFileName[] = ".usage"; | 13 const char FileSystemUsageCache::kUsageFileName[] = ".usage"; |
14 const char FileSystemUsageCache::kUsageFileHeader[] = "FSU2"; | 14 const char FileSystemUsageCache::kUsageFileHeader[] = "FSU3"; |
15 const int FileSystemUsageCache::kUsageFileHeaderSize = 4; | 15 const int FileSystemUsageCache::kUsageFileHeaderSize = 4; |
16 const int FileSystemUsageCache::kUsageFileSize = | 16 const int FileSystemUsageCache::kUsageFileSize = |
17 sizeof(Pickle::Header) + | 17 sizeof(Pickle::Header) + |
18 FileSystemUsageCache::kUsageFileHeaderSize + | 18 FileSystemUsageCache::kUsageFileHeaderSize + |
19 sizeof(int32) + sizeof(int64); | 19 sizeof(int32) + sizeof(int64); |
20 | 20 |
21 // static | 21 // static |
22 int64 FileSystemUsageCache::GetUsage(const FilePath& usage_file_path) { | 22 int64 FileSystemUsageCache::GetUsage(const FilePath& usage_file_path) { |
23 uint32 dirty = 0; | 23 uint32 dirty = 0; |
24 int64 fs_usage; | 24 int64 fs_usage; |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 if (bytes_written != kUsageFileSize) | 138 if (bytes_written != kUsageFileSize) |
139 return -1; | 139 return -1; |
140 | 140 |
141 if (file_util::ReplaceFile(temporary_usage_file_path, usage_file_path)) | 141 if (file_util::ReplaceFile(temporary_usage_file_path, usage_file_path)) |
142 return bytes_written; | 142 return bytes_written; |
143 else | 143 else |
144 return -1; | 144 return -1; |
145 } | 145 } |
146 | 146 |
147 } | 147 } |
OLD | NEW |