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

Unified Diff: base/path_service.cc

Issue 10909228: Add PathService::RemoveOverride to clear path overrides. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 3 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
Index: base/path_service.cc
diff --git a/base/path_service.cc b/base/path_service.cc
index a3b882c2a9e8f76f668ed71b8549706059aecf51..3dbeed54eb3bb165d5e56a176c6b7d14856c6aa4 100644
--- a/base/path_service.cc
+++ b/base/path_service.cc
@@ -221,11 +221,13 @@ bool PathService::Get(int key, FilePath* result) {
return true;
}
+// static
jar (doing other things) 2012/09/15 02:01:20 I personally like this style... but it is a gratui
pastarmovj 2012/09/17 16:30:40 Actually the file is already mixed style (see line
bool PathService::Override(int key, const FilePath& path) {
// Just call the full function with true for the value of |create|.
return OverrideAndCreateIfNeeded(key, path, true);
}
+// static
bool PathService::OverrideAndCreateIfNeeded(int key,
const FilePath& path,
bool create) {
@@ -264,6 +266,26 @@ bool PathService::OverrideAndCreateIfNeeded(int key,
return true;
}
+// static
+bool PathService::RemoveOverride(int key) {
+ PathData* path_data = GetPathData();
+ DCHECK(path_data);
+
+ base::AutoLock scoped_lock(path_data->lock);
+
+ if (path_data->overrides.find(key) == path_data->overrides.end())
+ return false;
+
+ // Clear the cache now. Some of its entries could have depended on the value
+ // we are going to remove, and are now out of sync.
+ path_data->cache.clear();
+
+ path_data->overrides.erase(key);
+
+ return true;
+}
+
+// static
void PathService::RegisterProvider(ProviderFunc func, int key_start,
int key_end) {
PathData* path_data = GetPathData();
« base/path_service.h ('K') | « base/path_service.h ('k') | base/path_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698