Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Side by Side Diff: base/linux_util.h

Issue 1701005: bsd: refactor XDG bits of linux_util into a shared file. (Closed)
Patch Set: Created 10 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef BASE_LINUX_UTIL_H_ 5 #ifndef BASE_LINUX_UTIL_H_
6 #define BASE_LINUX_UTIL_H_ 6 #define BASE_LINUX_UTIL_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <sys/types.h> 9 #include <sys/types.h>
10 10
11 #include <string> 11 #include <string>
12 12
13 class FilePath; 13 class FilePath;
14 14
15 namespace base { 15 namespace base {
16 16
17 class EnvVarGetter; 17 class EnvVarGetter;
18 18
19 static const char kFindInodeSwitch[] = "--find-inode"; 19 static const char kFindInodeSwitch[] = "--find-inode";
20 20
21 // Makes a copy of |pixels| with the ordering changed from BGRA to RGBA. 21 // Makes a copy of |pixels| with the ordering changed from BGRA to RGBA.
22 // The caller is responsible for free()ing the data. If |stride| is 0, 22 // The caller is responsible for free()ing the data. If |stride| is 0,
23 // it's assumed to be 4 * |width|. 23 // it's assumed to be 4 * |width|.
24 uint8_t* BGRAToRGBA(const uint8_t* pixels, int width, int height, int stride); 24 uint8_t* BGRAToRGBA(const uint8_t* pixels, int width, int height, int stride);
25 25
26 // Get the Linux Distro if we can, or return "Unknown", similar to 26 // Get the Linux Distro if we can, or return "Unknown", similar to
27 // GetWinVersion() in base/win_util.h. 27 // GetWinVersion() in base/win_util.h.
28 std::string GetLinuxDistro(); 28 std::string GetLinuxDistro();
29 29
30 // Get the home directory.
31 FilePath GetHomeDir(EnvVarGetter* env);
32
33 // Utility function for getting XDG directories.
34 // |env_name| is the name of an environment variable that we want to use to get
35 // a directory path. |fallback_dir| is the directory relative to $HOME that we
36 // use if |env_name| cannot be found or is empty. |fallback_dir| may be NULL.
37 // Examples of |env_name| are XDG_CONFIG_HOME and XDG_DATA_HOME.
38 FilePath GetXDGDirectory(EnvVarGetter* env, const char* env_name,
39 const char* fallback_dir);
40
41 // Wrapper around xdg_user_dir_lookup() from src/base/third_party/xdg-user-dirs
42 // This looks up "well known" user directories like the desktop and music
43 // folder. Examples of |dir_name| are DESKTOP and MUSIC.
44 FilePath GetXDGUserDirectory(EnvVarGetter* env, const char* dir_name,
45 const char* fallback_dir);
46
47 enum DesktopEnvironment {
48 DESKTOP_ENVIRONMENT_OTHER,
49 DESKTOP_ENVIRONMENT_GNOME,
50 // KDE3 and KDE4 are sufficiently different that we count
51 // them as two different desktop environments here.
52 DESKTOP_ENVIRONMENT_KDE3,
53 DESKTOP_ENVIRONMENT_KDE4,
54 DESKTOP_ENVIRONMENT_XFCE,
55 };
56
57 // Return an entry from the DesktopEnvironment enum with a best guess
58 // of which desktop environment we're using. We use this to know when
59 // to attempt to use preferences from the desktop environment --
60 // proxy settings, password manager, etc.
61 DesktopEnvironment GetDesktopEnvironment(EnvVarGetter* env);
62
63 // Return a string representation of the given desktop environment.
64 // May return NULL in the case of DESKTOP_ENVIRONMENT_OTHER.
65 const char* GetDesktopEnvironmentName(DesktopEnvironment env);
66 // Convenience wrapper that calls GetDesktopEnvironment() first.
67 const char* GetDesktopEnvironmentName(EnvVarGetter* env);
68
69 // Return the inode number for the UNIX domain socket |fd|. 30 // Return the inode number for the UNIX domain socket |fd|.
70 bool FileDescriptorGetInode(ino_t* inode_out, int fd); 31 bool FileDescriptorGetInode(ino_t* inode_out, int fd);
71 32
72 // Find the process which holds the given socket, named by inode number. If 33 // Find the process which holds the given socket, named by inode number. If
73 // multiple processes hold the socket, this function returns false. 34 // multiple processes hold the socket, this function returns false.
74 bool FindProcessHoldingSocket(pid_t* pid_out, ino_t socket_inode); 35 bool FindProcessHoldingSocket(pid_t* pid_out, ino_t socket_inode);
75 36
76 } // namespace base 37 } // namespace base
77 38
78 #endif // BASE_LINUX_UTIL_H_ 39 #endif // BASE_LINUX_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698