summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvitalybuka@chromium.org <vitalybuka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-29 00:56:56 +0000
committervitalybuka@chromium.org <vitalybuka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-29 00:56:56 +0000
commitc5a726b3541cdb5ab7e4f90da45c9bbbd3f6b4d3 (patch)
treeb2564d1f3895e5c857bde6c13d54d828e39c3a51
parentd239230b4be699a6e1e124e761b585692d54e140 (diff)
downloadchromium_src-c5a726b3541cdb5ab7e4f90da45c9bbbd3f6b4d3.zip
chromium_src-c5a726b3541cdb5ab7e4f90da45c9bbbd3f6b4d3.tar.gz
chromium_src-c5a726b3541cdb5ab7e4f90da45c9bbbd3f6b4d3.tar.bz2
Disable cache in PathService.
Google Cloud Printer implements port monitor. It's DLL that loaded into windows Spooler service (spoolsv.exe). Port monitor saves printed document to temp file and then runs Chrome.exe to send this file to cloud print. spoolsv.exe always runs as SYSTEM, but threads that call port monitor is executed as user, that spooled print jobs. Port monitor should be able to find Chrome.exe for different user. Now port monitor uses chrome_launcher_support::GetAnyChromePath(), which uses PathService, is to find chrome. If cache is enabled, port monitor will always use paths generated for the first users. BUG=170300 Review URL: https://chromiumcodereview.appspot.com/12079030 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@179234 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/path_service.cc21
-rw-r--r--base/path_service.h3
-rw-r--r--cloud_print/virtual_driver/win/port_monitor/port_monitor.cc2
3 files changed, 23 insertions, 3 deletions
diff --git a/base/path_service.cc b/base/path_service.cc
index aa53b0d..a19e78d 100644
--- a/base/path_service.cc
+++ b/base/path_service.cc
@@ -112,8 +112,9 @@ struct PathData {
PathMap cache; // Cache mappings from path key to path value.
PathMap overrides; // Track path overrides.
Provider* providers; // Linked list of path service providers.
+ bool cache_disabled; // Don't use cache if true;
- PathData() {
+ PathData() : cache_disabled(false) {
#if defined(OS_WIN)
providers = &base_provider_win;
#elif defined(OS_MACOSX)
@@ -144,6 +145,8 @@ static PathData* GetPathData() {
// Tries to find |key| in the cache. |path_data| should be locked by the caller!
bool LockedGetFromCache(int key, const PathData* path_data, FilePath* result) {
+ if (path_data->cache_disabled)
+ return false;
// check for a cached version
PathMap::const_iterator it = path_data->cache.find(key);
if (it != path_data->cache.end()) {
@@ -159,7 +162,8 @@ bool LockedGetFromOverrides(int key, PathData* path_data, FilePath* result) {
// check for an overridden version.
PathMap::const_iterator it = path_data->overrides.find(key);
if (it != path_data->overrides.end()) {
- path_data->cache[key] = it->second;
+ if (!path_data->cache_disabled)
+ path_data->cache[key] = it->second;
*result = it->second;
return true;
}
@@ -218,7 +222,8 @@ bool PathService::Get(int key, FilePath* result) {
*result = path;
base::AutoLock scoped_lock(path_data->lock);
- path_data->cache[key] = path;
+ if (!path_data->cache_disabled)
+ path_data->cache[key] = path;
return true;
}
@@ -317,3 +322,13 @@ void PathService::RegisterProvider(ProviderFunc func, int key_start,
p->next = path_data->providers;
path_data->providers = p;
}
+
+// static
+void PathService::DisableCache() {
+ PathData* path_data = GetPathData();
+ DCHECK(path_data);
+
+ base::AutoLock scoped_lock(path_data->lock);
+ path_data->cache.clear();
+ path_data->cache_disabled = true;
+}
diff --git a/base/path_service.h b/base/path_service.h
index 94b0db3..8a7defe 100644
--- a/base/path_service.h
+++ b/base/path_service.h
@@ -67,6 +67,9 @@ class BASE_EXPORT PathService {
int key_start,
int key_end);
+ // Disable internal cache.
+ static void DisableCache();
+
private:
friend class base::ScopedPathOverride;
FRIEND_TEST_ALL_PREFIXES(PathServiceTest, RemoveOverride);
diff --git a/cloud_print/virtual_driver/win/port_monitor/port_monitor.cc b/cloud_print/virtual_driver/win/port_monitor/port_monitor.cc
index ba6b959..0f99033 100644
--- a/cloud_print/virtual_driver/win/port_monitor/port_monitor.cc
+++ b/cloud_print/virtual_driver/win/port_monitor/port_monitor.cc
@@ -614,6 +614,8 @@ MONITOR2* WINAPI InitializePrintMonitor2(MONITORINIT*,
if (!cloud_print::kIsUnittest) {
// Unit tests set up their own AtExitManager
monitor_data->at_exit_manager = new base::AtExitManager();
+ // Single spooler.exe handles all users.
+ PathService::DisableCache();
}
} else {
SetLastError(ERROR_INVALID_PARAMETER);