summaryrefslogtreecommitdiffstats
path: root/base/linux_util.h
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 /base/linux_util.h
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 'base/linux_util.h')
-rw-r--r--base/linux_util.h35
1 files changed, 12 insertions, 23 deletions
diff --git a/base/linux_util.h b/base/linux_util.h
index 2139746..370a65e 100644
--- a/base/linux_util.h
+++ b/base/linux_util.h
@@ -1,15 +1,16 @@
-// 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.
-#ifndef BASE_LINUX_UTIL_H__
-#define BASE_LINUX_UTIL_H__
+#ifndef BASE_LINUX_UTIL_H_
+#define BASE_LINUX_UTIL_H_
#include <stdint.h>
#include <sys/types.h>
#include <string>
+class EnvVarGetter;
class FilePath;
namespace base {
@@ -25,34 +26,22 @@ uint8_t* BGRAToRGBA(const uint8_t* pixels, int width, int height, int stride);
// GetWinVersion() in base/win_util.h.
std::string GetLinuxDistro();
-// These are used to derive mocks for unittests.
-class EnvironmentVariableGetter {
- public:
- virtual ~EnvironmentVariableGetter() {}
- // 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;
-
- // Create an instance of EnvironmentVariableGetter
- static EnvironmentVariableGetter* Create();
-};
-
// Get the home directory.
-FilePath GetHomeDir(EnvironmentVariableGetter* env);
+FilePath GetHomeDir(EnvVarGetter* env);
// Utility function for getting XDG directories.
// |env_name| is the name of an environment variable that we want to use to get
// a directory path. |fallback_dir| is the directory relative to $HOME that we
// use if |env_name| cannot be found or is empty. |fallback_dir| may be NULL.
// Examples of |env_name| are XDG_CONFIG_HOME and XDG_DATA_HOME.
-FilePath GetXDGDirectory(EnvironmentVariableGetter* env,
- const char* env_name, const char* fallback_dir);
+FilePath GetXDGDirectory(EnvVarGetter* env, const char* env_name,
+ const char* fallback_dir);
// Wrapper around xdg_user_dir_lookup() from src/base/third_party/xdg-user-dirs
// This looks up "well known" user directories like the desktop and music
// folder. Examples of |dir_name| are DESKTOP and MUSIC.
-FilePath GetXDGUserDirectory(EnvironmentVariableGetter* env,
- const char* dir_name, const char* fallback_dir);
+FilePath GetXDGUserDirectory(EnvVarGetter* env, const char* dir_name,
+ const char* fallback_dir);
enum DesktopEnvironment {
DESKTOP_ENVIRONMENT_OTHER,
@@ -68,13 +57,13 @@ enum DesktopEnvironment {
// of which desktop environment we're using. We use this to know when
// to attempt to use preferences from the desktop environment --
// proxy settings, password manager, etc.
-DesktopEnvironment GetDesktopEnvironment(EnvironmentVariableGetter* env);
+DesktopEnvironment GetDesktopEnvironment(EnvVarGetter* env);
// Return a string representation of the given desktop environment.
// May return NULL in the case of DESKTOP_ENVIRONMENT_OTHER.
const char* GetDesktopEnvironmentName(DesktopEnvironment env);
// Convenience wrapper that calls GetDesktopEnvironment() first.
-const char* GetDesktopEnvironmentName(EnvironmentVariableGetter* env);
+const char* GetDesktopEnvironmentName(EnvVarGetter* env);
// Return the inode number for the UNIX domain socket |fd|.
bool FileDescriptorGetInode(ino_t* inode_out, int fd);
@@ -85,4 +74,4 @@ bool FindProcessHoldingSocket(pid_t* pid_out, ino_t socket_inode);
} // namespace base
-#endif // BASE_LINUX_UTIL_H__
+#endif // BASE_LINUX_UTIL_H_