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

Issue 6526040: CommandLine refactoring and cleanup. (Closed)

Created:
9 years, 10 months ago by msw
Modified:
9 years, 7 months ago
CC:
chromium-reviews, ncarter (slow), idana, Raghu Simha, brettw-cc_chromium.org, tim (not reviewing), gavinp, Nico
Visibility:
Public.

Description

Consolidate most CommandLine code across platforms. Significant refactoring with some notable behavior changes: 1. Switches are appended preceding existing arguments (after other swtiches). 2. (Windows) command_line_string() is generated and properly quoted/escaped. 3. Appended switches will retain their (optional) included prefixes (--,-,/). Notable internal changes (shouldn't affect behavior): 1. (Windows) Generate the cl string, instead of storing&updating the original. 2. Explicitly retain switch prefixes (--,-,/) (was automatic in init*/ctor). Update (obvious) code expecting switches to be appended antecedent to args. Add Nico's test from: codereview.chromium.org/6728016/. An intermediary CL landed between patch set 3 and 4, see: http://codereview.chromium.org/6596020 BUG=73195, 67764 TEST=Commandline usage. Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=85360

Patch Set 1 #

Patch Set 2 : Crutch CommandLineTest.CommandLineConstructor #

Patch Set 3 : Fix Test #

Total comments: 16

Patch Set 4 : Major refresh after r76339 and r76419. #

Total comments: 30

Patch Set 5 : Address some comments. #

Total comments: 6

Patch Set 6 : Address additional comments, additional refactoring. #

Total comments: 6

Patch Set 7 : Nix program_path_, add and update comments. #

Total comments: 12

Patch Set 8 : Fix nits, merge changes. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+472 lines, -469 lines) Patch
M base/command_line.h View 1 2 3 4 5 6 7 6 chunks +29 lines, -41 lines 0 comments Download
M base/command_line.cc View 1 2 3 4 5 6 7 9 chunks +167 lines, -250 lines 0 comments Download
M base/command_line_unittest.cc View 1 2 3 4 8 chunks +144 lines, -58 lines 0 comments Download
M chrome/browser/browser_main_win.cc View 1 2 3 4 5 6 7 1 chunk +1 line, -2 lines 0 comments Download
M chrome/browser/process_info_snapshot_mac.cc View 1 2 3 4 chunks +37 lines, -42 lines 0 comments Download
M chrome/browser/safe_browsing/safe_browsing_test.cc View 1 2 3 4 5 6 7 1 chunk +3 lines, -2 lines 0 comments Download
M chrome/browser/ui/browser_init.cc View 1 2 3 4 5 6 7 1 chunk +1 line, -1 line 0 comments Download
M chrome/common/switch_utils_unittest.cc View 1 2 3 3 chunks +25 lines, -12 lines 0 comments Download
M chrome/installer/util/install_util.h View 1 2 3 4 5 1 chunk +2 lines, -2 lines 0 comments Download
M chrome/installer/util/install_util.cc View 1 2 3 4 5 1 chunk +2 lines, -17 lines 0 comments Download
M chrome/installer/util/product_state_unittest.cc View 1 2 3 3 chunks +14 lines, -5 lines 0 comments Download
M chrome/test/live_sync/live_sync_test.cc View 1 2 3 4 5 6 7 1 chunk +2 lines, -6 lines 0 comments Download
M chrome/test/ui/ui_test.cc View 1 2 3 4 5 6 7 4 chunks +13 lines, -7 lines 0 comments Download
M chrome/test/ui_test_utils.cc View 1 2 3 4 5 6 3 chunks +15 lines, -8 lines 0 comments Download
M net/test/test_server.cc View 1 2 3 3 chunks +14 lines, -11 lines 0 comments Download
M net/test/test_server_posix.cc View 1 2 3 2 chunks +2 lines, -3 lines 0 comments Download
M net/test/test_server_win.cc View 1 2 3 1 chunk +1 line, -2 lines 0 comments Download

Messages

Total messages: 14 (0 generated)
evanm
I appreciate any cleanup you do, but it's a bit hard to follow this change; ...
9 years, 10 months ago (2011-02-24 01:01:05 UTC) #1
Paweł Hajdan Jr.
Drive-by with testing-related comments. Please let me do another review before committing. http://codereview.chromium.org/6526040/diff/2001/base/command_line.h File base/command_line.h ...
9 years, 10 months ago (2011-02-25 18:01:52 UTC) #2
msw
I finally made some progress; please consider this updated CL. I worry that some obscure ...
9 years, 7 months ago (2011-05-10 23:18:43 UTC) #3
Evan Martin
http://codereview.chromium.org/6526040/diff/26001/base/command_line.cc File base/command_line.cc (left): http://codereview.chromium.org/6526040/diff/26001/base/command_line.cc#oldcode278 base/command_line.cc:278: #endif Since you have to have this ifdef somewhere, ...
9 years, 7 months ago (2011-05-10 23:48:32 UTC) #4
msw
Addressed some comments; responded to others. grt, please review: chrome/installer/util/install_util.cc http://codereview.chromium.org/6526040/diff/26001/base/command_line.cc File base/command_line.cc (left): http://codereview.chromium.org/6526040/diff/26001/base/command_line.cc#oldcode278 ...
9 years, 7 months ago (2011-05-11 02:28:11 UTC) #5
Paweł Hajdan Jr.
Code I commented in the drive-by LGTM, thanks!
9 years, 7 months ago (2011-05-11 07:15:01 UTC) #6
grt (UTC plus 2)
http://codereview.chromium.org/6526040/diff/26003/base/command_line.cc File base/command_line.cc (right): http://codereview.chromium.org/6526040/diff/26003/base/command_line.cc#newcode39 base/command_line.cc:39: CommandLine::StringType GetNativeString(const std::string& string) { These two functions assume ...
9 years, 7 months ago (2011-05-11 14:27:32 UTC) #7
msw
Thanks, Greg! Your feedback prompted some extra refactoring. Evan and Greg, please consider my updated ...
9 years, 7 months ago (2011-05-12 00:37:47 UTC) #8
msw
Ping! Sorry for the size and churn of this change, but feedback is highly appreciated.
9 years, 7 months ago (2011-05-13 15:52:08 UTC) #9
Evan Martin
http://codereview.chromium.org/6526040/diff/39005/base/command_line.h File base/command_line.h (right): http://codereview.chromium.org/6526040/diff/39005/base/command_line.h#newcode159 base/command_line.h:159: StringType program_string_; Why do we track this separately when ...
9 years, 7 months ago (2011-05-13 16:45:04 UTC) #10
msw
Done. PTAL, thanks. http://codereview.chromium.org/6526040/diff/39005/base/command_line.h File base/command_line.h (right): http://codereview.chromium.org/6526040/diff/39005/base/command_line.h#newcode159 base/command_line.h:159: StringType program_string_; On 2011/05/13 16:45:05, Evan ...
9 years, 7 months ago (2011-05-13 18:54:49 UTC) #11
Evan Martin
LGTM thanks for doing this! http://codereview.chromium.org/6526040/diff/37005/base/command_line.h File base/command_line.h (right): http://codereview.chromium.org/6526040/diff/37005/base/command_line.h#newcode167 base/command_line.h:167: // The index after ...
9 years, 7 months ago (2011-05-13 19:09:41 UTC) #12
grt (UTC plus 2)
LGTM with some nits. Cheers, Greg http://codereview.chromium.org/6526040/diff/37005/base/command_line.cc File base/command_line.cc (right): http://codereview.chromium.org/6526040/diff/37005/base/command_line.cc#newcode58 base/command_line.cc:58: if(equals_position != CommandLine::StringType::npos) ...
9 years, 7 months ago (2011-05-13 19:16:14 UTC) #13
msw
9 years, 7 months ago (2011-05-13 20:28:02 UTC) #14
Done, will land after tests, and during quieter hours.

http://codereview.chromium.org/6526040/diff/37005/base/command_line.cc
File base/command_line.cc (right):

http://codereview.chromium.org/6526040/diff/37005/base/command_line.cc#newcode58
base/command_line.cc:58: if(equals_position != CommandLine::StringType::npos)
On 2011/05/13 19:16:14, grt wrote:
> style: add a space after "if"

Done.

http://codereview.chromium.org/6526040/diff/37005/base/command_line.cc#newcode73
base/command_line.cc:73: parse_switches &= arg != kSwitchTerminator;
On 2011/05/13 19:16:14, grt wrote:
> readability: parens around arg != kSwitchTerminator

Done.

http://codereview.chromium.org/6526040/diff/37005/base/command_line.cc#newcod...
base/command_line.cc:248: #if defined(OS_WIN)
On 2011/05/13 19:16:14, grt wrote:
> It seems like some of these conditional compilation blocks could be removed
> fairly easily.  How about defining a platform-specific helper func that takes
a
> std::string and returns an appropriate switch type?

Done, reincarnated Lowercase as LowerASCIIOnWindows.
Both string and wstring will eventually become string16, so I left those
preprocessor blocks alone for now.

http://codereview.chromium.org/6526040/diff/37005/base/command_line.cc#newcod...
base/command_line.cc:330: for (size_t i = 0; i < count; ++i)
On 2011/05/13 19:16:14, grt wrote:
> need braces here

Done.

http://codereview.chromium.org/6526040/diff/37005/base/command_line.cc#newcod...
base/command_line.cc:393: CHECK(args);
On 2011/05/13 19:16:14, grt wrote:
> Please use the following (or something similar) so that we get nice
diagnostics
> in logs:
> 
> PLOG_IF(FATAL, !args) << "CommandLineToArgvW failed on command line: " <<
> command_line;

Done.

http://codereview.chromium.org/6526040/diff/37005/base/command_line.h
File base/command_line.h (right):

http://codereview.chromium.org/6526040/diff/37005/base/command_line.h#newcode167
base/command_line.h:167: // The index after the program and switches, any
agruments start here.
On 2011/05/13 19:09:41, Evan Martin wrote:
> typo: arguments

Done.

Powered by Google App Engine
This is Rietveld 408576698