Thanks to visit codestin.com
Credit goes to chromium.googlesource.com

blob: c6a1855428bb6ebb2287a45e6a14a81b0d0f3f46 [file] [log] [blame]
Avi Drissmane4622aa2022-09-08 20:36:061// Copyright 2012 The Chromium Authors
license.botbf09a502008-08-24 00:55:552// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
initial.commitd7cae122008-07-26 21:49:384
[email protected]09ad1e622008-08-07 20:23:095#include "base/path_service.h"
[email protected]355cc2742008-08-06 16:01:256
brettw1ce49f62017-04-27 19:42:327#include <unordered_map>
Greg Thompson53fd47592023-08-01 07:30:598#include <utility>
brettw1ce49f62017-04-27 19:42:329
Qi Tiezhengf537c422022-09-15 06:58:3410#include "base/check_op.h"
11#include "base/files/file_path.h"
12#include "base/files/file_util.h"
13#include "base/logging.h"
Keishi Hattori0e45c022021-11-27 09:25:5214#include "base/memory/raw_ptr.h"
Keishi Hattori8a7e15d2023-01-19 07:16:2915#include "base/memory/raw_ptr_exclusion.h"
Qi Tiezhengf537c422022-09-15 06:58:3416#include "base/synchronization/lock.h"
Xiaohan Wang38e4ebb2022-01-19 06:57:4317#include "build/build_config.h"
Keishi Hattori0e45c022021-11-27 09:25:5218
Xiaohan Wang38e4ebb2022-01-19 06:57:4319#if BUILDFLAG(IS_WIN)
initial.commitd7cae122008-07-26 21:49:3820#include <windows.h>
Bruce Dawsona1e1cfcb2022-11-22 20:04:3521
initial.commitd7cae122008-07-26 21:49:3822#include <shellapi.h>
23#include <shlobj.h>
[email protected]355cc2742008-08-06 16:01:2524#endif
initial.commitd7cae122008-07-26 21:49:3825
Paul Semelf90c9dc52023-11-03 12:19:5626#define ENABLE_BEHAVIOUR_OVERRIDE_PROVIDER \
27 ((BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_APPLE) && !BUILDFLAG(IS_ANDROID)) || \
28 BUILDFLAG(IS_WIN))
29
initial.commitd7cae122008-07-26 21:49:3830namespace base {
brettwf0dea132015-09-25 20:08:5431
Paul Semelf90c9dc52023-11-03 12:19:5632// Custom behaviour providers.
33bool EnvOverridePathProvider(int key, FilePath* result);
34
brettwf0dea132015-09-25 20:08:5435bool PathProvider(int key, FilePath* result);
36
Xiaohan Wang38e4ebb2022-01-19 06:57:4337#if BUILDFLAG(IS_WIN)
brettwf0dea132015-09-25 20:08:5438bool PathProviderWin(int key, FilePath* result);
Sylvain Defresnea9ffa992023-06-19 09:29:0639#elif BUILDFLAG(IS_MAC)
brettwf0dea132015-09-25 20:08:5440bool PathProviderMac(int key, FilePath* result);
Sylvain Defresnea9ffa992023-06-19 09:29:0641#elif BUILDFLAG(IS_IOS)
42bool PathProviderIOS(int key, FilePath* result);
Xiaohan Wang38e4ebb2022-01-19 06:57:4343#elif BUILDFLAG(IS_ANDROID)
brettwf0dea132015-09-25 20:08:5444bool PathProviderAndroid(int key, FilePath* result);
Xiaohan Wang38e4ebb2022-01-19 06:57:4345#elif BUILDFLAG(IS_FUCHSIA)
scottmg1ab7aa82017-05-25 05:22:4946bool PathProviderFuchsia(int key, FilePath* result);
Xiaohan Wang38e4ebb2022-01-19 06:57:4347#elif BUILDFLAG(IS_POSIX)
brettwf0dea132015-09-25 20:08:5448// PathProviderPosix is the default path provider on POSIX OSes other than
49// Mac and Android.
50bool PathProviderPosix(int key, FilePath* result);
[email protected]ac510e12008-08-05 19:46:3151#endif
initial.commitd7cae122008-07-26 21:49:3852
53namespace {
54
brettw1ce49f62017-04-27 19:42:3255typedef std::unordered_map<int, FilePath> PathMap;
initial.commitd7cae122008-07-26 21:49:3856
57// We keep a linked list of providers. In a debug build we ensure that no two
58// providers claim overlapping keys.
59struct Provider {
60 PathService::ProviderFunc func;
Devon Loehrde99c7302024-12-16 21:33:0561 // This field is not a raw_ptr<> because would cause the class to have a
62 // nontrivial destructor, causing several cascading compile errors. The
63 // pointer cannot dangle because all Providers are either in statically-
64 // allocated memory (globals), or allocated in RegisterProvider and
65 // never freed.
Keishi Hattori8a7e15d2023-01-19 07:16:2966 RAW_PTR_EXCLUSION struct Provider* next;
initial.commitd7cae122008-07-26 21:49:3867#ifndef NDEBUG
68 int key_start;
69 int key_end;
70#endif
[email protected]173cb8a02008-08-20 15:47:3971 bool is_static;
initial.commitd7cae122008-07-26 21:49:3872};
73
Ivan Kotenkova16212a52017-11-08 12:37:3374Provider base_provider = {PathProvider, nullptr,
initial.commitd7cae122008-07-26 21:49:3875#ifndef NDEBUG
Ivan Kotenkova16212a52017-11-08 12:37:3376 PATH_START, PATH_END,
initial.commitd7cae122008-07-26 21:49:3877#endif
Ivan Kotenkova16212a52017-11-08 12:37:3378 true};
initial.commitd7cae122008-07-26 21:49:3879
Xiaohan Wang38e4ebb2022-01-19 06:57:4380#if BUILDFLAG(IS_WIN)
Paul Semelf90c9dc52023-11-03 12:19:5681Provider win_provider = {PathProviderWin, &base_provider,
[email protected]ac510e12008-08-05 19:46:3182#ifndef NDEBUG
Paul Semelf90c9dc52023-11-03 12:19:5683 PATH_WIN_START, PATH_WIN_END,
[email protected]ac510e12008-08-05 19:46:3184#endif
Paul Semelf90c9dc52023-11-03 12:19:5685 true};
86Provider base_provider_win = {EnvOverridePathProvider, &win_provider,
87#ifndef NDEBUG
88 PATH_START, PATH_END,
89#endif
90 true};
[email protected]ac510e12008-08-05 19:46:3191#endif
92
Sylvain Defresnea9ffa992023-06-19 09:29:0693#if BUILDFLAG(IS_MAC)
Peter Kasting134ef9af2024-12-28 02:30:0994Provider base_provider_mac = {PathProviderMac, &base_provider,
[email protected]5af2edb92008-08-08 20:16:0895#ifndef NDEBUG
Peter Kasting134ef9af2024-12-28 02:30:0996 PATH_MAC_START, PATH_MAC_END,
[email protected]5af2edb92008-08-08 20:16:0897#endif
Peter Kasting134ef9af2024-12-28 02:30:0998 true};
[email protected]5af2edb92008-08-08 20:16:0899#endif
[email protected]4c0040c2008-08-15 01:04:11100
Sylvain Defresnea9ffa992023-06-19 09:29:06101#if BUILDFLAG(IS_IOS)
Peter Kasting134ef9af2024-12-28 02:30:09102Provider base_provider_ios = {PathProviderIOS, &base_provider,
Sylvain Defresnea9ffa992023-06-19 09:29:06103#ifndef NDEBUG
Peter Kasting134ef9af2024-12-28 02:30:09104 PATH_IOS_START, PATH_IOS_END,
Sylvain Defresnea9ffa992023-06-19 09:29:06105#endif
Peter Kasting134ef9af2024-12-28 02:30:09106 true};
Sylvain Defresnea9ffa992023-06-19 09:29:06107#endif
108
Xiaohan Wang38e4ebb2022-01-19 06:57:43109#if BUILDFLAG(IS_ANDROID)
Peter Kasting134ef9af2024-12-28 02:30:09110Provider base_provider_android = {PathProviderAndroid, &base_provider,
[email protected]f7d69972011-06-21 22:34:50111#ifndef NDEBUG
Peter Kasting134ef9af2024-12-28 02:30:09112 PATH_ANDROID_START, PATH_ANDROID_END,
[email protected]f7d69972011-06-21 22:34:50113#endif
Peter Kasting134ef9af2024-12-28 02:30:09114 true};
[email protected]f7d69972011-06-21 22:34:50115#endif
116
Xiaohan Wang38e4ebb2022-01-19 06:57:43117#if BUILDFLAG(IS_FUCHSIA)
scottmg1ab7aa82017-05-25 05:22:49118Provider base_provider_fuchsia = {PathProviderFuchsia, &base_provider,
119#ifndef NDEBUG
120 0, 0,
121#endif
122 true};
123#endif
124
Xiaohan Wang38e4ebb2022-01-19 06:57:43125#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_APPLE) && !BUILDFLAG(IS_ANDROID)
Paul Semelf90c9dc52023-11-03 12:19:56126Provider posix_provider = {PathProviderPosix, &base_provider,
[email protected]4c0040c2008-08-15 01:04:11127#ifndef NDEBUG
Paul Semelf90c9dc52023-11-03 12:19:56128 PATH_POSIX_START, PATH_POSIX_END,
[email protected]4c0040c2008-08-15 01:04:11129#endif
Paul Semelf90c9dc52023-11-03 12:19:56130 true};
131Provider base_provider_posix = {EnvOverridePathProvider, &posix_provider,
132#ifndef NDEBUG
133 PATH_START, PATH_END,
134#endif
135 true};
[email protected]4c0040c2008-08-15 01:04:11136#endif
137
initial.commitd7cae122008-07-26 21:49:38138struct PathData {
brettwf0dea132015-09-25 20:08:54139 Lock lock;
Peter Kasting134ef9af2024-12-28 02:30:09140 PathMap cache; // Cache mappings from path key to path value.
141 PathMap overrides; // Track path overrides.
Keishi Hattori0e45c022021-11-27 09:25:52142 raw_ptr<Provider> providers; // Linked list of path service providers.
Peter Kasting811504a72025-01-09 03:18:50143 bool cache_disabled = false; // Don't use cache if true;
initial.commitd7cae122008-07-26 21:49:38144
Peter Kasting811504a72025-01-09 03:18:50145 PathData() {
Xiaohan Wang38e4ebb2022-01-19 06:57:43146#if BUILDFLAG(IS_WIN)
[email protected]ac510e12008-08-05 19:46:31147 providers = &base_provider_win;
Sylvain Defresnea9ffa992023-06-19 09:29:06148#elif BUILDFLAG(IS_MAC)
[email protected]5af2edb92008-08-08 20:16:08149 providers = &base_provider_mac;
Sylvain Defresnea9ffa992023-06-19 09:29:06150#elif BUILDFLAG(IS_IOS)
151 providers = &base_provider_ios;
Xiaohan Wang38e4ebb2022-01-19 06:57:43152#elif BUILDFLAG(IS_ANDROID)
[email protected]f7d69972011-06-21 22:34:50153 providers = &base_provider_android;
Xiaohan Wang38e4ebb2022-01-19 06:57:43154#elif BUILDFLAG(IS_FUCHSIA)
scottmg1ab7aa82017-05-25 05:22:49155 providers = &base_provider_fuchsia;
Xiaohan Wang38e4ebb2022-01-19 06:57:43156#elif BUILDFLAG(IS_POSIX)
[email protected]5d1937bb2009-11-21 01:29:00157 providers = &base_provider_posix;
[email protected]ac510e12008-08-05 19:46:31158#endif
initial.commitd7cae122008-07-26 21:49:38159 }
160};
[email protected]52a261f2009-03-03 15:01:12161
[email protected]1265917f2008-08-12 17:33:52162static PathData* GetPathData() {
vmpstr5f02eae2017-02-13 21:11:41163 static auto* path_data = new PathData();
scottmg6ece5ae2017-02-01 18:25:19164 return path_data;
[email protected]1265917f2008-08-12 17:33:52165}
initial.commitd7cae122008-07-26 21:49:38166
Benoit Lize25859152020-07-09 11:52:09167// Tries to find |key| in the cache.
168bool LockedGetFromCache(int key, const PathData* path_data, FilePath* result)
169 EXCLUSIVE_LOCKS_REQUIRED(path_data->lock) {
Peter Kasting134ef9af2024-12-28 02:30:09170 if (path_data->cache_disabled) {
[email protected]c5a726b32013-01-29 00:56:56171 return false;
Peter Kasting134ef9af2024-12-28 02:30:09172 }
[email protected]6723f832008-08-11 15:38:27173 // check for a cached version
jdoerrie1c4b8ff2018-10-03 00:10:57174 auto it = path_data->cache.find(key);
[email protected]6723f832008-08-11 15:38:27175 if (it != path_data->cache.end()) {
176 *result = it->second;
177 return true;
178 }
179 return false;
180}
181
Benoit Lize25859152020-07-09 11:52:09182// Tries to find |key| in the overrides map.
183bool LockedGetFromOverrides(int key, PathData* path_data, FilePath* result)
184 EXCLUSIVE_LOCKS_REQUIRED(path_data->lock) {
[email protected]846c3ecea2011-12-14 18:47:26185 // check for an overridden version.
[email protected]34e043b2010-09-09 23:49:04186 PathMap::const_iterator it = path_data->overrides.find(key);
187 if (it != path_data->overrides.end()) {
Peter Kasting134ef9af2024-12-28 02:30:09188 if (!path_data->cache_disabled) {
[email protected]c5a726b32013-01-29 00:56:56189 path_data->cache[key] = it->second;
Peter Kasting134ef9af2024-12-28 02:30:09190 }
[email protected]34e043b2010-09-09 23:49:04191 *result = it->second;
192 return true;
193 }
194 return false;
195}
196
[email protected]d6b3af92012-09-26 19:05:12197} // namespace
[email protected]6723f832008-08-11 15:38:27198
initial.commitd7cae122008-07-26 21:49:38199// TODO(brettw): this function does not handle long paths (filename > MAX_PATH)
200// characters). This isn't supported very well by Windows right now, so it is
201// moot, but we should keep this in mind for the future.
202// static
[email protected]640517f2008-10-30 23:54:04203bool PathService::Get(int key, FilePath* result) {
[email protected]1265917f2008-08-12 17:33:52204 PathData* path_data = GetPathData();
initial.commitd7cae122008-07-26 21:49:38205 DCHECK(path_data);
206 DCHECK(result);
David Dorwin15b9e1662021-11-04 19:45:05207 DCHECK_GT(key, PATH_START);
initial.commitd7cae122008-07-26 21:49:38208
David Dorwin15b9e1662021-11-04 19:45:05209 // Special case the current directory because it can never be cached.
Peter Kasting134ef9af2024-12-28 02:30:09210 if (key == DIR_CURRENT) {
brettwf0dea132015-09-25 20:08:54211 return GetCurrentDirectory(result);
Peter Kasting134ef9af2024-12-28 02:30:09212 }
initial.commitd7cae122008-07-26 21:49:38213
Ivan Kotenkova16212a52017-11-08 12:37:33214 Provider* provider = nullptr;
[email protected]d6b3af92012-09-26 19:05:12215 {
brettwf0dea132015-09-25 20:08:54216 AutoLock scoped_lock(path_data->lock);
Peter Kasting134ef9af2024-12-28 02:30:09217 if (LockedGetFromCache(key, path_data, result)) {
[email protected]d6b3af92012-09-26 19:05:12218 return true;
Peter Kasting134ef9af2024-12-28 02:30:09219 }
[email protected]c1a9f8d42009-02-28 01:49:55220
Peter Kasting134ef9af2024-12-28 02:30:09221 if (LockedGetFromOverrides(key, path_data, result)) {
[email protected]d6b3af92012-09-26 19:05:12222 return true;
Peter Kasting134ef9af2024-12-28 02:30:09223 }
[email protected]d6b3af92012-09-26 19:05:12224
225 // Get the beginning of the list while it is still locked.
226 provider = path_data->providers;
227 }
[email protected]34e043b2010-09-09 23:49:04228
[email protected]4792a262008-11-19 16:50:03229 FilePath path;
initial.commitd7cae122008-07-26 21:49:38230
[email protected]d6b3af92012-09-26 19:05:12231 // Iterating does not need the lock because only the list head might be
232 // modified on another thread.
initial.commitd7cae122008-07-26 21:49:38233 while (provider) {
Peter Kasting134ef9af2024-12-28 02:30:09234 if (provider->func(key, &path)) {
initial.commitd7cae122008-07-26 21:49:38235 break;
Peter Kasting134ef9af2024-12-28 02:30:09236 }
[email protected]c1a9f8d42009-02-28 01:49:55237 DCHECK(path.empty()) << "provider should not have modified path";
initial.commitd7cae122008-07-26 21:49:38238 provider = provider->next;
239 }
240
Peter Kasting134ef9af2024-12-28 02:30:09241 if (path.empty()) {
initial.commitd7cae122008-07-26 21:49:38242 return false;
Peter Kasting134ef9af2024-12-28 02:30:09243 }
initial.commitd7cae122008-07-26 21:49:38244
[email protected]082f8202013-01-26 04:51:29245 if (path.ReferencesParent()) {
246 // Make sure path service never returns a path with ".." in it.
[email protected]154769362013-04-12 05:17:15247 path = MakeAbsoluteFilePath(path);
Peter Kasting134ef9af2024-12-28 02:30:09248 if (path.empty()) {
[email protected]082f8202013-01-26 04:51:29249 return false;
Peter Kasting134ef9af2024-12-28 02:30:09250 }
[email protected]082f8202013-01-26 04:51:29251 }
[email protected]640517f2008-10-30 23:54:04252 *result = path;
[email protected]d6b3af92012-09-26 19:05:12253
brettwf0dea132015-09-25 20:08:54254 AutoLock scoped_lock(path_data->lock);
Peter Kasting134ef9af2024-12-28 02:30:09255 if (!path_data->cache_disabled) {
[email protected]c5a726b32013-01-29 00:56:56256 path_data->cache[key] = path;
Peter Kasting134ef9af2024-12-28 02:30:09257 }
[email protected]d6b3af92012-09-26 19:05:12258
[email protected]640517f2008-10-30 23:54:04259 return true;
260}
261
Maksim Ivanov9a39401c2020-07-08 19:30:37262FilePath PathService::CheckedGet(int key) {
263 FilePath path;
Maksim Ivanoveeb2d0802020-07-17 21:44:00264 LOG_IF(FATAL, !Get(key, &path)) << "Failed to get the path for " << key;
Maksim Ivanov9a39401c2020-07-08 19:30:37265 return path;
266}
267
[email protected]d6b3af92012-09-26 19:05:12268// static
[email protected]eca6a4f2009-06-25 17:29:09269bool PathService::Override(int key, const FilePath& path) {
[email protected]ff9ed9f2014-05-02 17:59:42270 // Just call the full function with true for the value of |create|, and
271 // assume that |path| may not be absolute yet.
272 return OverrideAndCreateIfNeeded(key, path, false, true);
[email protected]cb571e752012-05-09 10:50:10273}
274
[email protected]d6b3af92012-09-26 19:05:12275// static
[email protected]cb571e752012-05-09 10:50:10276bool PathService::OverrideAndCreateIfNeeded(int key,
277 const FilePath& path,
[email protected]ff9ed9f2014-05-02 17:59:42278 bool is_absolute,
[email protected]cb571e752012-05-09 10:50:10279 bool create) {
[email protected]1265917f2008-08-12 17:33:52280 PathData* path_data = GetPathData();
initial.commitd7cae122008-07-26 21:49:38281 DCHECK(path_data);
David Dorwin15b9e1662021-11-04 19:45:05282 DCHECK_GT(key, PATH_START) << "invalid path key";
initial.commitd7cae122008-07-26 21:49:38283
[email protected]eca6a4f2009-06-25 17:29:09284 FilePath file_path = path;
initial.commitd7cae122008-07-26 21:49:38285
Greg Thompson53fd47592023-08-01 07:30:59286 // Create the directory if requested by the caller. Do this before resolving
287 // `file_path` to an absolute path because on POSIX, MakeAbsoluteFilePath
288 // requires that the path exists.
289 if (create && !CreateDirectory(file_path)) {
290 return false;
[email protected]cb571e752012-05-09 10:50:10291 }
initial.commitd7cae122008-07-26 21:49:38292
[email protected]154769362013-04-12 05:17:15293 // We need to have an absolute path.
[email protected]ff9ed9f2014-05-02 17:59:42294 if (!is_absolute) {
295 file_path = MakeAbsoluteFilePath(file_path);
Peter Kasting134ef9af2024-12-28 02:30:09296 if (file_path.empty()) {
[email protected]ff9ed9f2014-05-02 17:59:42297 return false;
Peter Kasting134ef9af2024-12-28 02:30:09298 }
[email protected]ff9ed9f2014-05-02 17:59:42299 }
300 DCHECK(file_path.IsAbsolute());
[email protected]dabdb682009-10-27 23:31:36301
brettwf0dea132015-09-25 20:08:54302 AutoLock scoped_lock(path_data->lock);
[email protected]34e043b2010-09-09 23:49:04303
304 // Clear the cache now. Some of its entries could have depended
305 // on the value we are overriding, and are now out of sync with reality.
306 path_data->cache.clear();
307
Greg Thompson53fd47592023-08-01 07:30:59308 path_data->overrides[key] = std::move(file_path);
[email protected]34e043b2010-09-09 23:49:04309
initial.commitd7cae122008-07-26 21:49:38310 return true;
311}
312
[email protected]d6b3af92012-09-26 19:05:12313// static
Mingyu Lei814f95a2025-07-03 09:05:12314bool PathService::OverrideWithoutCheckForTesting(int key,
315 const FilePath& path) {
316 PathData* path_data = GetPathData();
317 DCHECK(path_data);
318
319 AutoLock scoped_lock(path_data->lock);
320
321 // Clear the cache now. Some of its entries could have depended
322 // on the value we are overriding, and are now out of sync with reality.
323 path_data->cache.clear();
324 path_data->overrides[key] = path;
325
326 return true;
327}
328
329// static
mlcui3f0b3892020-12-10 00:11:13330bool PathService::RemoveOverrideForTests(int key) {
[email protected]d6b3af92012-09-26 19:05:12331 PathData* path_data = GetPathData();
332 DCHECK(path_data);
333
brettwf0dea132015-09-25 20:08:54334 AutoLock scoped_lock(path_data->lock);
[email protected]d6b3af92012-09-26 19:05:12335
Peter Kasting134ef9af2024-12-28 02:30:09336 if (path_data->overrides.find(key) == path_data->overrides.end()) {
[email protected]d6b3af92012-09-26 19:05:12337 return false;
Peter Kasting134ef9af2024-12-28 02:30:09338 }
[email protected]d6b3af92012-09-26 19:05:12339
340 // Clear the cache now. Some of its entries could have depended on the value
341 // we are going to remove, and are now out of sync.
342 path_data->cache.clear();
343
344 path_data->overrides.erase(key);
345
346 return true;
347}
348
349// static
David Bienvenu9d6936742023-08-21 18:30:49350bool PathService::IsOverriddenForTesting(int key) {
mlcui8a86199b2020-12-03 06:41:27351 PathData* path_data = GetPathData();
352 DCHECK(path_data);
353
354 AutoLock scoped_lock(path_data->lock);
355
356 return path_data->overrides.find(key) != path_data->overrides.end();
357}
358
359// static
Peter Kasting134ef9af2024-12-28 02:30:09360void PathService::RegisterProvider(ProviderFunc func,
361 int key_start,
initial.commitd7cae122008-07-26 21:49:38362 int key_end) {
[email protected]1265917f2008-08-12 17:33:52363 PathData* path_data = GetPathData();
initial.commitd7cae122008-07-26 21:49:38364 DCHECK(path_data);
[email protected]88563f682011-03-13 22:13:33365 DCHECK_GT(key_end, key_start);
initial.commitd7cae122008-07-26 21:49:38366
initial.commitd7cae122008-07-26 21:49:38367 Provider* p;
368
initial.commitd7cae122008-07-26 21:49:38369 p = new Provider;
[email protected]173cb8a02008-08-20 15:47:39370 p->is_static = false;
initial.commitd7cae122008-07-26 21:49:38371 p->func = func;
initial.commitd7cae122008-07-26 21:49:38372#ifndef NDEBUG
373 p->key_start = key_start;
374 p->key_end = key_end;
375#endif
[email protected]d6b3af92012-09-26 19:05:12376
brettwf0dea132015-09-25 20:08:54377 AutoLock scoped_lock(path_data->lock);
[email protected]d6b3af92012-09-26 19:05:12378
379#ifndef NDEBUG
Peter Kasting134ef9af2024-12-28 02:30:09380 Provider* iter = path_data->providers;
[email protected]d6b3af92012-09-26 19:05:12381 while (iter) {
Peter Kasting134ef9af2024-12-28 02:30:09382 DCHECK(key_start >= iter->key_end || key_end <= iter->key_start)
383 << "path provider collision";
[email protected]d6b3af92012-09-26 19:05:12384 iter = iter->next;
385 }
386#endif
387
388 p->next = path_data->providers;
initial.commitd7cae122008-07-26 21:49:38389 path_data->providers = p;
390}
[email protected]c5a726b32013-01-29 00:56:56391
392// static
393void PathService::DisableCache() {
394 PathData* path_data = GetPathData();
395 DCHECK(path_data);
396
brettwf0dea132015-09-25 20:08:54397 AutoLock scoped_lock(path_data->lock);
[email protected]c5a726b32013-01-29 00:56:56398 path_data->cache.clear();
399 path_data->cache_disabled = true;
400}
brettwf0dea132015-09-25 20:08:54401
402} // namespace base