| 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 // TODO(evan): temporarily restoring this to quick-fix a regression. |
| 50 // Remove me again once it's fixed properly. |
| 51 static bool IsOverridden(int key); |
| 52 |
| 48 // To extend the set of supported keys, you can register a path provider, | 53 // To extend the set of supported keys, you can register a path provider, |
| 49 // which is just a function mirroring PathService::Get. The ProviderFunc | 54 // which is just a function mirroring PathService::Get. The ProviderFunc |
| 50 // returns false if it cannot provide a non-empty path for the given key. | 55 // returns false if it cannot provide a non-empty path for the given key. |
| 51 // Otherwise, true is returned. | 56 // Otherwise, true is returned. |
| 52 // | 57 // |
| 53 // WARNING: This function could be called on any thread from which the | 58 // WARNING: This function could be called on any thread from which the |
| 54 // PathService is used, so a the ProviderFunc MUST BE THREADSAFE. | 59 // PathService is used, so a the ProviderFunc MUST BE THREADSAFE. |
| 55 // | 60 // |
| 56 typedef bool (*ProviderFunc)(int, FilePath*); | 61 typedef bool (*ProviderFunc)(int, FilePath*); |
| 57 | 62 |
| 58 // Call to register a path provider. You must specify the range "[key_start, | 63 // Call to register a path provider. You must specify the range "[key_start, |
| 59 // key_end)" of supported path keys. | 64 // key_end)" of supported path keys. |
| 60 static void RegisterProvider(ProviderFunc provider, | 65 static void RegisterProvider(ProviderFunc provider, |
| 61 int key_start, | 66 int key_start, |
| 62 int key_end); | 67 int key_end); |
| 63 private: | 68 private: |
| 64 static bool GetFromCache(int key, FilePath* path); | 69 static bool GetFromCache(int key, FilePath* path); |
| 65 static bool GetFromOverrides(int key, FilePath* path); | 70 static bool GetFromOverrides(int key, FilePath* path); |
| 66 static void AddToCache(int key, const FilePath& path); | 71 static void AddToCache(int key, const FilePath& path); |
| 67 }; | 72 }; |
| 68 | 73 |
| 69 #endif // BASE_PATH_SERVICE_H_ | 74 #endif // BASE_PATH_SERVICE_H_ |
| OLD | NEW |