summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-21 01:29:00 +0000
committerevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-21 01:29:00 +0000
commit5d1937bb5d9137cbaa1c947c383c3742179062a9 (patch)
treee8644c6e2b7ce1c509d47b00b40bc5d41ef2f63f
parent29d334a2a5e8b66a83c161f54f83f3cdf5a31240 (diff)
downloadchromium_src-5d1937bb5d9137cbaa1c947c383c3742179062a9.zip
chromium_src-5d1937bb5d9137cbaa1c947c383c3742179062a9.tar.gz
chromium_src-5d1937bb5d9137cbaa1c947c383c3742179062a9.tar.bz2
posix: refactor duplicated path-handling code
We had the same code in three headers, and an "if FREEBSD" in a _linux.cc file. Review URL: http://codereview.chromium.org/414063 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@32722 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/base.gyp4
-rw-r--r--base/base_paths.h10
-rw-r--r--base/base_paths_linux.h30
-rw-r--r--base/base_paths_mac.h8
-rw-r--r--base/base_paths_posix.cc (renamed from base/base_paths_linux.cc)10
-rw-r--r--base/base_paths_win.h7
-rw-r--r--base/path_service.cc22
-rw-r--r--chrome/browser/gtk/browser_toolbar_gtk.cc2
-rw-r--r--chrome/browser/gtk/browser_window_gtk.cc2
9 files changed, 29 insertions, 66 deletions
diff --git a/base/base.gyp b/base/base.gyp
index 777dab1..e7eda09 100644
--- a/base/base.gyp
+++ b/base/base.gyp
@@ -76,10 +76,9 @@
'base_drop_target.h',
'base_paths.cc',
'base_paths.h',
- 'base_paths_linux.h',
- 'base_paths_linux.cc',
'base_paths_mac.h',
'base_paths_mac.mm',
+ 'base_paths_posix.cc',
'base_paths_win.cc',
'base_paths_win.h',
'base_switches.cc',
@@ -447,6 +446,7 @@
'crypto/signature_creator_nss.cc',
'crypto/signature_verifier_nss.cc',
'atomicops_internals_x86_gcc.cc',
+ 'base_paths_posix.cc',
'directory_watcher_inotify.cc',
'hmac_nss.cc',
'linux_util.cc',
diff --git a/base/base_paths.h b/base/base_paths.h
index 86c7a4b..8ec19e5 100644
--- a/base/base_paths.h
+++ b/base/base_paths.h
@@ -13,8 +13,6 @@
#include "base/base_paths_win.h"
#elif defined(OS_MACOSX)
#include "base/base_paths_mac.h"
-#elif defined(OS_LINUX) || defined(OS_FREEBSD)
-#include "base/base_paths_linux.h"
#endif
#include "base/path_service.h"
@@ -27,6 +25,14 @@ enum {
DIR_EXE, // directory containing FILE_EXE
DIR_MODULE, // directory containing FILE_MODULE
DIR_TEMP, // temporary directory
+ FILE_EXE, // Path and filename of the current executable.
+ FILE_MODULE, // Path and filename of the module containing the code for the
+ // PathService (which could differ from FILE_EXE if the
+ // PathService were compiled into a shared object, for example).
+ DIR_SOURCE_ROOT, // Returns the root of the source tree. This key is useful
+ // for tests that need to locate various resources. It
+ // should not be used outside of test code.
+
PATH_END
};
diff --git a/base/base_paths_linux.h b/base/base_paths_linux.h
deleted file mode 100644
index 8273f01..0000000
--- a/base/base_paths_linux.h
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright (c) 2006-2008 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_BASE_PATHS_LINUX_H_
-#define BASE_BASE_PATHS_LINUX_H_
-
-// This file declares Linux-specific path keys for the base module.
-// These can be used with the PathService to access various special
-// directories and files.
-
-namespace base {
-
-enum {
- PATH_LINUX_START = 200,
-
- FILE_EXE, // Path and filename of the current executable.
- FILE_MODULE, // Path and filename of the module containing the code for the
- // PathService (which could differ from FILE_EXE if the
- // PathService were compiled into a shared object, for example).
- DIR_SOURCE_ROOT, // Returns the root of the source tree. This key is useful
- // for tests that need to locate various resources. It
- // should not be used outside of test code.
-
- PATH_LINUX_END
-};
-
-} // namespace base
-
-#endif // BASE_BASE_PATHS_LINUX_H_
diff --git a/base/base_paths_mac.h b/base/base_paths_mac.h
index 324fc6c..60dd0f3 100644
--- a/base/base_paths_mac.h
+++ b/base/base_paths_mac.h
@@ -14,15 +14,9 @@ namespace base {
enum {
PATH_MAC_START = 200,
- FILE_EXE, // path and filename of the current executable
- FILE_MODULE, // path and filename of the module containing the code for the
- // PathService (which could differ from FILE_EXE if the
- // PathService were compiled into a library, for example)
DIR_CACHE, // ~/Library/Caches
DIR_APP_DATA, // ~/Library/Application Support
- DIR_SOURCE_ROOT, // Returns the root of the source tree. This key is useful
- // for tests that need to locate various resources. It
- // should not be used outside of test code.
+
PATH_MAC_END
};
diff --git a/base/base_paths_linux.cc b/base/base_paths_posix.cc
index ca5ca4e..799c135 100644
--- a/base/base_paths_linux.cc
+++ b/base/base_paths_posix.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/base_paths_linux.h"
+#include "base/base_paths.h"
#include <unistd.h>
@@ -21,7 +21,7 @@ const char kSelfExe[] = "/proc/self/exe";
const char kSelfExe[] = "/proc/curproc/file";
#endif
-bool PathProviderLinux(int key, FilePath* result) {
+bool PathProviderPosix(int key, FilePath* result) {
FilePath path;
switch (key) {
case base::FILE_EXE:
@@ -37,11 +37,11 @@ bool PathProviderLinux(int key, FilePath* result) {
return true;
}
case base::DIR_SOURCE_ROOT:
- // On linux, unit tests execute two levels deep from the source root.
+ // On POSIX, unit tests execute two levels deep from the source root.
// For example: sconsbuild/{Debug|Release}/net_unittest
if (PathService::Get(base::DIR_EXE, &path)) {
path = path.DirName().DirName();
- if (file_util::PathExists(path.Append("base/base_paths_linux.cc"))) {
+ if (file_util::PathExists(path.Append("base/base_paths_posix.cc"))) {
*result = path;
return true;
}
@@ -49,7 +49,7 @@ bool PathProviderLinux(int key, FilePath* result) {
// If that failed (maybe the build output is symlinked to a different
// drive) try assuming the current directory is the source root.
if (file_util::GetCurrentDirectory(&path) &&
- file_util::PathExists(path.Append("base/base_paths_linux.cc"))) {
+ file_util::PathExists(path.Append("base/base_paths_posix.cc"))) {
*result = path;
return true;
}
diff --git a/base/base_paths_win.h b/base/base_paths_win.h
index e393d24..2e585d9 100644
--- a/base/base_paths_win.h
+++ b/base/base_paths_win.h
@@ -14,10 +14,6 @@ namespace base {
enum {
PATH_WIN_START = 100,
- FILE_EXE, // path and filename of the current executable
- FILE_MODULE, // path and filename of the module containing the code for the
- // PathService (which could differ from FILE_EXE if the
- // PathService were compiled into a DLL, for example)
DIR_WINDOWS, // Windows directory, usually "c:\windows"
DIR_SYSTEM, // Usually c:\windows\system32"
DIR_PROGRAM_FILES, // Usually c:\program files
@@ -31,9 +27,6 @@ enum {
DIR_LOCAL_APP_DATA_LOW, // Local AppData directory for low integrity level.
DIR_LOCAL_APP_DATA, // "Local Settings\Application Data" directory under the
// user profile.
- DIR_SOURCE_ROOT, // Returns the root of the source tree. This key is useful
- // for tests that need to locate various resources. It
- // should not be used outside of test code.
PATH_WIN_END
};
diff --git a/base/path_service.cc b/base/path_service.cc
index 0e4c6a2..e363fe6 100644
--- a/base/path_service.cc
+++ b/base/path_service.cc
@@ -24,8 +24,8 @@ namespace base {
bool PathProviderWin(int key, FilePath* result);
#elif defined(OS_MACOSX)
bool PathProviderMac(int key, FilePath* result);
-#elif defined(OS_LINUX)
- bool PathProviderLinux(int key, FilePath* result);
+#elif defined(OS_POSIX)
+ bool PathProviderPosix(int key, FilePath* result);
#endif
}
@@ -56,7 +56,7 @@ static Provider base_provider = {
true
};
-#ifdef OS_WIN
+#if defined(OS_WIN)
static Provider base_provider_win = {
base::PathProviderWin,
&base_provider,
@@ -68,7 +68,7 @@ static Provider base_provider_win = {
};
#endif
-#ifdef OS_MACOSX
+#if defined(OS_MACOSX)
static Provider base_provider_mac = {
base::PathProviderMac,
&base_provider,
@@ -80,13 +80,13 @@ static Provider base_provider_mac = {
};
#endif
-#if defined(OS_LINUX)
-static Provider base_provider_linux = {
- base::PathProviderLinux,
+#if defined(OS_POSIX) && !defined(OS_MACOSX)
+static Provider base_provider_posix = {
+ base::PathProviderPosix,
&base_provider,
#ifndef NDEBUG
- base::PATH_LINUX_START,
- base::PATH_LINUX_END,
+ 0,
+ 0,
#endif
true
};
@@ -104,8 +104,8 @@ struct PathData {
providers = &base_provider_win;
#elif defined(OS_MACOSX)
providers = &base_provider_mac;
-#elif defined(OS_LINUX)
- providers = &base_provider_linux;
+#elif defined(OS_POSIX)
+ providers = &base_provider_posix;
#endif
}
diff --git a/chrome/browser/gtk/browser_toolbar_gtk.cc b/chrome/browser/gtk/browser_toolbar_gtk.cc
index a0e21ab..e0c5965 100644
--- a/chrome/browser/gtk/browser_toolbar_gtk.cc
+++ b/chrome/browser/gtk/browser_toolbar_gtk.cc
@@ -11,7 +11,7 @@
#include "app/gtk_dnd_util.h"
#include "app/l10n_util.h"
#include "app/resource_bundle.h"
-#include "base/base_paths_linux.h"
+#include "base/base_paths.h"
#include "base/logging.h"
#include "base/path_service.h"
#include "chrome/app/chrome_dll_resource.h"
diff --git a/chrome/browser/gtk/browser_window_gtk.cc b/chrome/browser/gtk/browser_window_gtk.cc
index c136c0c..fd57740 100644
--- a/chrome/browser/gtk/browser_window_gtk.cc
+++ b/chrome/browser/gtk/browser_window_gtk.cc
@@ -14,7 +14,7 @@
#include "app/l10n_util.h"
#include "app/resource_bundle.h"
#include "app/theme_provider.h"
-#include "base/base_paths_linux.h"
+#include "base/base_paths.h"
#include "base/command_line.h"
#include "base/gfx/rect.h"
#include "base/logging.h"