Skip to content

Commit

Permalink
base: rename Environment::HasEnv to Environment::HasVar.
Browse files Browse the repository at this point in the history
This is the part 2 of this series. More two comming. Splitting this
into small parts, so it is more easy to review and reduce the size of the CL.

BUG=None
TEST=trybots

Review URL: http://codereview.chromium.org/3035050

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@54996 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
tfarina@chromium.org committed Aug 4, 2010
1 parent 3a77e46 commit 9432ade
Show file tree
Hide file tree
Showing 13 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion base/environment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ Environment* Environment::Create() {
return new EnvironmentImpl();
}

bool Environment::HasEnv(const char* variable_name) {
bool Environment::HasVar(const char* variable_name) {
return GetEnv(variable_name, NULL);
}

Expand Down
2 changes: 1 addition & 1 deletion base/environment.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Environment {
virtual bool GetEnv(const char* variable_name, std::string* result) = 0;

// Syntactic sugar for GetEnv(variable_name, NULL);
virtual bool HasEnv(const char* variable_name);
virtual bool HasVar(const char* variable_name);

// Returns true on success, otherwise returns false.
virtual bool SetEnv(const char* variable_name,
Expand Down
10 changes: 5 additions & 5 deletions base/environment_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ TEST_F(EnvironmentTest, GetEnvVar) {
EXPECT_NE(env_value, "");
}

TEST_F(EnvironmentTest, HasEnvVar) {
TEST_F(EnvironmentTest, HasVar) {
// Every setup should have PATH...
scoped_ptr<base::Environment> env(base::Environment::Create());
EXPECT_TRUE(env->HasEnv("PATH"));
EXPECT_TRUE(env->HasVar("PATH"));
}

TEST_F(EnvironmentTest, SetEnvVar) {
Expand All @@ -31,7 +31,7 @@ TEST_F(EnvironmentTest, SetEnvVar) {
EXPECT_TRUE(env->SetEnv(kFooUpper, kFooLower));

// Now verify that the environment has the new variable.
EXPECT_TRUE(env->HasEnv(kFooUpper));
EXPECT_TRUE(env->HasVar(kFooUpper));

std::string var_value;
EXPECT_TRUE(env->GetEnv(kFooUpper, &var_value));
Expand All @@ -47,11 +47,11 @@ TEST_F(EnvironmentTest, UnSetVar) {
EXPECT_TRUE(env->SetEnv(kFooUpper, kFooLower));

// Now verify that the environment has the new variable.
EXPECT_TRUE(env->HasEnv(kFooUpper));
EXPECT_TRUE(env->HasVar(kFooUpper));

// Finally verify that the environment variable was erased.
EXPECT_TRUE(env->UnSetVar(kFooUpper));

// And check that the variable has been unset.
EXPECT_FALSE(env->HasEnv(kFooUpper));
EXPECT_FALSE(env->HasVar(kFooUpper));
}
2 changes: 1 addition & 1 deletion base/nss_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ void UseLocalCacheOfNSSDatabaseIfNFS(const FilePath& database_dir) {
if (buf.f_type == NFS_SUPER_MAGIC) {
scoped_ptr<base::Environment> env(base::Environment::Create());
const char* use_cache_env_var = "NSS_SDB_USE_CACHE";
if (!env->HasEnv(use_cache_env_var))
if (!env->HasVar(use_cache_env_var))
env->SetEnv(use_cache_env_var, "yes");
}
}
Expand Down
8 changes: 4 additions & 4 deletions base/xdg_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ DesktopEnvironment GetDesktopEnvironment(Environment* env) {
return DESKTOP_ENVIRONMENT_KDE4;
} else if (desktop_session == "kde") {
// This may mean KDE4 on newer systems, so we have to check.
if (env->HasEnv("KDE_SESSION_VERSION"))
if (env->HasVar("KDE_SESSION_VERSION"))
return DESKTOP_ENVIRONMENT_KDE4;
return DESKTOP_ENVIRONMENT_KDE3;
} else if (desktop_session.find("xfce") != std::string::npos) {
Expand All @@ -49,10 +49,10 @@ DesktopEnvironment GetDesktopEnvironment(Environment* env) {

// Fall back on some older environment variables.
// Useful particularly in the DESKTOP_SESSION=default case.
if (env->HasEnv("GNOME_DESKTOP_SESSION_ID")) {
if (env->HasVar("GNOME_DESKTOP_SESSION_ID")) {
return DESKTOP_ENVIRONMENT_GNOME;
} else if (env->HasEnv("KDE_FULL_SESSION")) {
if (env->HasEnv("KDE_SESSION_VERSION"))
} else if (env->HasVar("KDE_FULL_SESSION")) {
if (env->HasVar("KDE_SESSION_VERSION"))
return DESKTOP_ENVIRONMENT_KDE4;
return DESKTOP_ENVIRONMENT_KDE3;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ static const int kStreamId = 50;

static bool IsRunningHeadless() {
scoped_ptr<base::Environment> env(base::Environment::Create());
if (env->HasEnv("CHROME_HEADLESS"))
if (env->HasVar("CHROME_HEADLESS"))
return true;
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/safe_browsing/protocol_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ bool SafeBrowsingProtocolManager::HandleServiceResponse(const GURL& url,
void SafeBrowsingProtocolManager::Initialize() {
// Don't want to hit the safe browsing servers on build/chrome bots.
scoped_ptr<base::Environment> env(base::Environment::Create());
if (env->HasEnv(env_vars::kHeadless))
if (env->HasVar(env_vars::kHeadless))
return;

ScheduleNextUpdate(false /* no back off */);
Expand Down
4 changes: 2 additions & 2 deletions chrome/common/logging_chrome.cc
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ void InitChromeLogging(const CommandLine& command_line,
// Variable or by the Command Line Switch. This is for
// automated test purposes.
scoped_ptr<base::Environment> env(base::Environment::Create());
if (env->HasEnv(env_vars::kHeadless) ||
if (env->HasVar(env_vars::kHeadless) ||
command_line.HasSwitch(switches::kNoErrorDialogs))
SuppressDialogs();

Expand All @@ -227,7 +227,7 @@ void InitChromeLogging(const CommandLine& command_line,

#if defined(OS_WIN)
// Enable trace control and transport through event tracing for Windows.
if (env->HasEnv(env_vars::kEtwLogging))
if (env->HasVar(env_vars::kEtwLogging))
logging::LogEventProvider::Initialize(kChromeTraceProviderName);
#endif

Expand Down
2 changes: 1 addition & 1 deletion chrome/common/process_watcher_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class TimerExpiredTask : public Task, public base::ObjectWatcher::Delegate {
private:
void KillProcess() {
scoped_ptr<base::Environment> env(base::Environment::Create());
if (env->HasEnv(env_vars::kHeadless)) {
if (env->HasVar(env_vars::kHeadless)) {
// If running the distributed tests, give the renderer a little time
// to figure out that the channel is shutdown and unwind.
if (WaitForSingleObject(process_, kWaitInterval) == WAIT_OBJECT_0) {
Expand Down
2 changes: 1 addition & 1 deletion chrome/test/automated_ui_tests/automated_ui_tests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ AutomatedUITest::AutomatedUITest()
}
}
scoped_ptr<base::Environment> env(base::Environment::Create());
if (env->HasEnv(env_vars::kHeadless))
if (env->HasVar(env_vars::kHeadless))
logging::SetLogReportHandler(SilentRuntimeReportHandler);
}

Expand Down
2 changes: 1 addition & 1 deletion chrome/test/ui/ui_test_suite.cc
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ void UITestSuite::SuppressErrorDialogs() {
#if defined(OS_WIN)
void UITestSuite::LoadCrashService() {
scoped_ptr<base::Environment> env(base::Environment::Create());
if (env->HasEnv(env_vars::kHeadless))
if (env->HasVar(env_vars::kHeadless))
return;

if (base::GetProcessCount(L"crash_service.exe", NULL))
Expand Down
2 changes: 1 addition & 1 deletion media/audio/audio_output_controller_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ static bool HasAudioOutputDevices() {

static bool IsRunningHeadless() {
scoped_ptr<base::Environment> env(base::Environment::Create());
if (env->HasEnv("CHROME_HEADLESS"))
if (env->HasVar("CHROME_HEADLESS"))
return true;
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion webkit/tools/test_shell/test_shell_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ int main(int argc, char* argv[]) {

scoped_ptr<base::Environment> env(base::Environment::Create());
bool suppress_error_dialogs = (
env->HasEnv("CHROME_HEADLESS") ||
env->HasVar("CHROME_HEADLESS") ||
parsed_command_line.HasSwitch(test_shell::kNoErrorDialogs) ||
parsed_command_line.HasSwitch(test_shell::kLayoutTests));
bool layout_test_mode =
Expand Down

0 comments on commit 9432ade

Please sign in to comment.