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 // 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 <set> | 9 #include <set> |
10 #include <stdio.h> | 10 #include <stdio.h> |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "base/file_util.h" | 13 #include "base/file_util.h" |
14 #include "base/message_loop.h" | 14 #include "base/message_loop.h" |
15 #include "net/base/file_stream.h" | 15 #include "net/base/file_stream.h" |
16 #include "net/disk_cache/block_files.h" | 16 #include "net/disk_cache/block_files.h" |
17 #include "net/disk_cache/disk_format.h" | 17 #include "net/disk_cache/disk_format.h" |
18 #include "net/disk_cache/mapped_file.h" | 18 #include "net/disk_cache/mapped_file.h" |
19 #include "net/disk_cache/storage_block.h" | 19 #include "net/disk_cache/storage_block.h" |
20 #include "net/disk_cache/storage_block-inl.h" | 20 #include "net/disk_cache/storage_block-inl.h" |
21 | 21 |
22 namespace { | 22 namespace { |
23 | 23 |
24 const wchar_t kIndexName[] = L"index"; | 24 const wchar_t kIndexName[] = L"index"; |
25 const wchar_t kDataPrefix[] = L"data_"; | 25 const wchar_t kDataPrefix[] = L"data_"; |
26 | 26 |
27 // Reads the |header_size| bytes from the beginning of file |name|. | 27 // Reads the |header_size| bytes from the beginning of file |name|. |
28 bool ReadHeader(const std::wstring& name, char* header, int header_size) { | 28 bool ReadHeader(const std::wstring& name, char* header, int header_size) { |
29 net::FileStream file; | 29 net::FileStream file(NULL); |
30 file.Open(FilePath::FromWStringHack(name), | 30 file.Open(FilePath::FromWStringHack(name), |
31 base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ); | 31 base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ); |
32 if (!file.IsOpen()) { | 32 if (!file.IsOpen()) { |
33 printf("Unable to open file %ls\n", name.c_str()); | 33 printf("Unable to open file %ls\n", name.c_str()); |
34 return false; | 34 return false; |
35 } | 35 } |
36 | 36 |
37 int read = file.Read(header, header_size, net::CompletionCallback()); | 37 int read = file.Read(header, header_size, net::CompletionCallback()); |
38 if (read != header_size) { | 38 if (read != header_size) { |
39 printf("Unable to read file %ls\n", name.c_str()); | 39 printf("Unable to read file %ls\n", name.c_str()); |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 DumpEntry(entry); | 319 DumpEntry(entry); |
320 disk_cache::RankingsNode rankings; | 320 disk_cache::RankingsNode rankings; |
321 if (dumper.LoadRankings(entry.rankings_node, &rankings)) | 321 if (dumper.LoadRankings(entry.rankings_node, &rankings)) |
322 DumpRankings(rankings); | 322 DumpRankings(rankings); |
323 } | 323 } |
324 | 324 |
325 printf("Done.\n"); | 325 printf("Done.\n"); |
326 | 326 |
327 return 0; | 327 return 0; |
328 } | 328 } |
OLD | NEW |