diff options
author | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-07 02:57:59 +0000 |
---|---|---|
committer | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-07 02:57:59 +0000 |
commit | 3ba7e0887015ba6a59579c4de08a6d609f851c23 (patch) | |
tree | d4b3ab95c9fa344346e2a1d3357916771587dcd1 | |
parent | 3eac24a2b4c9438196899e62ac2f3ae5f03ba039 (diff) | |
download | chromium_src-3ba7e0887015ba6a59579c4de08a6d609f851c23.zip chromium_src-3ba7e0887015ba6a59579c4de08a6d609f851c23.tar.gz chromium_src-3ba7e0887015ba6a59579c4de08a6d609f851c23.tar.bz2 |
base: rename Environment::GetEnv to Environment::GetVar.
This is the part 4 and the latest of this series.
BUG=None
TEST=trybots
Review URL: http://codereview.chromium.org/3029062
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@55326 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | base/base_paths_posix.cc | 2 | ||||
-rw-r--r-- | base/environment.cc | 10 | ||||
-rw-r--r-- | base/environment.h | 4 | ||||
-rw-r--r-- | base/environment_unittest.cc | 6 | ||||
-rw-r--r-- | base/xdg_util.cc | 4 | ||||
-rw-r--r-- | base/xdg_util_unittest.cc | 18 | ||||
-rw-r--r-- | chrome/browser/browser_init.cc | 2 | ||||
-rw-r--r-- | chrome/browser/shell_integration_linux.cc | 6 | ||||
-rw-r--r-- | chrome/browser/shell_integration_unittest.cc | 2 | ||||
-rw-r--r-- | chrome/browser/zygote_host_linux.cc | 2 | ||||
-rw-r--r-- | chrome/common/logging_chrome.cc | 2 | ||||
-rw-r--r-- | chrome/common/logging_chrome_uitest.cc | 2 | ||||
-rw-r--r-- | chrome/plugin/plugin_main_mac.mm | 2 | ||||
-rw-r--r-- | chrome/test/startup/shutdown_test.cc | 2 | ||||
-rw-r--r-- | chrome/test/startup/startup_test.cc | 2 | ||||
-rw-r--r-- | courgette/encoded_program.cc | 2 | ||||
-rw-r--r-- | net/proxy/proxy_config_service_linux.cc | 16 | ||||
-rw-r--r-- | net/proxy/proxy_config_service_linux_unittest.cc | 2 |
18 files changed, 43 insertions, 43 deletions
diff --git a/base/base_paths_posix.cc b/base/base_paths_posix.cc index 8412009..45b397e 100644 --- a/base/base_paths_posix.cc +++ b/base/base_paths_posix.cc @@ -63,7 +63,7 @@ bool PathProviderPosix(int key, FilePath* result) { // tree configurations (sub-project builds, gyp --output_dir, etc.) scoped_ptr<base::Environment> env(base::Environment::Create()); std::string cr_source_root; - if (env->GetEnv("CR_SOURCE_ROOT", &cr_source_root)) { + if (env->GetVar("CR_SOURCE_ROOT", &cr_source_root)) { path = FilePath(cr_source_root); if (file_util::PathExists(path.Append("base/base_paths_posix.cc"))) { *result = path; diff --git a/base/environment.cc b/base/environment.cc index 6a6b556..2f2431e 100644 --- a/base/environment.cc +++ b/base/environment.cc @@ -21,8 +21,8 @@ namespace { class EnvironmentImpl : public base::Environment { public: - virtual bool GetEnv(const char* variable_name, std::string* result) { - if (GetEnvImpl(variable_name, result)) + virtual bool GetVar(const char* variable_name, std::string* result) { + if (GetVarImpl(variable_name, result)) return true; // Some commonly used variable names are uppercase while others @@ -37,7 +37,7 @@ class EnvironmentImpl : public base::Environment { alternate_case_var = StringToLowerASCII(std::string(variable_name)); else return false; - return GetEnvImpl(alternate_case_var.c_str(), result); + return GetVarImpl(alternate_case_var.c_str(), result); } virtual bool SetVar(const char* variable_name, const std::string& new_value) { @@ -49,7 +49,7 @@ class EnvironmentImpl : public base::Environment { } private: - bool GetEnvImpl(const char* variable_name, std::string* result) { + bool GetVarImpl(const char* variable_name, std::string* result) { #if defined(OS_POSIX) const char* env_value = getenv(variable_name); if (!env_value) @@ -120,7 +120,7 @@ Environment* Environment::Create() { } bool Environment::HasVar(const char* variable_name) { - return GetEnv(variable_name, NULL); + return GetVar(variable_name, NULL); } } // namespace base diff --git a/base/environment.h b/base/environment.h index ac83de3..4c0691b 100644 --- a/base/environment.h +++ b/base/environment.h @@ -30,9 +30,9 @@ class Environment { // Gets an environment variable's value and stores it in |result|. // Returns false if the key is unset. - virtual bool GetEnv(const char* variable_name, std::string* result) = 0; + virtual bool GetVar(const char* variable_name, std::string* result) = 0; - // Syntactic sugar for GetEnv(variable_name, NULL); + // Syntactic sugar for GetVar(variable_name, NULL); virtual bool HasVar(const char* variable_name); // Returns true on success, otherwise returns false. diff --git a/base/environment_unittest.cc b/base/environment_unittest.cc index ba48123..3d7ab3c 100644 --- a/base/environment_unittest.cc +++ b/base/environment_unittest.cc @@ -9,11 +9,11 @@ typedef PlatformTest EnvironmentTest; -TEST_F(EnvironmentTest, GetEnvVar) { +TEST_F(EnvironmentTest, GetVar) { // Every setup should have non-empty PATH... scoped_ptr<base::Environment> env(base::Environment::Create()); std::string env_value; - EXPECT_TRUE(env->GetEnv("PATH", &env_value)); + EXPECT_TRUE(env->GetVar("PATH", &env_value)); EXPECT_NE(env_value, ""); } @@ -34,7 +34,7 @@ TEST_F(EnvironmentTest, SetVar) { EXPECT_TRUE(env->HasVar(kFooUpper)); std::string var_value; - EXPECT_TRUE(env->GetEnv(kFooUpper, &var_value)); + EXPECT_TRUE(env->GetVar(kFooUpper, &var_value)); EXPECT_EQ(var_value, kFooLower); } diff --git a/base/xdg_util.cc b/base/xdg_util.cc index 6978986..017ae7a 100644 --- a/base/xdg_util.cc +++ b/base/xdg_util.cc @@ -14,7 +14,7 @@ namespace base { FilePath GetXDGDirectory(Environment* env, const char* env_name, const char* fallback_dir) { std::string env_value; - if (env->GetEnv(env_name, &env_value) && !env_value.empty()) + if (env->GetVar(env_name, &env_value) && !env_value.empty()) return FilePath(env_value); return file_util::GetHomeDir().Append(fallback_dir); } @@ -32,7 +32,7 @@ FilePath GetXDGUserDirectory(Environment* env, const char* dir_name, DesktopEnvironment GetDesktopEnvironment(Environment* env) { std::string desktop_session; - if (env->GetEnv("DESKTOP_SESSION", &desktop_session)) { + if (env->GetVar("DESKTOP_SESSION", &desktop_session)) { if (desktop_session == "gnome") { return DESKTOP_ENVIRONMENT_GNOME; } else if (desktop_session == "kde4") { diff --git a/base/xdg_util_unittest.cc b/base/xdg_util_unittest.cc index 09f65c4..c33fca5 100644 --- a/base/xdg_util_unittest.cc +++ b/base/xdg_util_unittest.cc @@ -17,7 +17,7 @@ namespace { class MockEnvironment : public base::Environment { public: - MOCK_METHOD2(GetEnv, bool(const char*, std::string* result)); + MOCK_METHOD2(GetVar, bool(const char*, std::string* result)); MOCK_METHOD2(SetVar, bool(const char*, const std::string& new_value)); MOCK_METHOD1(UnSetVar, bool(const char*)); }; @@ -31,8 +31,8 @@ const char* kXFCE = "xfce"; TEST(XDGUtilTest, GetDesktopEnvironmentGnome) { MockEnvironment getter; - EXPECT_CALL(getter, GetEnv(_, _)).WillRepeatedly(Return(false)); - EXPECT_CALL(getter, GetEnv(StrEq("DESKTOP_SESSION"), _)) + EXPECT_CALL(getter, GetVar(_, _)).WillRepeatedly(Return(false)); + EXPECT_CALL(getter, GetVar(StrEq("DESKTOP_SESSION"), _)) .WillOnce(DoAll(SetArgumentPointee<1>(kGnome), Return(true))); EXPECT_EQ(base::DESKTOP_ENVIRONMENT_GNOME, @@ -41,8 +41,8 @@ TEST(XDGUtilTest, GetDesktopEnvironmentGnome) { TEST(XDGUtilTest, GetDesktopEnvironmentKDE4) { MockEnvironment getter; - EXPECT_CALL(getter, GetEnv(_, _)).WillRepeatedly(Return(false)); - EXPECT_CALL(getter, GetEnv(StrEq("DESKTOP_SESSION"), _)) + EXPECT_CALL(getter, GetVar(_, _)).WillRepeatedly(Return(false)); + EXPECT_CALL(getter, GetVar(StrEq("DESKTOP_SESSION"), _)) .WillOnce(DoAll(SetArgumentPointee<1>(kKDE4), Return(true))); EXPECT_EQ(base::DESKTOP_ENVIRONMENT_KDE4, @@ -51,8 +51,8 @@ TEST(XDGUtilTest, GetDesktopEnvironmentKDE4) { TEST(XDGUtilTest, GetDesktopEnvironmentKDE3) { MockEnvironment getter; - EXPECT_CALL(getter, GetEnv(_, _)).WillRepeatedly(Return(false)); - EXPECT_CALL(getter, GetEnv(StrEq("DESKTOP_SESSION"), _)) + EXPECT_CALL(getter, GetVar(_, _)).WillRepeatedly(Return(false)); + EXPECT_CALL(getter, GetVar(StrEq("DESKTOP_SESSION"), _)) .WillOnce(DoAll(SetArgumentPointee<1>(kKDE), Return(true))); EXPECT_EQ(base::DESKTOP_ENVIRONMENT_KDE3, @@ -61,8 +61,8 @@ TEST(XDGUtilTest, GetDesktopEnvironmentKDE3) { TEST(XDGUtilTest, GetDesktopEnvironmentXFCE) { MockEnvironment getter; - EXPECT_CALL(getter, GetEnv(_, _)).WillRepeatedly(Return(false)); - EXPECT_CALL(getter, GetEnv(StrEq("DESKTOP_SESSION"), _)) + EXPECT_CALL(getter, GetVar(_, _)).WillRepeatedly(Return(false)); + EXPECT_CALL(getter, GetVar(StrEq("DESKTOP_SESSION"), _)) .WillOnce(DoAll(SetArgumentPointee<1>(kXFCE), Return(true))); EXPECT_EQ(base::DESKTOP_ENVIRONMENT_XFCE, diff --git a/chrome/browser/browser_init.cc b/chrome/browser/browser_init.cc index dd79815..ca72ccf 100644 --- a/chrome/browser/browser_init.cc +++ b/chrome/browser/browser_init.cc @@ -316,7 +316,7 @@ LaunchMode GetLaunchShortcutKind() { return LM_SHORTCUT_QUICKLAUNCH; scoped_ptr<base::Environment> env(base::Environment::Create()); std::string appdata_path; - env->GetEnv("USERPROFILE", &appdata_path); + env->GetVar("USERPROFILE", &appdata_path); if (!appdata_path.empty() && shortcut.find(ASCIIToWide(appdata_path)) != std::wstring::npos) return LM_SHORTCUT_DESKTOP; diff --git a/chrome/browser/shell_integration_linux.cc b/chrome/browser/shell_integration_linux.cc index 27b5a9b..7c0d4cc 100644 --- a/chrome/browser/shell_integration_linux.cc +++ b/chrome/browser/shell_integration_linux.cc @@ -49,7 +49,7 @@ std::string GetDesktopName(base::Environment* env) { // versions can set themselves as the default without interfering with // non-official, packaged versions using the built-in value. std::string name; - if (env->GetEnv("CHROME_DESKTOP", &name) && !name.empty()) + if (env->GetVar("CHROME_DESKTOP", &name) && !name.empty()) return name; return "chromium-browser.desktop"; #endif @@ -254,13 +254,13 @@ bool ShellIntegration::GetDesktopShortcutTemplate( std::vector<FilePath> search_paths; std::string xdg_data_home; - if (env->GetEnv("XDG_DATA_HOME", &xdg_data_home) && + if (env->GetVar("XDG_DATA_HOME", &xdg_data_home) && !xdg_data_home.empty()) { search_paths.push_back(FilePath(xdg_data_home)); } std::string xdg_data_dirs; - if (env->GetEnv("XDG_DATA_DIRS", &xdg_data_dirs) && + if (env->GetVar("XDG_DATA_DIRS", &xdg_data_dirs) && !xdg_data_dirs.empty()) { StringTokenizer tokenizer(xdg_data_dirs, ":"); while (tokenizer.GetNext()) { diff --git a/chrome/browser/shell_integration_unittest.cc b/chrome/browser/shell_integration_unittest.cc index 28f02c6..9ea7021 100644 --- a/chrome/browser/shell_integration_unittest.cc +++ b/chrome/browser/shell_integration_unittest.cc @@ -39,7 +39,7 @@ class MockEnvironment : public base::Environment { variables_[name] = value; } - virtual bool GetEnv(const char* variable_name, std::string* result) { + virtual bool GetVar(const char* variable_name, std::string* result) { if (ContainsKey(variables_, variable_name)) { *result = variables_[variable_name]; return true; diff --git a/chrome/browser/zygote_host_linux.cc b/chrome/browser/zygote_host_linux.cc index 0d57b55..f01bcf1 100644 --- a/chrome/browser/zygote_host_linux.cc +++ b/chrome/browser/zygote_host_linux.cc @@ -43,7 +43,7 @@ static void SaveSUIDUnsafeEnvironmentVariables() { scoped_ptr<base::Environment> env(base::Environment::Create()); std::string value; - if (env->GetEnv(envvar, &value)) + if (env->GetVar(envvar, &value)) env->SetVar(saved_envvar, value); else env->UnSetVar(saved_envvar); diff --git a/chrome/common/logging_chrome.cc b/chrome/common/logging_chrome.cc index 10795caf..f546e35 100644 --- a/chrome/common/logging_chrome.cc +++ b/chrome/common/logging_chrome.cc @@ -249,7 +249,7 @@ void CleanupChromeLogging() { FilePath GetLogFileName() { std::string filename; scoped_ptr<base::Environment> env(base::Environment::Create()); - if (env->GetEnv(env_vars::kLogFileName, &filename) && !filename.empty()) { + if (env->GetVar(env_vars::kLogFileName, &filename) && !filename.empty()) { #if defined(OS_WIN) return FilePath(UTF8ToWide(filename).c_str()); #elif defined(OS_POSIX) diff --git a/chrome/common/logging_chrome_uitest.cc b/chrome/common/logging_chrome_uitest.cc index a8c39c0..328a5a49 100644 --- a/chrome/common/logging_chrome_uitest.cc +++ b/chrome/common/logging_chrome_uitest.cc @@ -26,7 +26,7 @@ class ChromeLoggingTest : public testing::Test { // variable and sets the variable to new_value. void SaveEnvironmentVariable(std::string new_value) { scoped_ptr<base::Environment> env(base::Environment::Create()); - if (!env->GetEnv(env_vars::kLogFileName, &environment_filename_)) + if (!env->GetVar(env_vars::kLogFileName, &environment_filename_)) environment_filename_ = ""; env->SetVar(env_vars::kLogFileName, new_value); diff --git a/chrome/plugin/plugin_main_mac.mm b/chrome/plugin/plugin_main_mac.mm index 47957ba..2bde557 100644 --- a/chrome/plugin/plugin_main_mac.mm +++ b/chrome/plugin/plugin_main_mac.mm @@ -14,7 +14,7 @@ void TrimInterposeEnvironment() { scoped_ptr<base::Environment> env(base::Environment::Create()); std::string interpose_list; - if (!env->GetEnv(plugin_interpose_strings::kDYLDInsertLibrariesKey, + if (!env->GetVar(plugin_interpose_strings::kDYLDInsertLibrariesKey, &interpose_list)) { NOTREACHED() << "No interposing libraries set"; return; diff --git a/chrome/test/startup/shutdown_test.cc b/chrome/test/startup/shutdown_test.cc index db4422e..a7a0722 100644 --- a/chrome/test/startup/shutdown_test.cc +++ b/chrome/test/startup/shutdown_test.cc @@ -72,7 +72,7 @@ class ShutdownTest : public UITest { int numCycles = kNumCyclesMax; scoped_ptr<base::Environment> env(base::Environment::Create()); std::string numCyclesEnv; - if (env->GetEnv(env_vars::kStartupTestsNumCycles, &numCyclesEnv) && + if (env->GetVar(env_vars::kStartupTestsNumCycles, &numCyclesEnv) && base::StringToInt(numCyclesEnv, &numCycles)) { if (numCycles <= kNumCyclesMax) { LOG(INFO) << env_vars::kStartupTestsNumCycles diff --git a/chrome/test/startup/startup_test.cc b/chrome/test/startup/startup_test.cc index f6b0479..e33e113 100644 --- a/chrome/test/startup/startup_test.cc +++ b/chrome/test/startup/startup_test.cc @@ -109,7 +109,7 @@ class StartupTest : public UITest { int numCycles = kNumCyclesMax; scoped_ptr<base::Environment> env(base::Environment::Create()); std::string numCyclesEnv; - if (env->GetEnv(env_vars::kStartupTestsNumCycles, &numCyclesEnv) && + if (env->GetVar(env_vars::kStartupTestsNumCycles, &numCyclesEnv) && base::StringToInt(numCyclesEnv, &numCycles)) { if (numCycles <= kNumCyclesMax) { LOG(INFO) << env_vars::kStartupTestsNumCycles diff --git a/courgette/encoded_program.cc b/courgette/encoded_program.cc index eb3dcda..56290c77 100644 --- a/courgette/encoded_program.cc +++ b/courgette/encoded_program.cc @@ -268,7 +268,7 @@ static FieldSelect GetFieldSelect() { // TODO(sra): Use better configuration. scoped_ptr<base::Environment> env(base::Environment::Create()); std::string s; - env->GetEnv("A_FIELDS", &s); + env->GetVar("A_FIELDS", &s); if (!s.empty()) { return static_cast<FieldSelect>(wcstoul(ASCIIToWide(s).c_str(), 0, 0)); } diff --git a/net/proxy/proxy_config_service_linux.cc b/net/proxy/proxy_config_service_linux.cc index b001c11..a3b01b7 100644 --- a/net/proxy/proxy_config_service_linux.cc +++ b/net/proxy/proxy_config_service_linux.cc @@ -83,7 +83,7 @@ bool ProxyConfigServiceLinux::Delegate::GetProxyFromEnvVarForScheme( const char* variable, ProxyServer::Scheme scheme, ProxyServer* result_server) { std::string env_value; - if (env_var_getter_->GetEnv(variable, &env_value)) { + if (env_var_getter_->GetVar(variable, &env_value)) { if (!env_value.empty()) { env_value = FixupProxyHostScheme(scheme, env_value); ProxyServer proxy_server = @@ -111,7 +111,7 @@ bool ProxyConfigServiceLinux::Delegate::GetConfigFromEnv(ProxyConfig* config) { // extension has ever used this, but it still sounds like a good // idea. std::string auto_proxy; - if (env_var_getter_->GetEnv("auto_proxy", &auto_proxy)) { + if (env_var_getter_->GetVar("auto_proxy", &auto_proxy)) { if (auto_proxy.empty()) { // Defined and empty => autodetect config->set_auto_detect(true); @@ -151,7 +151,7 @@ bool ProxyConfigServiceLinux::Delegate::GetConfigFromEnv(ProxyConfig* config) { // If the above were not defined, try for socks. ProxyServer::Scheme scheme = ProxyServer::SCHEME_SOCKS4; std::string env_version; - if (env_var_getter_->GetEnv("SOCKS_VERSION", &env_version) + if (env_var_getter_->GetVar("SOCKS_VERSION", &env_version) && env_version == "5") scheme = ProxyServer::SCHEME_SOCKS5; if (GetProxyFromEnvVarForScheme("SOCKS_SERVER", scheme, &proxy_server)) { @@ -161,7 +161,7 @@ bool ProxyConfigServiceLinux::Delegate::GetConfigFromEnv(ProxyConfig* config) { } // Look for the proxy bypass list. std::string no_proxy; - env_var_getter_->GetEnv("no_proxy", &no_proxy); + env_var_getter_->GetVar("no_proxy", &no_proxy); if (config->proxy_rules().empty()) { // Having only "no_proxy" set, presumably to "*", makes it // explicit that env vars do specify a configuration: having no @@ -428,13 +428,13 @@ class GConfSettingGetterImplKDE env_var_getter_(env_var_getter), file_loop_(NULL) { // Derive the location of the kde config dir from the environment. std::string home; - if (env_var_getter->GetEnv("KDEHOME", &home) && !home.empty()) { + if (env_var_getter->GetVar("KDEHOME", &home) && !home.empty()) { // $KDEHOME is set. Use it unconditionally. kde_config_dir_ = KDEHomeToConfigPath(FilePath(home)); } else { // $KDEHOME is unset. Try to figure out what to use. This seems to be // the common case on most distributions. - if (!env_var_getter->GetEnv(base::env_vars::kHome, &home)) + if (!env_var_getter->GetVar(base::env_vars::kHome, &home)) // User has no $HOME? Give up. Later we'll report the failure. return; if (base::GetDesktopEnvironment(env_var_getter) == @@ -688,7 +688,7 @@ class GConfSettingGetterImplKDE string_map_type::iterator it = string_table_.find(key); if (it != string_table_.end()) { std::string value; - if (env_var_getter_->GetEnv(it->second.c_str(), &value)) + if (env_var_getter_->GetVar(it->second.c_str(), &value)) it->second = value; else string_table_.erase(it); @@ -700,7 +700,7 @@ class GConfSettingGetterImplKDE if (it != strings_table_.end()) { std::string value; if (!it->second.empty() && - env_var_getter_->GetEnv(it->second[0].c_str(), &value)) + env_var_getter_->GetVar(it->second[0].c_str(), &value)) AddHostList(key, value); else strings_table_.erase(it); diff --git a/net/proxy/proxy_config_service_linux_unittest.cc b/net/proxy/proxy_config_service_linux_unittest.cc index 74eddc8..0a541c1 100644 --- a/net/proxy/proxy_config_service_linux_unittest.cc +++ b/net/proxy/proxy_config_service_linux_unittest.cc @@ -105,7 +105,7 @@ class MockEnvironment : public base::Environment { } // Begin base::Environment implementation. - virtual bool GetEnv(const char* variable_name, std::string* result) { + virtual bool GetVar(const char* variable_name, std::string* result) { const char* env_value = table.Get(variable_name); if (env_value) { // Note that the variable may be defined but empty. |