OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/browser/cache_storage/cache_storage_manager.h" | 5 #include "content/browser/cache_storage/cache_storage_manager.h" |
6 | 6 |
| 7 #include <stdint.h> |
| 8 |
7 #include <map> | 9 #include <map> |
8 #include <string> | 10 #include <string> |
9 | 11 |
10 #include "base/bind.h" | 12 #include "base/bind.h" |
11 #include "base/files/file_enumerator.h" | 13 #include "base/files/file_enumerator.h" |
12 #include "base/files/file_util.h" | 14 #include "base/files/file_util.h" |
13 #include "base/id_map.h" | 15 #include "base/id_map.h" |
14 #include "base/sha1.h" | 16 #include "base/sha1.h" |
15 #include "base/stl_util.h" | 17 #include "base/stl_util.h" |
16 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 } | 67 } |
66 | 68 |
67 std::vector<CacheStorageUsageInfo> GetAllOriginsUsageOnTaskRunner( | 69 std::vector<CacheStorageUsageInfo> GetAllOriginsUsageOnTaskRunner( |
68 const base::FilePath root_path) { | 70 const base::FilePath root_path) { |
69 std::vector<CacheStorageUsageInfo> entries; | 71 std::vector<CacheStorageUsageInfo> entries; |
70 const std::set<GURL> origins = ListOriginsOnDisk(root_path); | 72 const std::set<GURL> origins = ListOriginsOnDisk(root_path); |
71 entries.reserve(origins.size()); | 73 entries.reserve(origins.size()); |
72 for (const GURL& origin : origins) { | 74 for (const GURL& origin : origins) { |
73 base::FilePath path = | 75 base::FilePath path = |
74 CacheStorageManager::ConstructOriginPath(root_path, origin); | 76 CacheStorageManager::ConstructOriginPath(root_path, origin); |
75 int64 size = base::ComputeDirectorySize(path); | 77 int64_t size = base::ComputeDirectorySize(path); |
76 base::File::Info file_info; | 78 base::File::Info file_info; |
77 base::Time last_modified; | 79 base::Time last_modified; |
78 if (base::GetFileInfo(path, &file_info)) | 80 if (base::GetFileInfo(path, &file_info)) |
79 last_modified = file_info.last_modified; | 81 last_modified = file_info.last_modified; |
80 entries.push_back(CacheStorageUsageInfo(origin, size, last_modified)); | 82 entries.push_back(CacheStorageUsageInfo(origin, size, last_modified)); |
81 } | 83 } |
82 return entries; | 84 return entries; |
83 } | 85 } |
84 | 86 |
85 void GetOriginsForHostDidListOrigins( | 87 void GetOriginsForHostDidListOrigins( |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 base::Bind(&GetAllOriginsUsageOnTaskRunner, root_path_), | 224 base::Bind(&GetAllOriginsUsageOnTaskRunner, root_path_), |
223 base::Bind(callback)); | 225 base::Bind(callback)); |
224 } | 226 } |
225 | 227 |
226 void CacheStorageManager::GetOriginUsage( | 228 void CacheStorageManager::GetOriginUsage( |
227 const GURL& origin_url, | 229 const GURL& origin_url, |
228 const storage::QuotaClient::GetUsageCallback& callback) { | 230 const storage::QuotaClient::GetUsageCallback& callback) { |
229 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 231 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
230 | 232 |
231 if (IsMemoryBacked()) { | 233 if (IsMemoryBacked()) { |
232 int64 usage = 0; | 234 int64_t usage = 0; |
233 if (ContainsKey(cache_storage_map_, origin_url)) | 235 if (ContainsKey(cache_storage_map_, origin_url)) |
234 usage = cache_storage_map_[origin_url]->MemoryBackedSize(); | 236 usage = cache_storage_map_[origin_url]->MemoryBackedSize(); |
235 callback.Run(usage); | 237 callback.Run(usage); |
236 return; | 238 return; |
237 } | 239 } |
238 | 240 |
239 MigrateOrigin(origin_url); | 241 MigrateOrigin(origin_url); |
240 PostTaskAndReplyWithResult( | 242 PostTaskAndReplyWithResult( |
241 cache_task_runner_.get(), FROM_HERE, | 243 cache_task_runner_.get(), FROM_HERE, |
242 base::Bind(base::ComputeDirectorySize, | 244 base::Bind(base::ComputeDirectorySize, |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 const base::FilePath& old_path, | 407 const base::FilePath& old_path, |
406 const base::FilePath& new_path) { | 408 const base::FilePath& new_path) { |
407 if (base::PathExists(old_path)) { | 409 if (base::PathExists(old_path)) { |
408 if (!base::PathExists(new_path)) | 410 if (!base::PathExists(new_path)) |
409 base::Move(old_path, new_path); | 411 base::Move(old_path, new_path); |
410 base::DeleteFile(old_path, /*recursive*/ true); | 412 base::DeleteFile(old_path, /*recursive*/ true); |
411 } | 413 } |
412 } | 414 } |
413 | 415 |
414 } // namespace content | 416 } // namespace content |
OLD | NEW |