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 #if defined(OS_WIN) | 7 #if defined(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> |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 #if defined(OS_WIN) | 119 #if defined(OS_WIN) |
120 providers = &base_provider_win; | 120 providers = &base_provider_win; |
121 #elif defined(OS_MACOSX) | 121 #elif defined(OS_MACOSX) |
122 providers = &base_provider_mac; | 122 providers = &base_provider_mac; |
123 #elif defined(OS_ANDROID) | 123 #elif defined(OS_ANDROID) |
124 providers = &base_provider_android; | 124 providers = &base_provider_android; |
125 #elif defined(OS_POSIX) | 125 #elif defined(OS_POSIX) |
126 providers = &base_provider_posix; | 126 providers = &base_provider_posix; |
127 #endif | 127 #endif |
128 } | 128 } |
129 | |
130 ~PathData() { | |
131 Provider* p = providers; | |
132 while (p) { | |
133 Provider* next = p->next; | |
134 if (!p->is_static) | |
135 delete p; | |
136 p = next; | |
137 } | |
138 } | |
139 }; | 129 }; |
140 | 130 |
141 static LazyInstance<PathData> g_path_data = LAZY_INSTANCE_INITIALIZER; | 131 static LazyInstance<PathData>::Leaky g_path_data = LAZY_INSTANCE_INITIALIZER; |
142 | 132 |
143 static PathData* GetPathData() { | 133 static PathData* GetPathData() { |
144 return g_path_data.Pointer(); | 134 return g_path_data.Pointer(); |
145 } | 135 } |
146 | 136 |
147 // Tries to find |key| in the cache. |path_data| should be locked by the caller! | 137 // Tries to find |key| in the cache. |path_data| should be locked by the caller! |
148 bool LockedGetFromCache(int key, const PathData* path_data, FilePath* result) { | 138 bool LockedGetFromCache(int key, const PathData* path_data, FilePath* result) { |
149 if (path_data->cache_disabled) | 139 if (path_data->cache_disabled) |
150 return false; | 140 return false; |
151 // check for a cached version | 141 // check for a cached version |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 void PathService::DisableCache() { | 321 void PathService::DisableCache() { |
332 PathData* path_data = GetPathData(); | 322 PathData* path_data = GetPathData(); |
333 DCHECK(path_data); | 323 DCHECK(path_data); |
334 | 324 |
335 AutoLock scoped_lock(path_data->lock); | 325 AutoLock scoped_lock(path_data->lock); |
336 path_data->cache.clear(); | 326 path_data->cache.clear(); |
337 path_data->cache_disabled = true; | 327 path_data->cache_disabled = true; |
338 } | 328 } |
339 | 329 |
340 } // namespace base | 330 } // namespace base |
OLD | NEW |