Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_PATH_SERVICE_H_ | 5 #ifndef BASE_PATH_SERVICE_H_ |
| 6 #define BASE_PATH_SERVICE_H_ | 6 #define BASE_PATH_SERVICE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/base_export.h" | 10 #include "base/base_export.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 46 // one test should not carry over to another. | 46 // one test should not carry over to another. |
| 47 static bool Override(int key, const base::FilePath& path); | 47 static bool Override(int key, const base::FilePath& path); |
| 48 | 48 |
| 49 // This function does the same as PathService::Override but it takes an extra | 49 // This function does the same as PathService::Override but it takes an extra |
| 50 // parameter |create| which guides whether the directory to be overriden must | 50 // parameter |create| which guides whether the directory to be overriden must |
| 51 // be created in case it doesn't exist already. | 51 // be created in case it doesn't exist already. |
| 52 static bool OverrideAndCreateIfNeeded(int key, | 52 static bool OverrideAndCreateIfNeeded(int key, |
| 53 const base::FilePath& path, | 53 const base::FilePath& path, |
| 54 bool create); | 54 bool create); |
| 55 | 55 |
| 56 // This function also does the same as PathService::Override but |path| must | |
| 57 // already be an absolute path. This can be used to override paths to | |
| 58 // non-existent files in posix systems, since Override relies on realpath() | |
| 59 // and that fails if the path doesn't exist. | |
| 60 // If |path| is a directory then it isn't created by this method. | |
| 61 static void OverrideWithAbsolutePath(int key, const base::FilePath& path); | |
|
brettw
2014/04/29 22:41:51
I'd rather see this as an additional flag to Overr
Joao da Silva
2014/04/30 13:08:06
Done.
| |
| 62 | |
| 56 // To extend the set of supported keys, you can register a path provider, | 63 // To extend the set of supported keys, you can register a path provider, |
| 57 // which is just a function mirroring PathService::Get. The ProviderFunc | 64 // which is just a function mirroring PathService::Get. The ProviderFunc |
| 58 // returns false if it cannot provide a non-empty path for the given key. | 65 // returns false if it cannot provide a non-empty path for the given key. |
| 59 // Otherwise, true is returned. | 66 // Otherwise, true is returned. |
| 60 // | 67 // |
| 61 // WARNING: This function could be called on any thread from which the | 68 // WARNING: This function could be called on any thread from which the |
| 62 // PathService is used, so a the ProviderFunc MUST BE THREADSAFE. | 69 // PathService is used, so a the ProviderFunc MUST BE THREADSAFE. |
| 63 // | 70 // |
| 64 typedef bool (*ProviderFunc)(int, base::FilePath*); | 71 typedef bool (*ProviderFunc)(int, base::FilePath*); |
| 65 | 72 |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 76 friend class base::ScopedPathOverride; | 83 friend class base::ScopedPathOverride; |
| 77 FRIEND_TEST_ALL_PREFIXES(PathServiceTest, RemoveOverride); | 84 FRIEND_TEST_ALL_PREFIXES(PathServiceTest, RemoveOverride); |
| 78 | 85 |
| 79 // Removes an override for a special directory or file. Returns true if there | 86 // Removes an override for a special directory or file. Returns true if there |
| 80 // was an override to remove or false if none was present. | 87 // was an override to remove or false if none was present. |
| 81 // NOTE: This function is intended to be used by tests only! | 88 // NOTE: This function is intended to be used by tests only! |
| 82 static bool RemoveOverride(int key); | 89 static bool RemoveOverride(int key); |
| 83 }; | 90 }; |
| 84 | 91 |
| 85 #endif // BASE_PATH_SERVICE_H_ | 92 #endif // BASE_PATH_SERVICE_H_ |
| OLD | NEW |