summaryrefslogtreecommitdiffstats
path: root/base/command_line.cc
diff options
context:
space:
mode:
authorerikwright@chromium.org <erikwright@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-27 18:38:12 +0000
committererikwright@chromium.org <erikwright@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-27 18:38:12 +0000
commit72e2e24228f7e9d94222ad3ebc4a103b2e513f15 (patch)
tree4715446c9a1efa3f222364a612fc4b5fd2940d9e /base/command_line.cc
parent077c19bf3598bb1f4091a0d9ad73ff543ce82bd6 (diff)
downloadchromium_src-72e2e24228f7e9d94222ad3ebc4a103b2e513f15.zip
chromium_src-72e2e24228f7e9d94222ad3ebc4a103b2e513f15.tar.gz
chromium_src-72e2e24228f7e9d94222ad3ebc4a103b2e513f15.tar.bz2
Allow callers of CommandLine::Init to know whether they were the first caller.
If there are multiple callers to Init, only one should call Reset. The boolean return value tells the caller whether they are the one responsible for the destruction. As long as the lifetimes of clients are strictly nested (i.e., a client X who uses CommandLine after client Y has initialized it always ceases its use before client Y destroys it) this secures access to this singleton object. One client in particular is updated to follow this model. I will submit follow-up CLs for remaining clients (at least, those who currently do call Reset). This is motivated by a crash in the chrome_frame_net_tests. This test executable nests a TestSuite within the lifetime of a ContentMainRunner (i.e., the engine that is typically used to run Chrome). The content layer initializes CommandLine and Resets it, but the TestSuite also resets it, leading to a DCHECK. This is currently the last remaining issue keeping the chrome_frame_net_tests off the waterfall, and I am very eager to get them back there to reduce the likelihood of further issues being introduced. BUG=114369 TEST=A test has been modified to reflect this change. Review URL: http://codereview.chromium.org/9477001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@123763 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/command_line.cc')
-rw-r--r--base/command_line.cc8
1 files changed, 5 insertions, 3 deletions
diff --git a/base/command_line.cc b/base/command_line.cc
index 0237ffe..983181f 100644
--- a/base/command_line.cc
+++ b/base/command_line.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -167,12 +167,12 @@ CommandLine::~CommandLine() {
}
// static
-void CommandLine::Init(int argc, const char* const* argv) {
+bool CommandLine::Init(int argc, const char* const* argv) {
if (current_process_commandline_) {
// If this is intentional, Reset() must be called first. If we are using
// the shared build mode, we have to share a single object across multiple
// shared libraries.
- return;
+ return false;
}
current_process_commandline_ = new CommandLine(NO_PROGRAM);
@@ -181,6 +181,8 @@ void CommandLine::Init(int argc, const char* const* argv) {
#elif defined(OS_POSIX)
current_process_commandline_->InitFromArgv(argc, argv);
#endif
+
+ return true;
}
// static