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

Side by Side Diff: base/command_line.h

Issue 3162047: FBTF: Move some heavy, repeatedly emitted symbols to implementation files. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: mac fixes Created 10 years, 3 months 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
« no previous file with comments | « app/gfx/gl/gl_implementation.cc ('k') | base/command_line.cc » ('j') | 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-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 class works with command lines: building and parsing. 5 // This class works with command lines: building and parsing.
6 // Switches can optionally have a value attached using an equals sign, 6 // Switches can optionally have a value attached using an equals sign,
7 // as in "-switch=value". Arguments that aren't prefixed with a 7 // as in "-switch=value". Arguments that aren't prefixed with a
8 // switch prefix are saved as extra arguments. An argument of "--" 8 // switch prefix are saved as extra arguments. An argument of "--"
9 // will terminate switch parsing, causing everything after to be 9 // will terminate switch parsing, causing everything after to be
10 // considered as extra arguments. 10 // considered as extra arguments.
11 11
12 // There is a singleton read-only CommandLine that represents the command 12 // There is a singleton read-only CommandLine that represents the command
13 // line that the current process was started with. It must be initialized 13 // line that the current process was started with. It must be initialized
14 // in main() (or whatever the platform's equivalent function is). 14 // in main() (or whatever the platform's equivalent function is).
15 15
16 #ifndef BASE_COMMAND_LINE_H_ 16 #ifndef BASE_COMMAND_LINE_H_
17 #define BASE_COMMAND_LINE_H_ 17 #define BASE_COMMAND_LINE_H_
18 #pragma once 18 #pragma once
19 19
20 #include "build/build_config.h" 20 #include "build/build_config.h"
21 21
22 #include <map> 22 #include <map>
23 #include <string> 23 #include <string>
24 #include <vector> 24 #include <vector>
25 25
26 #include "base/basictypes.h" 26 #include "base/basictypes.h"
27 #include "base/logging.h"
28 27
29 class FilePath; 28 class FilePath;
30 class InProcessBrowserTest; 29 class InProcessBrowserTest;
31 30
32 class CommandLine { 31 class CommandLine {
33 public: 32 public:
34 // A constructor for CommandLines that are used only to carry arguments. 33 // A constructor for CommandLines that are used only to carry arguments.
35 enum ArgumentsOnly { ARGUMENTS_ONLY }; 34 enum ArgumentsOnly { ARGUMENTS_ONLY };
36 explicit CommandLine(ArgumentsOnly args_only); 35 explicit CommandLine(ArgumentsOnly args_only);
37 ~CommandLine(); 36 ~CommandLine();
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 // Destroys the current process CommandLine singleton. This is necessary if 75 // Destroys the current process CommandLine singleton. This is necessary if
77 // you want to reset the base library to its initial state (for example in an 76 // you want to reset the base library to its initial state (for example in an
78 // outer library that needs to be able to terminate, and be re-initialized). 77 // outer library that needs to be able to terminate, and be re-initialized).
79 // If Init is called only once, e.g. in main(), calling Reset() is not 78 // If Init is called only once, e.g. in main(), calling Reset() is not
80 // necessary. 79 // necessary.
81 static void Reset(); 80 static void Reset();
82 81
83 // Get the singleton CommandLine representing the current process's 82 // Get the singleton CommandLine representing the current process's
84 // command line. Note: returned value is mutable, but not thread safe; 83 // command line. Note: returned value is mutable, but not thread safe;
85 // only mutate if you know what you're doing! 84 // only mutate if you know what you're doing!
86 static CommandLine* ForCurrentProcess() { 85 static CommandLine* ForCurrentProcess();
87 DCHECK(current_process_commandline_);
88 return current_process_commandline_;
89 }
90 86
91 // Returns true if this command line contains the given switch. 87 // Returns true if this command line contains the given switch.
92 // (Switch names are case-insensitive.) 88 // (Switch names are case-insensitive.)
93 bool HasSwitch(const std::string& switch_string) const; 89 bool HasSwitch(const std::string& switch_string) const;
94 90
95 // Returns the value associated with the given switch. If the 91 // Returns the value associated with the given switch. If the
96 // switch has no value or isn't present, this method returns 92 // switch has no value or isn't present, this method returns
97 // the empty string. 93 // the empty string.
98 std::string GetSwitchValueASCII(const std::string& switch_string) const; 94 std::string GetSwitchValueASCII(const std::string& switch_string) const;
99 FilePath GetSwitchValuePath(const std::string& switch_string) const; 95 FilePath GetSwitchValuePath(const std::string& switch_string) const;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 // Deprecated on non-Windows. 169 // Deprecated on non-Windows.
174 bool HasSwitch(const std::wstring& switch_string) const; 170 bool HasSwitch(const std::wstring& switch_string) const;
175 #endif 171 #endif
176 172
177 private: 173 private:
178 friend class InProcessBrowserTest; 174 friend class InProcessBrowserTest;
179 175
180 CommandLine(); 176 CommandLine();
181 177
182 // Used by InProcessBrowserTest. 178 // Used by InProcessBrowserTest.
183 static CommandLine* ForCurrentProcessMutable() { 179 static CommandLine* ForCurrentProcessMutable();
184 DCHECK(current_process_commandline_);
185 return current_process_commandline_;
186 }
187 180
188 // The singleton CommandLine instance representing the current process's 181 // The singleton CommandLine instance representing the current process's
189 // command line. 182 // command line.
190 static CommandLine* current_process_commandline_; 183 static CommandLine* current_process_commandline_;
191 184
192 // We store a platform-native version of the command line, used when building 185 // We store a platform-native version of the command line, used when building
193 // up a new command line to be executed. This ifdef delimits that code. 186 // up a new command line to be executed. This ifdef delimits that code.
194 187
195 #if defined(OS_WIN) 188 #if defined(OS_WIN)
196 // The quoted, space-separated command-line string. 189 // The quoted, space-separated command-line string.
(...skipping 18 matching lines...) Expand all
215 std::vector<StringType> args_; 208 std::vector<StringType> args_;
216 209
217 // We allow copy constructors, because a common pattern is to grab a 210 // We allow copy constructors, because a common pattern is to grab a
218 // copy of the current process's command line and then add some 211 // copy of the current process's command line and then add some
219 // flags to it. E.g.: 212 // flags to it. E.g.:
220 // CommandLine cl(*CommandLine::ForCurrentProcess()); 213 // CommandLine cl(*CommandLine::ForCurrentProcess());
221 // cl.AppendSwitch(...); 214 // cl.AppendSwitch(...);
222 }; 215 };
223 216
224 #endif // BASE_COMMAND_LINE_H_ 217 #endif // BASE_COMMAND_LINE_H_
OLDNEW
« no previous file with comments | « app/gfx/gl/gl_implementation.cc ('k') | base/command_line.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698