| 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 #include <unordered_map> | 
 |    8  | 
|    7 #if defined(OS_WIN) |    9 #if defined(OS_WIN) | 
|    8 #include <windows.h> |   10 #include <windows.h> | 
|    9 #include <shellapi.h> |   11 #include <shellapi.h> | 
|   10 #include <shlobj.h> |   12 #include <shlobj.h> | 
|   11 #endif |   13 #endif | 
|   12  |   14  | 
|   13 #include "base/containers/hash_tables.h" |  | 
|   14 #include "base/files/file_path.h" |   15 #include "base/files/file_path.h" | 
|   15 #include "base/files/file_util.h" |   16 #include "base/files/file_util.h" | 
|   16 #include "base/logging.h" |   17 #include "base/logging.h" | 
|   17 #include "base/synchronization/lock.h" |   18 #include "base/synchronization/lock.h" | 
|   18 #include "build/build_config.h" |   19 #include "build/build_config.h" | 
|   19  |   20  | 
|   20 namespace base { |   21 namespace base { | 
|   21  |   22  | 
|   22 bool PathProvider(int key, FilePath* result); |   23 bool PathProvider(int key, FilePath* result); | 
|   23  |   24  | 
|   24 #if defined(OS_WIN) |   25 #if defined(OS_WIN) | 
|   25 bool PathProviderWin(int key, FilePath* result); |   26 bool PathProviderWin(int key, FilePath* result); | 
|   26 #elif defined(OS_MACOSX) |   27 #elif defined(OS_MACOSX) | 
|   27 bool PathProviderMac(int key, FilePath* result); |   28 bool PathProviderMac(int key, FilePath* result); | 
|   28 #elif defined(OS_ANDROID) |   29 #elif defined(OS_ANDROID) | 
|   29 bool PathProviderAndroid(int key, FilePath* result); |   30 bool PathProviderAndroid(int key, FilePath* result); | 
|   30 #elif defined(OS_POSIX) |   31 #elif defined(OS_POSIX) | 
|   31 // PathProviderPosix is the default path provider on POSIX OSes other than |   32 // PathProviderPosix is the default path provider on POSIX OSes other than | 
|   32 // Mac and Android. |   33 // Mac and Android. | 
|   33 bool PathProviderPosix(int key, FilePath* result); |   34 bool PathProviderPosix(int key, FilePath* result); | 
|   34 #endif |   35 #endif | 
|   35  |   36  | 
|   36 namespace { |   37 namespace { | 
|   37  |   38  | 
|   38 typedef hash_map<int, FilePath> PathMap; |   39 typedef std::unordered_map<int, FilePath> PathMap; | 
|   39  |   40  | 
|   40 // We keep a linked list of providers.  In a debug build we ensure that no two |   41 // We keep a linked list of providers.  In a debug build we ensure that no two | 
|   41 // providers claim overlapping keys. |   42 // providers claim overlapping keys. | 
|   42 struct Provider { |   43 struct Provider { | 
|   43   PathService::ProviderFunc func; |   44   PathService::ProviderFunc func; | 
|   44   struct Provider* next; |   45   struct Provider* next; | 
|   45 #ifndef NDEBUG |   46 #ifndef NDEBUG | 
|   46   int key_start; |   47   int key_start; | 
|   47   int key_end; |   48   int key_end; | 
|   48 #endif |   49 #endif | 
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  320 void PathService::DisableCache() { |  321 void PathService::DisableCache() { | 
|  321   PathData* path_data = GetPathData(); |  322   PathData* path_data = GetPathData(); | 
|  322   DCHECK(path_data); |  323   DCHECK(path_data); | 
|  323  |  324  | 
|  324   AutoLock scoped_lock(path_data->lock); |  325   AutoLock scoped_lock(path_data->lock); | 
|  325   path_data->cache.clear(); |  326   path_data->cache.clear(); | 
|  326   path_data->cache_disabled = true; |  327   path_data->cache_disabled = true; | 
|  327 } |  328 } | 
|  328  |  329  | 
|  329 }  // namespace base |  330 }  // namespace base | 
| OLD | NEW |