| 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 // This command-line program dumps the contents of a set of cache files, either | 5 // This command-line program dumps the contents of a set of cache files, either |
| 6 // to stdout or to another set of cache files. | 6 // to stdout or to another set of cache files. |
| 7 | 7 |
| 8 #include <stdio.h> | 8 #include <stdio.h> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 | 122 |
| 123 base::FilePath output_path = command_line.GetSwitchValuePath(kOutputPath); | 123 base::FilePath output_path = command_line.GetSwitchValuePath(kOutputPath); |
| 124 if ((dump_to_files || upgrade) && output_path.empty()) | 124 if ((dump_to_files || upgrade) && output_path.empty()) |
| 125 return Help(); | 125 return Help(); |
| 126 | 126 |
| 127 int version = GetMajorVersion(input_path); | 127 int version = GetMajorVersion(input_path); |
| 128 if (!version) | 128 if (!version) |
| 129 return FILE_ACCESS_ERROR; | 129 return FILE_ACCESS_ERROR; |
| 130 | 130 |
| 131 bool slave_required = upgrade; | 131 bool slave_required = upgrade; |
| 132 if (version != disk_cache::kCurrentVersion >> 16) { | 132 if ((version != 2) && (version != 3)) { |
| 133 if (command_line.HasSwitch(kSlave)) { | 133 if (command_line.HasSwitch(kSlave)) { |
| 134 printf("Unknown version\n"); | 134 printf("Unknown version\n"); |
| 135 return UNKNOWN_VERSION; | 135 return UNKNOWN_VERSION; |
| 136 } | 136 } |
| 137 slave_required = true; | 137 slave_required = true; |
| 138 } | 138 } |
| 139 | 139 |
| 140 #if defined(OS_WIN) | 140 #if defined(OS_WIN) |
| 141 base::string16 pipe_number = command_line.GetSwitchValueNative(kPipe); | 141 base::string16 pipe_number = command_line.GetSwitchValueNative(kPipe); |
| 142 if (command_line.HasSwitch(kSlave) && slave_required) | 142 if (command_line.HasSwitch(kSlave) && slave_required) |
| (...skipping 27 matching lines...) Expand all Loading... |
| 170 return INVALID_ARGUMENT; | 170 return INVALID_ARGUMENT; |
| 171 } | 171 } |
| 172 #endif | 172 #endif |
| 173 | 173 |
| 174 if (dump_to_files) { | 174 if (dump_to_files) { |
| 175 net::SimpleCacheDumper dumper(input_path, output_path); | 175 net::SimpleCacheDumper dumper(input_path, output_path); |
| 176 dumper.Run(); | 176 dumper.Run(); |
| 177 return ALL_GOOD; | 177 return ALL_GOOD; |
| 178 } | 178 } |
| 179 | 179 |
| 180 if (command_line.HasSwitch(kDumpContents)) | 180 if (command_line.HasSwitch(kDumpContents)) { |
| 181 return DumpContents(input_path); | 181 if (version == 3) |
| 182 return DumpContentsV3(input_path); |
| 183 else |
| 184 return DumpContentsV2(input_path); |
| 185 } |
| 182 | 186 |
| 183 if (command_line.HasSwitch(kDumpHeaders)) | 187 if (command_line.HasSwitch(kDumpHeaders)) |
| 184 return DumpHeaders(input_path); | 188 return DumpHeaders(input_path); |
| 185 | 189 |
| 186 return Help(); | 190 return Help(); |
| 187 } | 191 } |
| OLD | NEW |