| 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 #include "base/path_service.h" | 5 #include "base/path_service.h" |
| 6 | 6 |
| 7 #ifdef OS_WIN | 7 #ifdef OS_WIN |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 #include <shellapi.h> | 9 #include <shellapi.h> |
| 10 #include <shlobj.h> | 10 #include <shlobj.h> |
| 11 #endif | 11 #endif |
| 12 | 12 |
| 13 #include "base/base_paths.h" |
| 13 #include "base/file_path.h" | 14 #include "base/file_path.h" |
| 14 #include "base/file_util.h" | 15 #include "base/file_util.h" |
| 15 #include "base/hash_tables.h" | 16 #include "base/hash_tables.h" |
| 16 #include "base/lazy_instance.h" | 17 #include "base/lazy_instance.h" |
| 17 #include "base/logging.h" | 18 #include "base/logging.h" |
| 18 #include "base/synchronization/lock.h" | 19 #include "base/synchronization/lock.h" |
| 19 | 20 |
| 21 #if defined(OS_WIN) |
| 22 #include "base/base_paths_win.h" |
| 23 #elif defined(OS_ANDROID) |
| 24 #include "base/base_paths_android.h" |
| 25 #elif defined(OS_MACOSX) |
| 26 #include "base/base_paths_mac.h" |
| 27 #endif |
| 28 |
| 29 #if defined(OS_POSIX) |
| 30 #include "base/base_paths_posix.h" |
| 31 #endif |
| 32 |
| 20 namespace base { | 33 namespace base { |
| 21 bool PathProvider(int key, FilePath* result); | 34 bool PathProvider(int key, FilePath* result); |
| 22 #if defined(OS_WIN) | 35 #if defined(OS_WIN) |
| 23 bool PathProviderWin(int key, FilePath* result); | 36 bool PathProviderWin(int key, FilePath* result); |
| 24 #elif defined(OS_MACOSX) | 37 #elif defined(OS_MACOSX) |
| 25 bool PathProviderMac(int key, FilePath* result); | 38 bool PathProviderMac(int key, FilePath* result); |
| 26 #elif defined(OS_ANDROID) | 39 #elif defined(OS_ANDROID) |
| 27 bool PathProviderAndroid(int key, FilePath* result); | 40 bool PathProviderAndroid(int key, FilePath* result); |
| 28 #elif defined(OS_POSIX) | 41 #elif defined(OS_POSIX) |
| 29 bool PathProviderPosix(int key, FilePath* result); | 42 bool PathProviderPosix(int key, FilePath* result); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 #endif | 91 #endif |
| 79 true | 92 true |
| 80 }; | 93 }; |
| 81 #endif | 94 #endif |
| 82 | 95 |
| 83 #if defined(OS_ANDROID) | 96 #if defined(OS_ANDROID) |
| 84 Provider base_provider_android = { | 97 Provider base_provider_android = { |
| 85 base::PathProviderAndroid, | 98 base::PathProviderAndroid, |
| 86 &base_provider, | 99 &base_provider, |
| 87 #ifndef NDEBUG | 100 #ifndef NDEBUG |
| 88 0, | 101 base::PATH_ANDROID_START, |
| 89 0, | 102 base::PATH_ANDROID_END, |
| 90 #endif | 103 #endif |
| 91 true | 104 true |
| 92 }; | 105 }; |
| 93 #endif | 106 #endif |
| 94 | 107 |
| 95 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) | 108 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) |
| 96 Provider base_provider_posix = { | 109 Provider base_provider_posix = { |
| 97 base::PathProviderPosix, | 110 base::PathProviderPosix, |
| 98 &base_provider, | 111 &base_provider, |
| 99 #ifndef NDEBUG | 112 #ifndef NDEBUG |
| 100 0, | 113 base::PATH_POSIX_START, |
| 101 0, | 114 base::PATH_POSIX_END, |
| 102 #endif | 115 #endif |
| 103 true | 116 true |
| 104 }; | 117 }; |
| 105 #endif | 118 #endif |
| 106 | 119 |
| 107 | 120 |
| 108 struct PathData { | 121 struct PathData { |
| 109 base::Lock lock; | 122 base::Lock lock; |
| 110 PathMap cache; // Cache mappings from path key to path value. | 123 PathMap cache; // Cache mappings from path key to path value. |
| 111 PathMap overrides; // Track path overrides. | 124 PathMap overrides; // Track path overrides. |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 p = new Provider; | 299 p = new Provider; |
| 287 p->is_static = false; | 300 p->is_static = false; |
| 288 p->func = func; | 301 p->func = func; |
| 289 p->next = path_data->providers; | 302 p->next = path_data->providers; |
| 290 #ifndef NDEBUG | 303 #ifndef NDEBUG |
| 291 p->key_start = key_start; | 304 p->key_start = key_start; |
| 292 p->key_end = key_end; | 305 p->key_end = key_end; |
| 293 #endif | 306 #endif |
| 294 path_data->providers = p; | 307 path_data->providers = p; |
| 295 } | 308 } |
| OLD | NEW |