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 "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 FilePath::CharType FileSystemUsageCache::kUsageFileName[] = | 13 const FilePath::CharType FileSystemUsageCache::kUsageFileName[] = |
14 FILE_PATH_LITERAL(".usage"); | 14 FILE_PATH_LITERAL(".usage"); |
15 const char FileSystemUsageCache::kUsageFileHeader[] = "FSU4"; | 15 const char FileSystemUsageCache::kUsageFileHeader[] = "FSU5"; |
16 const int FileSystemUsageCache::kUsageFileHeaderSize = 4; | 16 const int FileSystemUsageCache::kUsageFileHeaderSize = 4; |
17 | 17 |
18 /* Pickle::{Read,Write}Bool treat bool as int */ | 18 /* Pickle::{Read,Write}Bool treat bool as int */ |
19 const int FileSystemUsageCache::kUsageFileSize = | 19 const int FileSystemUsageCache::kUsageFileSize = |
20 sizeof(Pickle::Header) + | 20 sizeof(Pickle::Header) + |
21 FileSystemUsageCache::kUsageFileHeaderSize + | 21 FileSystemUsageCache::kUsageFileHeaderSize + |
22 sizeof(int) + sizeof(int32) + sizeof(int64); | 22 sizeof(int) + sizeof(int32) + sizeof(int64); |
23 | 23 |
24 // static | 24 // static |
25 int64 FileSystemUsageCache::GetUsage(const FilePath& usage_file_path) { | 25 int64 FileSystemUsageCache::GetUsage(const FilePath& usage_file_path) { |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 if (bytes_written != kUsageFileSize) | 177 if (bytes_written != kUsageFileSize) |
178 return -1; | 178 return -1; |
179 | 179 |
180 if (file_util::ReplaceFile(temporary_usage_file_path, usage_file_path)) | 180 if (file_util::ReplaceFile(temporary_usage_file_path, usage_file_path)) |
181 return bytes_written; | 181 return bytes_written; |
182 else | 182 else |
183 return -1; | 183 return -1; |
184 } | 184 } |
185 | 185 |
186 } // namespace fileapi | 186 } // namespace fileapi |
OLD | NEW |