OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 | 10 |
(...skipping 27 matching lines...) Expand all Loading... |
38 // path specifies a directory that does not exist, the directory will be | 38 // path specifies a directory that does not exist, the directory will be |
39 // created by this method. This method returns true if successful. | 39 // created by this method. This method returns true if successful. |
40 // | 40 // |
41 // If the given path is relative, then it will be resolved against | 41 // If the given path is relative, then it will be resolved against |
42 // DIR_CURRENT. | 42 // DIR_CURRENT. |
43 // | 43 // |
44 // WARNING: Consumers of PathService::Get may expect paths to be constant | 44 // WARNING: Consumers of PathService::Get may expect paths to be constant |
45 // over the lifetime of the app, so this method should be used with caution. | 45 // over the lifetime of the app, so this method should be used with caution. |
46 static bool Override(int key, const FilePath& path); | 46 static bool Override(int key, const FilePath& path); |
47 | 47 |
48 // Return whether a path was overridden. | |
49 static bool IsOverridden(int key); | |
50 | |
51 // To extend the set of supported keys, you can register a path provider, | 48 // To extend the set of supported keys, you can register a path provider, |
52 // which is just a function mirroring PathService::Get. The ProviderFunc | 49 // which is just a function mirroring PathService::Get. The ProviderFunc |
53 // returns false if it cannot provide a non-empty path for the given key. | 50 // returns false if it cannot provide a non-empty path for the given key. |
54 // Otherwise, true is returned. | 51 // Otherwise, true is returned. |
55 // | 52 // |
56 // WARNING: This function could be called on any thread from which the | 53 // WARNING: This function could be called on any thread from which the |
57 // PathService is used, so a the ProviderFunc MUST BE THREADSAFE. | 54 // PathService is used, so a the ProviderFunc MUST BE THREADSAFE. |
58 // | 55 // |
59 typedef bool (*ProviderFunc)(int, FilePath*); | 56 typedef bool (*ProviderFunc)(int, FilePath*); |
60 | 57 |
61 // Call to register a path provider. You must specify the range "[key_start, | 58 // Call to register a path provider. You must specify the range "[key_start, |
62 // key_end)" of supported path keys. | 59 // key_end)" of supported path keys. |
63 static void RegisterProvider(ProviderFunc provider, | 60 static void RegisterProvider(ProviderFunc provider, |
64 int key_start, | 61 int key_start, |
65 int key_end); | 62 int key_end); |
66 private: | 63 private: |
67 static bool GetFromCache(int key, FilePath* path); | 64 static bool GetFromCache(int key, FilePath* path); |
| 65 static bool GetFromOverrides(int key, FilePath* path); |
68 static void AddToCache(int key, const FilePath& path); | 66 static void AddToCache(int key, const FilePath& path); |
69 }; | 67 }; |
70 | 68 |
71 #endif // BASE_PATH_SERVICE_H_ | 69 #endif // BASE_PATH_SERVICE_H_ |
OLD | NEW |