| OLD | NEW |
| 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2008 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 // Performs basic inspection of the disk cache files with minimal disruption | 5 // Performs basic inspection of the disk cache files with minimal disruption |
| 6 // to the actual files (they still may change if an error is detected on the | 6 // to the actual files (they still may change if an error is detected on the |
| 7 // files). | 7 // files). |
| 8 | 8 |
| 9 #include <stdio.h> | 9 #include <stdio.h> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 } | 270 } |
| 271 | 271 |
| 272 // Dumps the headers of all files. | 272 // Dumps the headers of all files. |
| 273 int DumpHeaders(const std::wstring input_path) { | 273 int DumpHeaders(const std::wstring input_path) { |
| 274 std::wstring index_name(input_path); | 274 std::wstring index_name(input_path); |
| 275 file_util::AppendToPath(&index_name, kIndexName); | 275 file_util::AppendToPath(&index_name, kIndexName); |
| 276 DumpIndexHeader(index_name); | 276 DumpIndexHeader(index_name); |
| 277 | 277 |
| 278 std::wstring pattern(kDataPrefix); | 278 std::wstring pattern(kDataPrefix); |
| 279 pattern.append(L"*"); | 279 pattern.append(L"*"); |
| 280 file_util::FileEnumerator iter(input_path, false, | 280 file_util::FileEnumerator iter(FilePath::FromWStringHack(input_path), false, |
| 281 file_util::FileEnumerator::FILES, pattern); | 281 file_util::FileEnumerator::FILES, pattern); |
| 282 for (std::wstring file = iter.Next(); !file.empty(); file = iter.Next()) { | 282 for (std::wstring file = iter.Next().ToWStringHack(); !file.empty(); |
| 283 file = iter.Next()) { |
| 283 DumpBlockHeader(file); | 284 DumpBlockHeader(file); |
| 284 } | 285 } |
| 285 | 286 |
| 286 return 0; | 287 return 0; |
| 287 } | 288 } |
| 288 | 289 |
| 289 // Dumps all entries from the cache. | 290 // Dumps all entries from the cache. |
| 290 int DumpContents(const std::wstring input_path) { | 291 int DumpContents(const std::wstring input_path) { |
| 291 DumpHeaders(input_path); | 292 DumpHeaders(input_path); |
| 292 | 293 |
| 293 // We need a message loop, although we really don't run any task. | 294 // We need a message loop, although we really don't run any task. |
| 294 MessageLoop loop(MessageLoop::TYPE_IO); | 295 MessageLoop loop(MessageLoop::TYPE_IO); |
| 295 CacheDumper dumper(input_path); | 296 CacheDumper dumper(input_path); |
| 296 if (!dumper.Init()) | 297 if (!dumper.Init()) |
| 297 return -1; | 298 return -1; |
| 298 | 299 |
| 299 disk_cache::EntryStore entry; | 300 disk_cache::EntryStore entry; |
| 300 while (dumper.GetEntry(&entry)) { | 301 while (dumper.GetEntry(&entry)) { |
| 301 DumpEntry(entry); | 302 DumpEntry(entry); |
| 302 disk_cache::RankingsNode rankings; | 303 disk_cache::RankingsNode rankings; |
| 303 if (dumper.LoadRankings(entry.rankings_node, &rankings)) | 304 if (dumper.LoadRankings(entry.rankings_node, &rankings)) |
| 304 DumpRankings(rankings); | 305 DumpRankings(rankings); |
| 305 } | 306 } |
| 306 | 307 |
| 307 printf("Done.\n"); | 308 printf("Done.\n"); |
| 308 | 309 |
| 309 return 0; | 310 return 0; |
| 310 } | 311 } |
| OLD | NEW |