summaryrefslogtreecommitdiffstats
path: root/base/linux_util.h
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2010-07-29 17:14:53 +0100
committerBen Murdoch <benm@google.com>2010-08-04 14:29:45 +0100
commitc407dc5cd9bdc5668497f21b26b09d988ab439de (patch)
tree7eaf8707c0309516bdb042ad976feedaf72b0bb1 /base/linux_util.h
parent0998b1cdac5733f299c12d88bc31ef9c8035b8fa (diff)
downloadexternal_chromium-c407dc5cd9bdc5668497f21b26b09d988ab439de.zip
external_chromium-c407dc5cd9bdc5668497f21b26b09d988ab439de.tar.gz
external_chromium-c407dc5cd9bdc5668497f21b26b09d988ab439de.tar.bz2
Merge Chromium src@r53293
Change-Id: Ia79acf8670f385cee48c45b0a75371d8e950af34
Diffstat (limited to 'base/linux_util.h')
-rw-r--r--base/linux_util.h71
1 files changed, 12 insertions, 59 deletions
diff --git a/base/linux_util.h b/base/linux_util.h
index b62f7cc..a4ba9b6 100644
--- a/base/linux_util.h
+++ b/base/linux_util.h
@@ -1,9 +1,9 @@
-// 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>
@@ -14,67 +14,14 @@ class FilePath;
namespace base {
-static const char kFindInodeSwitch[] = "--find-inode";
+class EnvVarGetter;
-// Makes a copy of |pixels| with the ordering changed from BGRA to RGBA.
-// The caller is responsible for free()ing the data. If |stride| is 0,
-// it's assumed to be 4 * |width|.
-uint8_t* BGRAToRGBA(const uint8_t* pixels, int width, int height, int stride);
+static const char kFindInodeSwitch[] = "--find-inode";
// Get the Linux Distro if we can, or return "Unknown", similar to
// 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);
-
-// 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);
-
-// 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);
-
-enum DesktopEnvironment {
- DESKTOP_ENVIRONMENT_OTHER,
- DESKTOP_ENVIRONMENT_GNOME,
- // KDE3 and KDE4 are sufficiently different that we count
- // them as two different desktop environments here.
- DESKTOP_ENVIRONMENT_KDE3,
- DESKTOP_ENVIRONMENT_KDE4,
-};
-
-// Return an entry from the DesktopEnvironment enum with a best guess
-// 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);
-
-// 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);
-
// Return the inode number for the UNIX domain socket |fd|.
bool FileDescriptorGetInode(ino_t* inode_out, int fd);
@@ -82,6 +29,12 @@ bool FileDescriptorGetInode(ino_t* inode_out, int fd);
// multiple processes hold the socket, this function returns false.
bool FindProcessHoldingSocket(pid_t* pid_out, ino_t socket_inode);
+// For a given process |pid|, look through all its threads and find the first
+// thread with /proc/[pid]/task/[thread_id]/syscall whose first N bytes matches
+// |expected_data|, where N is the length of |expected_data|.
+// Returns the thread id or -1 on error.
+pid_t FindThreadIDWithSyscall(pid_t pid, const std::string& expected_data);
+
} // namespace base
-#endif // BASE_LINUX_UTIL_H__
+#endif // BASE_LINUX_UTIL_H_