Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(135)

Side by Side Diff: net/tools/dump_cache/dump_cache.cc

Issue 330024: Make the command line syntax a little easier.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 printf("--upgrade: copy contents to the output path\n"); 68 printf("--upgrade: copy contents to the output path\n");
69 printf("--dump-to-files: write the contents of the cache to files\n"); 69 printf("--dump-to-files: write the contents of the cache to files\n");
70 return INVALID_ARGUMENT; 70 return INVALID_ARGUMENT;
71 } 71 }
72 72
73 // Starts a new process, to generate the files. 73 // Starts a new process, to generate the files.
74 int LaunchSlave(const CommandLine& command_line, 74 int LaunchSlave(const CommandLine& command_line,
75 const std::wstring& pipe_number, int version) { 75 const std::wstring& pipe_number, int version) {
76 // TODO(port): remove this string-munging hackery. 76 // TODO(port): remove this string-munging hackery.
77 std::wstring hacked_command_line = command_line.command_line_string(); 77 std::wstring hacked_command_line = command_line.command_line_string();
78 const std::wstring old_exe(L"dump_cache.exe"); 78 const std::wstring old_exe(L"dump_cache");
79 size_t to_remove = hacked_command_line.find(old_exe); 79 size_t to_remove = hacked_command_line.find(old_exe);
80 hacked_command_line.erase(to_remove, old_exe.size()); 80 hacked_command_line.erase(to_remove, old_exe.size());
81 81
82 bool do_upgrade = command_line.HasSwitch(kUpgrade); 82 bool do_upgrade = command_line.HasSwitch(kUpgrade);
83 bool do_convert_to_text = command_line.HasSwitch(kDumpToFiles); 83 bool do_convert_to_text = command_line.HasSwitch(kDumpToFiles);
84 84
85 std::wstring new_program; 85 std::wstring new_program;
86 if (do_upgrade) 86 if (do_upgrade)
87 new_program = StringPrintf(L"%ls%d.exe", L"dump_cache_", version); 87 new_program = StringPrintf(L"%ls%d", L"dump_cache_", version);
88 else 88 else
89 new_program = StringPrintf(L"dump_cache.exe"); 89 new_program = StringPrintf(L"dump_cache");
90 90
91 hacked_command_line.insert(to_remove, new_program); 91 hacked_command_line.insert(to_remove, new_program);
92 92
93 CommandLine new_command_line(L""); 93 CommandLine new_command_line(L"");
94 new_command_line.ParseFromString(hacked_command_line); 94 new_command_line.ParseFromString(hacked_command_line);
95 95
96 if (do_upgrade || do_convert_to_text) 96 if (do_upgrade || do_convert_to_text)
97 new_command_line.AppendSwitch(kSlave); 97 new_command_line.AppendSwitch(kSlave);
98 98
99 new_command_line.AppendSwitchWithValue(kPipe, pipe_number); 99 new_command_line.AppendSwitchWithValue(kPipe, pipe_number);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 Sleep(500); 172 Sleep(500);
173 return ALL_GOOD; 173 return ALL_GOOD;
174 } 174 }
175 175
176 if (command_line.HasSwitch(kDumpContents)) 176 if (command_line.HasSwitch(kDumpContents))
177 return DumpContents(input_path); 177 return DumpContents(input_path);
178 if (command_line.HasSwitch(kDumpHeaders)) 178 if (command_line.HasSwitch(kDumpHeaders))
179 return DumpHeaders(input_path); 179 return DumpHeaders(input_path);
180 return Help(); 180 return Help();
181 } 181 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698