| 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 | 7 |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/base_paths.h" | 12 #include "base/base_paths.h" |
| 13 | 13 |
| 14 class FilePath; | 14 class FilePath; |
| 15 | 15 |
| 16 // The path service is a global table mapping keys to file system paths. It is | 16 // The path service is a global table mapping keys to file system paths. It is |
| 17 // OK to use this service from multiple threads. | 17 // OK to use this service from multiple threads. |
| 18 // | 18 // |
| 19 class PathService { | 19 class PathService { |
| 20 public: | 20 public: |
| 21 // Retrieves a path to a special directory or file and places it into the | 21 // Retrieves a path to a special directory or file and places it into the |
| 22 // string pointed to by 'path'. If you ask for a directory it is guaranteed | 22 // string pointed to by 'path'. If you ask for a directory it is guaranteed |
| 23 // to NOT have a path separator at the end. For example, "c:\windows\temp" | 23 // to NOT have a path separator at the end. For example, "c:\windows\temp" |
| 24 // Directories are also guaranteed to exist when this function succeeds. | 24 // Directories are also guaranteed to exist when this function succeeds. |
| 25 // | 25 // |
| 26 // Returns true if the directory or file was successfully retrieved. On | 26 // Returns true if the directory or file was successfully retrieved. On |
| 27 // failure, 'path' will not be changed. | 27 // failure, 'path' will not be changed. |
| 28 static bool Get(int key, FilePath* path); | 28 static bool Get(int key, FilePath* path); |
| 29 #if defined(OS_WIN) |
| 29 // This version, producing a wstring, is deprecated and only kept around | 30 // This version, producing a wstring, is deprecated and only kept around |
| 30 // until we can fix all callers. | 31 // until we can fix all callers. |
| 31 static bool Get(int key, std::wstring* path); | 32 static bool Get(int key, std::wstring* path); |
| 33 #endif |
| 32 | 34 |
| 33 // Overrides the path to a special directory or file. This cannot be used to | 35 // Overrides the path to a special directory or file. This cannot be used to |
| 34 // change the value of DIR_CURRENT, but that should be obvious. Also, if the | 36 // change the value of DIR_CURRENT, but that should be obvious. Also, if the |
| 35 // path specifies a directory that does not exist, the directory will be | 37 // path specifies a directory that does not exist, the directory will be |
| 36 // created by this method. This method returns true if successful. | 38 // created by this method. This method returns true if successful. |
| 37 // | 39 // |
| 38 // If the given path is relative, then it will be resolved against | 40 // If the given path is relative, then it will be resolved against |
| 39 // DIR_CURRENT. | 41 // DIR_CURRENT. |
| 40 // | 42 // |
| 41 // WARNING: Consumers of PathService::Get may expect paths to be constant | 43 // WARNING: Consumers of PathService::Get may expect paths to be constant |
| (...skipping 17 matching lines...) Expand all Loading... |
| 59 // key_end)" of supported path keys. | 61 // key_end)" of supported path keys. |
| 60 static void RegisterProvider(ProviderFunc provider, | 62 static void RegisterProvider(ProviderFunc provider, |
| 61 int key_start, | 63 int key_start, |
| 62 int key_end); | 64 int key_end); |
| 63 private: | 65 private: |
| 64 static bool GetFromCache(int key, FilePath* path); | 66 static bool GetFromCache(int key, FilePath* path); |
| 65 static void AddToCache(int key, const FilePath& path); | 67 static void AddToCache(int key, const FilePath& path); |
| 66 }; | 68 }; |
| 67 | 69 |
| 68 #endif // BASE_PATH_SERVICE_H_ | 70 #endif // BASE_PATH_SERVICE_H_ |
| OLD | NEW |