summaryrefslogtreecommitdiffstats
path: root/net/proxy
diff options
context:
space:
mode:
authorthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-03 01:05:39 +0000
committerthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-03 01:05:39 +0000
commit9bc8cff2f20eb98d86cfa77f5e75b5b3efc80ced (patch)
tree969fefb9d6c5d42d974fccd4d640861dc880a73d /net/proxy
parentd5c8101d795d43c265d81277305958d38160ab19 (diff)
downloadchromium_src-9bc8cff2f20eb98d86cfa77f5e75b5b3efc80ced.zip
chromium_src-9bc8cff2f20eb98d86cfa77f5e75b5b3efc80ced.tar.gz
chromium_src-9bc8cff2f20eb98d86cfa77f5e75b5b3efc80ced.tar.bz2
Move EnvironmentVariableGetter from base/linux_util.h to base/env_var.h and rename it EnvVarGetter. Label base::SysInfo::{Get,Has}EnvVar as deprecated.
BUG=none TEST=none Review URL: http://codereview.chromium.org/1606007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43559 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/proxy')
-rw-r--r--net/proxy/proxy_config_service_linux.cc32
-rw-r--r--net/proxy/proxy_config_service_linux.h15
-rw-r--r--net/proxy/proxy_config_service_linux_unittest.cc20
3 files changed, 31 insertions, 36 deletions
diff --git a/net/proxy/proxy_config_service_linux.cc b/net/proxy/proxy_config_service_linux.cc
index a43a7e8..163b39d 100644
--- a/net/proxy/proxy_config_service_linux.cc
+++ b/net/proxy/proxy_config_service_linux.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -13,8 +13,11 @@
#include <sys/inotify.h>
#include <unistd.h>
+#include <map>
+
#include "base/file_path.h"
#include "base/file_util.h"
+#include "base/linux_util.h"
#include "base/logging.h"
#include "base/message_loop.h"
#include "base/string_tokenizer.h"
@@ -78,7 +81,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_->GetEnv(variable, &env_value)) {
if (!env_value.empty()) {
env_value = FixupProxyHostScheme(scheme, env_value);
ProxyServer proxy_server =
@@ -106,7 +109,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_->GetEnv("auto_proxy", &auto_proxy)) {
if (auto_proxy.empty()) {
// Defined and empty => autodetect
config->set_auto_detect(true);
@@ -146,7 +149,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_->GetEnv("SOCKS_VERSION", &env_version)
&& env_version == "5")
scheme = ProxyServer::SCHEME_SOCKS5;
if (GetProxyFromEnvVarForScheme("SOCKS_SERVER", scheme, &proxy_server)) {
@@ -156,7 +159,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_->GetEnv("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
@@ -408,15 +411,14 @@ class GConfSettingGetterImplKDE
: public ProxyConfigServiceLinux::GConfSettingGetter,
public base::MessagePumpLibevent::Watcher {
public:
- explicit GConfSettingGetterImplKDE(
- base::EnvironmentVariableGetter* env_var_getter)
+ explicit GConfSettingGetterImplKDE(base::EnvVarGetter* env_var_getter)
: inotify_fd_(-1), notify_delegate_(NULL), indirect_manual_(false),
auto_no_pac_(false), reversed_exception_(false), file_loop_(NULL) {
// We don't save the env var getter for later use since we don't own it.
// Instead we use it here and save the result we actually care about.
std::string kde_home;
- if (!env_var_getter->Getenv("KDE_HOME", &kde_home)) {
- if (!env_var_getter->Getenv("HOME", &kde_home))
+ if (!env_var_getter->GetEnv("KDE_HOME", &kde_home)) {
+ if (!env_var_getter->GetEnv("HOME", &kde_home))
// User has no $HOME? Give up. Later we'll report the failure.
return;
kde_home = FilePath(kde_home).Append(FILE_PATH_LITERAL(".kde")).value();
@@ -961,8 +963,7 @@ bool ProxyConfigServiceLinux::Delegate::GetConfigFromGConf(
return true;
}
-ProxyConfigServiceLinux::Delegate::Delegate(
- base::EnvironmentVariableGetter* env_var_getter)
+ProxyConfigServiceLinux::Delegate::Delegate(base::EnvVarGetter* env_var_getter)
: env_var_getter_(env_var_getter),
glib_default_loop_(NULL), io_loop_(NULL) {
// Figure out which GConfSettingGetterImpl to use, if any.
@@ -980,8 +981,7 @@ ProxyConfigServiceLinux::Delegate::Delegate(
}
}
-ProxyConfigServiceLinux::Delegate::Delegate(
- base::EnvironmentVariableGetter* env_var_getter,
+ProxyConfigServiceLinux::Delegate::Delegate(base::EnvVarGetter* env_var_getter,
GConfSettingGetter* gconf_getter)
: env_var_getter_(env_var_getter), gconf_getter_(gconf_getter),
glib_default_loop_(NULL), io_loop_(NULL) {
@@ -1119,16 +1119,16 @@ void ProxyConfigServiceLinux::Delegate::OnDestroy() {
}
ProxyConfigServiceLinux::ProxyConfigServiceLinux()
- : delegate_(new Delegate(base::EnvironmentVariableGetter::Create())) {
+ : delegate_(new Delegate(base::EnvVarGetter::Create())) {
}
ProxyConfigServiceLinux::ProxyConfigServiceLinux(
- base::EnvironmentVariableGetter* env_var_getter)
+ base::EnvVarGetter* env_var_getter)
: delegate_(new Delegate(env_var_getter)) {
}
ProxyConfigServiceLinux::ProxyConfigServiceLinux(
- base::EnvironmentVariableGetter* env_var_getter,
+ base::EnvVarGetter* env_var_getter,
GConfSettingGetter* gconf_getter)
: delegate_(new Delegate(env_var_getter, gconf_getter)) {
}
diff --git a/net/proxy/proxy_config_service_linux.h b/net/proxy/proxy_config_service_linux.h
index a55ba35..904441d 100644
--- a/net/proxy/proxy_config_service_linux.h
+++ b/net/proxy/proxy_config_service_linux.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -9,7 +9,7 @@
#include <vector>
#include "base/basictypes.h"
-#include "base/linux_util.h"
+#include "base/env_var.h"
#include "base/message_loop.h"
#include "base/ref_counted.h"
#include "base/scoped_ptr.h"
@@ -105,10 +105,10 @@ class ProxyConfigServiceLinux : public ProxyConfigService {
public:
// Constructor receives env var getter implementation to use, and
// takes ownership of it. This is the normal constructor.
- explicit Delegate(base::EnvironmentVariableGetter* env_var_getter);
+ explicit Delegate(base::EnvVarGetter* env_var_getter);
// Constructor receives gconf and env var getter implementations
// to use, and takes ownership of them. Used for testing.
- Delegate(base::EnvironmentVariableGetter* env_var_getter,
+ Delegate(base::EnvVarGetter* env_var_getter,
GConfSettingGetter* gconf_getter);
// Synchronously obtains the proxy configuration. If gconf is
// used, also enables gconf notification for setting
@@ -168,7 +168,7 @@ class ProxyConfigServiceLinux : public ProxyConfigService {
// carry the new config information.
void SetNewProxyConfig(const ProxyConfig& new_config);
- scoped_ptr<base::EnvironmentVariableGetter> env_var_getter_;
+ scoped_ptr<base::EnvVarGetter> env_var_getter_;
scoped_ptr<GConfSettingGetter> gconf_getter_;
// Cached proxy configuration, to be returned by
@@ -203,9 +203,8 @@ class ProxyConfigServiceLinux : public ProxyConfigService {
// Usual constructor
ProxyConfigServiceLinux();
// For testing: take alternate gconf and env var getter implementations.
- explicit ProxyConfigServiceLinux(
- base::EnvironmentVariableGetter* env_var_getter);
- ProxyConfigServiceLinux(base::EnvironmentVariableGetter* env_var_getter,
+ explicit ProxyConfigServiceLinux(base::EnvVarGetter* env_var_getter);
+ ProxyConfigServiceLinux(base::EnvVarGetter* env_var_getter,
GConfSettingGetter* gconf_getter);
virtual ~ProxyConfigServiceLinux() {
diff --git a/net/proxy/proxy_config_service_linux_unittest.cc b/net/proxy/proxy_config_service_linux_unittest.cc
index 689b8b6..e6afb43 100644
--- a/net/proxy/proxy_config_service_linux_unittest.cc
+++ b/net/proxy/proxy_config_service_linux_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -77,9 +77,9 @@ struct SettingsTable {
map_type settings;
};
-class MockEnvironmentVariableGetter : public base::EnvironmentVariableGetter {
+class MockEnvVarGetter : public base::EnvVarGetter {
public:
- MockEnvironmentVariableGetter() {
+ MockEnvVarGetter() {
#define ENTRY(x) table.settings[#x] = &values.x
ENTRY(DESKTOP_SESSION);
ENTRY(KDE_HOME);
@@ -101,7 +101,7 @@ class MockEnvironmentVariableGetter : public base::EnvironmentVariableGetter {
values = zero_values;
}
- virtual bool Getenv(const char* variable_name, std::string* result) {
+ virtual bool GetEnv(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.
@@ -576,8 +576,7 @@ TEST_F(ProxyConfigServiceLinuxTest, BasicGConfTest) {
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) {
SCOPED_TRACE(StringPrintf("Test[%" PRIuS "] %s", i,
tests[i].description.c_str()));
- MockEnvironmentVariableGetter* env_getter =
- new MockEnvironmentVariableGetter;
+ MockEnvVarGetter* env_getter = new MockEnvVarGetter;
MockGConfSettingGetter* gconf_getter = new MockGConfSettingGetter;
SynchConfigGetter sync_config_getter(
new ProxyConfigServiceLinux(env_getter, gconf_getter));
@@ -844,8 +843,7 @@ TEST_F(ProxyConfigServiceLinuxTest, BasicEnvTest) {
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) {
SCOPED_TRACE(StringPrintf("Test[%" PRIuS "] %s", i,
tests[i].description.c_str()));
- MockEnvironmentVariableGetter* env_getter =
- new MockEnvironmentVariableGetter;
+ MockEnvVarGetter* env_getter = new MockEnvVarGetter;
MockGConfSettingGetter* gconf_getter = new MockGConfSettingGetter;
SynchConfigGetter sync_config_getter(
new ProxyConfigServiceLinux(env_getter, gconf_getter));
@@ -861,8 +859,7 @@ TEST_F(ProxyConfigServiceLinuxTest, BasicEnvTest) {
}
TEST_F(ProxyConfigServiceLinuxTest, GconfNotification) {
- MockEnvironmentVariableGetter* env_getter =
- new MockEnvironmentVariableGetter;
+ MockEnvVarGetter* env_getter = new MockEnvVarGetter;
MockGConfSettingGetter* gconf_getter = new MockGConfSettingGetter;
ProxyConfigServiceLinux* service =
new ProxyConfigServiceLinux(env_getter, gconf_getter);
@@ -1166,8 +1163,7 @@ TEST_F(ProxyConfigServiceLinuxTest, KDEConfigParser) {
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); ++i) {
SCOPED_TRACE(StringPrintf("Test[%" PRIuS "] %s", i,
tests[i].description.c_str()));
- MockEnvironmentVariableGetter* env_getter =
- new MockEnvironmentVariableGetter;
+ MockEnvVarGetter* env_getter = new MockEnvVarGetter;
// Force the KDE getter to be used and tell it where the test is.
env_getter->values.DESKTOP_SESSION = "kde4";
env_getter->values.KDE_HOME = kde_home_.value().c_str();