| Index: net/tools/dump_cache/dump_cache.cc
|
| diff --git a/net/tools/dump_cache/dump_cache.cc b/net/tools/dump_cache/dump_cache.cc
|
| index 1b651189f73256b8faa87bccba9a5a1e673ccfa5..106fbfd87008c776d9581707567fc4c68344f789 100644
|
| --- a/net/tools/dump_cache/dump_cache.cc
|
| +++ b/net/tools/dump_cache/dump_cache.cc
|
| @@ -13,8 +13,14 @@
|
| #include "base/process_util.h"
|
| #include "base/string_util.h"
|
| #include "base/stringprintf.h"
|
| -#include "base/win/scoped_handle.h"
|
| #include "net/disk_cache/disk_format.h"
|
| +#include "net/tools/dump_cache/dump_files.h"
|
| +#include "net/tools/dump_cache/simple_cache_dumper.h"
|
| +
|
| +#if defined(OS_WIN)
|
| +#include "base/win/scoped_handle.h"
|
| +#include "net/tools/dump_cache/upgrade_win.h"
|
| +#endif
|
|
|
| enum Errors {
|
| GENERIC = -1,
|
| @@ -25,13 +31,6 @@ enum Errors {
|
| TOOL_NOT_FOUND,
|
| };
|
|
|
| -int GetMajorVersion(const FilePath& input_path);
|
| -int DumpContents(const FilePath& input_path);
|
| -int DumpHeaders(const FilePath& input_path);
|
| -int RunSlave(const FilePath& input_path, const std::wstring& pipe_number);
|
| -int CopyCache(const FilePath& output_path, HANDLE pipe, bool copy_to_text);
|
| -HANDLE CreateServer(std::wstring* pipe_number);
|
| -
|
| const char kUpgradeHelp[] =
|
| "\nIn order to use the upgrade function, a version of this tool that\n"
|
| "understands the file format of the files to upgrade is needed. For\n"
|
| @@ -70,6 +69,8 @@ int Help() {
|
| return INVALID_ARGUMENT;
|
| }
|
|
|
| +#if defined(OS_WIN)
|
| +
|
| // Starts a new process, to generate the files.
|
| int LaunchSlave(CommandLine command_line,
|
| const std::wstring& pipe_number,
|
| @@ -95,6 +96,8 @@ int LaunchSlave(CommandLine command_line,
|
| return ALL_GOOD;
|
| }
|
|
|
| +#endif
|
| +
|
| // -----------------------------------------------------------------------
|
|
|
| int main(int argc, const char* argv[]) {
|
| @@ -108,17 +111,21 @@ int main(int argc, const char* argv[]) {
|
| if (input_path.empty())
|
| return Help();
|
|
|
| - bool upgrade = false;
|
| - bool slave_required = false;
|
| - bool copy_to_text = false;
|
| FilePath output_path = command_line.GetSwitchValuePath(kOutputPath);
|
|
|
| + if (command_line.HasSwitch(kDumpToFiles)) {
|
| + net::SimpleCacheDumper dumper(input_path, output_path);
|
| + dumper.Run();
|
| + return 0;
|
| + }
|
| +
|
| +#if defined(OS_WIN)
|
| + bool upgrade = false;
|
| if (command_line.HasSwitch(kUpgrade))
|
| upgrade = true;
|
| - if (command_line.HasSwitch(kDumpToFiles))
|
| - copy_to_text = true;
|
|
|
| - if (upgrade || copy_to_text) {
|
| + bool slave_required = false;
|
| + if (upgrade) {
|
| if (output_path.empty())
|
| return Help();
|
| slave_required = true;
|
| @@ -153,8 +160,10 @@ int main(int argc, const char* argv[]) {
|
| return ret;
|
| }
|
|
|
| - if (upgrade || copy_to_text)
|
| - return CopyCache(output_path, server, copy_to_text);
|
| + // TODO(rch): Remove the logic from CopyCache that is redundant with
|
| + // SimpleCacheDumper.
|
| + if (upgrade)
|
| + return CopyCache(output_path, server, false);
|
|
|
| if (slave_required) {
|
| // Wait until the slave starts dumping data before we quit. Lazy "fix" for a
|
| @@ -167,5 +176,6 @@ int main(int argc, const char* argv[]) {
|
| return DumpContents(input_path);
|
| if (command_line.HasSwitch(kDumpHeaders))
|
| return DumpHeaders(input_path);
|
| +#endif
|
| return Help();
|
| }
|
|
|