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

Side by Side Diff: base/path_service.cc

Issue 200473002: Move all callers of GetHomeDir() to PathService::Get(base::DIR_HOME). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move subprocess homedir override to ChromeContentBrowserClient/ChromeMainDelegate Created 6 years, 8 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
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 #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 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 // fore we protect this call with a flag. 251 // fore we protect this call with a flag.
252 if (create) { 252 if (create) {
253 // Make sure the directory exists. We need to do this before we translate 253 // Make sure the directory exists. We need to do this before we translate
254 // this to the absolute path because on POSIX, MakeAbsoluteFilePath fails 254 // this to the absolute path because on POSIX, MakeAbsoluteFilePath fails
255 // if called on a non-existent path. 255 // if called on a non-existent path.
256 if (!base::PathExists(file_path) && 256 if (!base::PathExists(file_path) &&
257 !base::CreateDirectory(file_path)) 257 !base::CreateDirectory(file_path))
258 return false; 258 return false;
259 } 259 }
260 260
261 // We need to have an absolute path. 261 // File path may be already provided as absolute value so avoid calling
262 file_path = MakeAbsoluteFilePath(file_path); 262 // MakeAbsoluteFilePath() since it will fail in case of sandbox.
263 if (file_path.empty()) 263 if (!file_path.IsAbsolute()) {
264 return false; 264 // We need to have an absolute path.
265 file_path = MakeAbsoluteFilePath(file_path);
266 if (file_path.empty())
267 return false;
268 }
265 269
266 base::AutoLock scoped_lock(path_data->lock); 270 base::AutoLock scoped_lock(path_data->lock);
267 271
268 // Clear the cache now. Some of its entries could have depended 272 // Clear the cache now. Some of its entries could have depended
269 // on the value we are overriding, and are now out of sync with reality. 273 // on the value we are overriding, and are now out of sync with reality.
270 path_data->cache.clear(); 274 path_data->cache.clear();
271 275
272 path_data->overrides[key] = file_path; 276 path_data->overrides[key] = file_path;
273 277
274 return true; 278 return true;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 331
328 // static 332 // static
329 void PathService::DisableCache() { 333 void PathService::DisableCache() {
330 PathData* path_data = GetPathData(); 334 PathData* path_data = GetPathData();
331 DCHECK(path_data); 335 DCHECK(path_data);
332 336
333 base::AutoLock scoped_lock(path_data->lock); 337 base::AutoLock scoped_lock(path_data->lock);
334 path_data->cache.clear(); 338 path_data->cache.clear();
335 path_data->cache_disabled = true; 339 path_data->cache_disabled = true;
336 } 340 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698