Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: base/path_service.cc

Issue 2907473002: fuchsia: add base_paths_fuchsia.cc (Closed)
Patch Set: rebase Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/base_paths_posix.cc ('k') | base/path_service_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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> 7 #include <unordered_map>
8 8
9 #if defined(OS_WIN) 9 #if defined(OS_WIN)
10 #include <windows.h> 10 #include <windows.h>
(...skipping 10 matching lines...) Expand all
21 namespace base { 21 namespace base {
22 22
23 bool PathProvider(int key, FilePath* result); 23 bool PathProvider(int key, FilePath* result);
24 24
25 #if defined(OS_WIN) 25 #if defined(OS_WIN)
26 bool PathProviderWin(int key, FilePath* result); 26 bool PathProviderWin(int key, FilePath* result);
27 #elif defined(OS_MACOSX) 27 #elif defined(OS_MACOSX)
28 bool PathProviderMac(int key, FilePath* result); 28 bool PathProviderMac(int key, FilePath* result);
29 #elif defined(OS_ANDROID) 29 #elif defined(OS_ANDROID)
30 bool PathProviderAndroid(int key, FilePath* result); 30 bool PathProviderAndroid(int key, FilePath* result);
31 #elif defined(OS_FUCHSIA)
32 bool PathProviderFuchsia(int key, FilePath* result);
31 #elif defined(OS_POSIX) 33 #elif defined(OS_POSIX)
32 // PathProviderPosix is the default path provider on POSIX OSes other than 34 // PathProviderPosix is the default path provider on POSIX OSes other than
33 // Mac and Android. 35 // Mac and Android.
34 bool PathProviderPosix(int key, FilePath* result); 36 bool PathProviderPosix(int key, FilePath* result);
35 #endif 37 #endif
36 38
37 namespace { 39 namespace {
38 40
39 typedef std::unordered_map<int, FilePath> PathMap; 41 typedef std::unordered_map<int, FilePath> PathMap;
40 42
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 PathProviderAndroid, 91 PathProviderAndroid,
90 &base_provider, 92 &base_provider,
91 #ifndef NDEBUG 93 #ifndef NDEBUG
92 PATH_ANDROID_START, 94 PATH_ANDROID_START,
93 PATH_ANDROID_END, 95 PATH_ANDROID_END,
94 #endif 96 #endif
95 true 97 true
96 }; 98 };
97 #endif 99 #endif
98 100
99 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) 101 #if defined(OS_FUCHSIA)
102 Provider base_provider_fuchsia = {PathProviderFuchsia, &base_provider,
103 #ifndef NDEBUG
104 0, 0,
105 #endif
106 true};
107 #endif
108
109 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) && \
110 !defined(OS_FUCHSIA)
100 Provider base_provider_posix = { 111 Provider base_provider_posix = {
101 PathProviderPosix, 112 PathProviderPosix,
102 &base_provider, 113 &base_provider,
103 #ifndef NDEBUG 114 #ifndef NDEBUG
104 PATH_POSIX_START, 115 PATH_POSIX_START,
105 PATH_POSIX_END, 116 PATH_POSIX_END,
106 #endif 117 #endif
107 true 118 true
108 }; 119 };
109 #endif 120 #endif
110 121
111 122
112 struct PathData { 123 struct PathData {
113 Lock lock; 124 Lock lock;
114 PathMap cache; // Cache mappings from path key to path value. 125 PathMap cache; // Cache mappings from path key to path value.
115 PathMap overrides; // Track path overrides. 126 PathMap overrides; // Track path overrides.
116 Provider* providers; // Linked list of path service providers. 127 Provider* providers; // Linked list of path service providers.
117 bool cache_disabled; // Don't use cache if true; 128 bool cache_disabled; // Don't use cache if true;
118 129
119 PathData() : cache_disabled(false) { 130 PathData() : cache_disabled(false) {
120 #if defined(OS_WIN) 131 #if defined(OS_WIN)
121 providers = &base_provider_win; 132 providers = &base_provider_win;
122 #elif defined(OS_MACOSX) 133 #elif defined(OS_MACOSX)
123 providers = &base_provider_mac; 134 providers = &base_provider_mac;
124 #elif defined(OS_ANDROID) 135 #elif defined(OS_ANDROID)
125 providers = &base_provider_android; 136 providers = &base_provider_android;
137 #elif defined(OS_FUCHSIA)
138 providers = &base_provider_fuchsia;
126 #elif defined(OS_POSIX) 139 #elif defined(OS_POSIX)
127 providers = &base_provider_posix; 140 providers = &base_provider_posix;
128 #endif 141 #endif
129 } 142 }
130 }; 143 };
131 144
132 static PathData* GetPathData() { 145 static PathData* GetPathData() {
133 static auto* path_data = new PathData(); 146 static auto* path_data = new PathData();
134 return path_data; 147 return path_data;
135 } 148 }
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 void PathService::DisableCache() { 334 void PathService::DisableCache() {
322 PathData* path_data = GetPathData(); 335 PathData* path_data = GetPathData();
323 DCHECK(path_data); 336 DCHECK(path_data);
324 337
325 AutoLock scoped_lock(path_data->lock); 338 AutoLock scoped_lock(path_data->lock);
326 path_data->cache.clear(); 339 path_data->cache.clear();
327 path_data->cache_disabled = true; 340 path_data->cache_disabled = true;
328 } 341 }
329 342
330 } // namespace base 343 } // namespace base
OLDNEW
« no previous file with comments | « base/base_paths_posix.cc ('k') | base/path_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698