| 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 // 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 "net/tools/dump_cache/dump_files.h" | 9 #include "net/tools/dump_cache/dump_files.h" |
| 10 | 10 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 disk_cache::IndexHeader header; | 50 disk_cache::IndexHeader header; |
| 51 if (!ReadHeader(name, reinterpret_cast<char*>(&header), sizeof(header))) | 51 if (!ReadHeader(name, reinterpret_cast<char*>(&header), sizeof(header))) |
| 52 return 0; | 52 return 0; |
| 53 | 53 |
| 54 return header.version >> 16; | 54 return header.version >> 16; |
| 55 } | 55 } |
| 56 | 56 |
| 57 // Dumps the contents of the Stats record. | 57 // Dumps the contents of the Stats record. |
| 58 void DumpStats(const base::FilePath& path, disk_cache::CacheAddr addr) { | 58 void DumpStats(const base::FilePath& path, disk_cache::CacheAddr addr) { |
| 59 // We need a message loop, although we really don't run any task. | 59 // We need a message loop, although we really don't run any task. |
| 60 base::MessageLoop loop(base::MessageLoop::TYPE_IO); | 60 base::MessageLoopForIO loop; |
| 61 | 61 |
| 62 disk_cache::BlockFiles block_files(path); | 62 disk_cache::BlockFiles block_files(path); |
| 63 if (!block_files.Init(false)) { | 63 if (!block_files.Init(false)) { |
| 64 printf("Unable to init block files\n"); | 64 printf("Unable to init block files\n"); |
| 65 return; | 65 return; |
| 66 } | 66 } |
| 67 | 67 |
| 68 disk_cache::Addr address(addr); | 68 disk_cache::Addr address(addr); |
| 69 disk_cache::MappedFile* file = block_files.GetFile(address); | 69 disk_cache::MappedFile* file = block_files.GetFile(address); |
| 70 if (!file) | 70 if (!file) |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 | 348 |
| 349 DumpStats(input_path, stats_addr); | 349 DumpStats(input_path, stats_addr); |
| 350 return 0; | 350 return 0; |
| 351 } | 351 } |
| 352 | 352 |
| 353 // Dumps all entries from the cache. | 353 // Dumps all entries from the cache. |
| 354 int DumpContents(const base::FilePath& input_path) { | 354 int DumpContents(const base::FilePath& input_path) { |
| 355 DumpHeaders(input_path); | 355 DumpHeaders(input_path); |
| 356 | 356 |
| 357 // We need a message loop, although we really don't run any task. | 357 // We need a message loop, although we really don't run any task. |
| 358 base::MessageLoop loop(base::MessageLoop::TYPE_IO); | 358 base::MessageLoopForIO loop; |
| 359 CacheDumper dumper(input_path); | 359 CacheDumper dumper(input_path); |
| 360 if (!dumper.Init()) | 360 if (!dumper.Init()) |
| 361 return -1; | 361 return -1; |
| 362 | 362 |
| 363 disk_cache::EntryStore entry; | 363 disk_cache::EntryStore entry; |
| 364 while (dumper.GetEntry(&entry)) { | 364 while (dumper.GetEntry(&entry)) { |
| 365 DumpEntry(entry); | 365 DumpEntry(entry); |
| 366 disk_cache::RankingsNode rankings; | 366 disk_cache::RankingsNode rankings; |
| 367 if (dumper.LoadRankings(entry.rankings_node, &rankings)) | 367 if (dumper.LoadRankings(entry.rankings_node, &rankings)) |
| 368 DumpRankings(rankings); | 368 DumpRankings(rankings); |
| 369 } | 369 } |
| 370 | 370 |
| 371 printf("Done.\n"); | 371 printf("Done.\n"); |
| 372 | 372 |
| 373 return 0; | 373 return 0; |
| 374 } | 374 } |
| OLD | NEW |