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

Side by Side Diff: base/path_service.cc

Issue 146057: Making browser test work (again) on Linux (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « base/path_service.h ('k') | chrome/browser/ssl/ssl_browser_tests.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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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>
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 } 199 }
200 200
201 bool PathService::IsOverridden(int key) { 201 bool PathService::IsOverridden(int key) {
202 PathData* path_data = GetPathData(); 202 PathData* path_data = GetPathData();
203 DCHECK(path_data); 203 DCHECK(path_data);
204 204
205 AutoLock scoped_lock(path_data->lock); 205 AutoLock scoped_lock(path_data->lock);
206 return path_data->overrides.find(key) != path_data->overrides.end(); 206 return path_data->overrides.find(key) != path_data->overrides.end();
207 } 207 }
208 208
209 bool PathService::Override(int key, const std::wstring& path) { 209 bool PathService::Override(int key, const FilePath& path) {
210 PathData* path_data = GetPathData(); 210 PathData* path_data = GetPathData();
211 DCHECK(path_data); 211 DCHECK(path_data);
212 DCHECK(key > base::DIR_CURRENT) << "invalid path key"; 212 DCHECK(key > base::DIR_CURRENT) << "invalid path key";
213 213
214 std::wstring file_path = path; 214 FilePath file_path = path;
215 #if defined(OS_WIN) 215 #if defined(OS_WIN)
216 // On Windows we switch the current working directory to load plugins (at 216 // On Windows we switch the current working directory to load plugins (at
217 // least). That's not the case on POSIX. 217 // least). That's not the case on POSIX.
218 // Also, on POSIX, AbsolutePath fails if called on a non-existant path. 218 // Also, on POSIX, AbsolutePath fails if called on a non-existant path.
219 if (!file_util::AbsolutePath(&file_path)) 219 if (!file_util::AbsolutePath(&file_path))
220 return false; 220 return false;
221 #endif 221 #endif
222 222
223 // make sure the directory exists: 223 // make sure the directory exists:
224 if (!file_util::CreateDirectory(file_path)) 224 if (!file_util::PathExists(file_path) &&
225 !file_util::CreateDirectory(file_path))
225 return false; 226 return false;
226 227
227 file_util::TrimTrailingSeparator(&file_path);
228
229 AutoLock scoped_lock(path_data->lock); 228 AutoLock scoped_lock(path_data->lock);
230 path_data->cache[key] = FilePath::FromWStringHack(file_path); 229 path_data->cache[key] = file_path;
231 path_data->overrides.insert(key); 230 path_data->overrides.insert(key);
232 return true; 231 return true;
233 } 232 }
234 233
234 bool PathService::Override(int key, const std::wstring& path) {
235 return Override(key, FilePath::FromWStringHack(path));
236 }
237
235 bool PathService::SetCurrentDirectory(const std::wstring& current_directory) { 238 bool PathService::SetCurrentDirectory(const std::wstring& current_directory) {
236 return file_util::SetCurrentDirectory(current_directory); 239 return file_util::SetCurrentDirectory(current_directory);
237 } 240 }
238 241
239 void PathService::RegisterProvider(ProviderFunc func, int key_start, 242 void PathService::RegisterProvider(ProviderFunc func, int key_start,
240 int key_end) { 243 int key_end) {
241 PathData* path_data = GetPathData(); 244 PathData* path_data = GetPathData();
242 DCHECK(path_data); 245 DCHECK(path_data);
243 DCHECK(key_end > key_start); 246 DCHECK(key_end > key_start);
244 247
(...skipping 13 matching lines...) Expand all
258 p = new Provider; 261 p = new Provider;
259 p->is_static = false; 262 p->is_static = false;
260 p->func = func; 263 p->func = func;
261 p->next = path_data->providers; 264 p->next = path_data->providers;
262 #ifndef NDEBUG 265 #ifndef NDEBUG
263 p->key_start = key_start; 266 p->key_start = key_start;
264 p->key_end = key_end; 267 p->key_end = key_end;
265 #endif 268 #endif
266 path_data->providers = p; 269 path_data->providers = p;
267 } 270 }
OLDNEW
« no previous file with comments | « base/path_service.h ('k') | chrome/browser/ssl/ssl_browser_tests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698