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

Unified Diff: base/path_service.cc

Issue 3169031: Revert 56738 - Fix CheckFalseTest.CheckFails on Linux after my change to ui_t... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/path_service.h ('k') | chrome/browser/profile_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/path_service.cc
===================================================================
--- base/path_service.cc (revision 56775)
+++ base/path_service.cc (working copy)
@@ -31,6 +31,7 @@
namespace {
typedef base::hash_map<int, FilePath> PathMap;
+typedef base::hash_set<int> PathSet;
// We keep a linked list of providers. In a debug build we ensure that no two
// providers claim overlapping keys.
@@ -93,8 +94,8 @@
struct PathData {
Lock lock;
- PathMap cache; // Cache mappings from path key to path value.
- PathMap overrides; // Track path overrides.
+ PathMap cache; // Track mappings from path key to path value.
+ PathSet overrides; // Track whether a path has been overridden.
Provider* providers; // Linked list of path service providers.
PathData() {
@@ -140,20 +141,6 @@
}
// static
-bool PathService::GetFromOverrides(int key, FilePath* result) {
- PathData* path_data = GetPathData();
- AutoLock scoped_lock(path_data->lock);
-
- // check for an overriden version.
- PathMap::const_iterator it = path_data->overrides.find(key);
- if (it != path_data->overrides.end()) {
- *result = it->second;
- return true;
- }
- return false;
-}
-
-// static
void PathService::AddToCache(int key, const FilePath& path) {
PathData* path_data = GetPathData();
AutoLock scoped_lock(path_data->lock);
@@ -175,16 +162,9 @@
if (key == base::DIR_CURRENT)
return file_util::GetCurrentDirectory(result);
- if (GetFromCache(key, result)) {
- LOG(ERROR) << "Key: " << key << " returning " << result->value() << " from cache.";
+ if (GetFromCache(key, result))
return true;
- }
- if (GetFromOverrides(key, result)) {
- LOG(ERROR) << "Key: " << key << " returning " << result->value() << " from overrides.";
- return true;
- }
-
FilePath path;
// search providers for the requested path
@@ -204,7 +184,6 @@
AddToCache(key, path);
*result = path;
- LOG(ERROR) << "Key: " << key << " returning " << result->value() << ".";
return true;
}
@@ -220,6 +199,14 @@
}
#endif
+bool PathService::IsOverridden(int key) {
+ PathData* path_data = GetPathData();
+ DCHECK(path_data);
+
+ AutoLock scoped_lock(path_data->lock);
+ return path_data->overrides.find(key) != path_data->overrides.end();
+}
+
bool PathService::Override(int key, const FilePath& path) {
PathData* path_data = GetPathData();
DCHECK(path_data);
@@ -241,14 +228,8 @@
return false;
AutoLock scoped_lock(path_data->lock);
-
- // Clear the cache now. Some of its entries could have depended
- // on the value we are overriding, and are now out of sync with reality.
- path_data->cache.clear();
-
path_data->cache[key] = file_path;
- path_data->overrides[key] = file_path;
-
+ path_data->overrides.insert(key);
return true;
}
« no previous file with comments | « base/path_service.h ('k') | chrome/browser/profile_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698