summaryrefslogtreecommitdiffstats
path: root/base/path_service.cc
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-12 05:17:15 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-12 05:17:15 +0000
commit154769362a046967efd14bb0a0da5d6f3a301e32 (patch)
tree33e4550cd4f8895b639fabc55b45f5bb6e8d67bc /base/path_service.cc
parente7a810943e48e9649db8063058fb77ddefaf9f96 (diff)
downloadchromium_src-154769362a046967efd14bb0a0da5d6f3a301e32.zip
chromium_src-154769362a046967efd14bb0a0da5d6f3a301e32.tar.gz
chromium_src-154769362a046967efd14bb0a0da5d6f3a301e32.tar.bz2
Move path functions from file_util to FilePath object.
EnsureEndsWithSeparator used to check whether the file existed. This seems bad and unnecessary so I removed it. I removed file_util::ContainsPath and used the existing file_util::IsParent instead. The functions descriptions are the same but the implementations do slightly different things, which is worrying. The only non-test use of this function to worry about is content/browser/storage_partition_impl_map.cc. As far as I see, the requirements for this seem OK, but I'm not very familiar with this. After some discussion with akalin, I changed sync/internal_api/sync_manager_impl.cc to be a DCHECK that the path is absolute rather than make it absolute. The old code relied on the behavior of the old function that the argument would be unchanged if the file didn't exist, and this (possibly relative) path would be used later. This behavior doesn't make a lot of sense, and it looks like now that the path is always absolute, so I replaced this call with a DCHECK. BUG= Review URL: https://codereview.chromium.org/13196006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@193855 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/path_service.cc')
-rw-r--r--base/path_service.cc16
1 files changed, 8 insertions, 8 deletions
diff --git a/base/path_service.cc b/base/path_service.cc
index 1fd2f6f..32c6909 100644
--- a/base/path_service.cc
+++ b/base/path_service.cc
@@ -18,6 +18,7 @@
#include "base/synchronization/lock.h"
using base::FilePath;
+using base::MakeAbsoluteFilePath;
namespace base {
bool PathProvider(int key, FilePath* result);
@@ -217,9 +218,9 @@ bool PathService::Get(int key, FilePath* result) {
if (path.ReferencesParent()) {
// Make sure path service never returns a path with ".." in it.
- if (!file_util::AbsolutePath(&path)) {
+ path = MakeAbsoluteFilePath(path);
+ if (path.empty())
return false;
- }
}
*result = path;
@@ -250,17 +251,16 @@ bool PathService::OverrideAndCreateIfNeeded(int key,
// fore we protect this call with a flag.
if (create) {
// Make sure the directory exists. We need to do this before we translate
- // this to the absolute path because on POSIX, AbsolutePath fails if called
- // on a non-existent path.
+ // this to the absolute path because on POSIX, MakeAbsoluteFilePath fails
+ // if called on a non-existent path.
if (!file_util::PathExists(file_path) &&
!file_util::CreateDirectory(file_path))
return false;
}
- // We need to have an absolute path, as extensions and plugins don't like
- // relative paths, and will gladly crash the browser in CHECK()s if they get a
- // relative path.
- if (!file_util::AbsolutePath(&file_path))
+ // We need to have an absolute path.
+ file_path = MakeAbsoluteFilePath(file_path);
+ if (file_path.empty())
return false;
base::AutoLock scoped_lock(path_data->lock);