diff options
author | tommycli@chromium.org <tommycli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-08-09 05:42:37 +0000 |
---|---|---|
committer | tommycli@chromium.org <tommycli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-08-09 05:43:39 +0000 |
commit | c376cae9ec4d7a9fea0e026b98f318131409a255 (patch) | |
tree | 2b9bc9b14011233d03923c38a6aca9fb752dd39a /components/component_updater/component_updater_paths.cc | |
parent | 60dfcb7f066a319d39eca43e793cef6becd765d0 (diff) | |
download | chromium_src-c376cae9ec4d7a9fea0e026b98f318131409a255.zip chromium_src-c376cae9ec4d7a9fea0e026b98f318131409a255.tar.gz chromium_src-c376cae9ec4d7a9fea0e026b98f318131409a255.tar.bz2 |
Componentize component_updater: Fix bug where components disrespect --user-data-dir flag.
BUG=399993
TBR=blundell
Review URL: https://codereview.chromium.org/447303002
Cr-Commit-Position: refs/heads/master@{#288514}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@288514 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'components/component_updater/component_updater_paths.cc')
-rw-r--r-- | components/component_updater/component_updater_paths.cc | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/components/component_updater/component_updater_paths.cc b/components/component_updater/component_updater_paths.cc index bf9f4d3..ca36c17 100644 --- a/components/component_updater/component_updater_paths.cc +++ b/components/component_updater/component_updater_paths.cc @@ -11,14 +11,23 @@ namespace component_updater { namespace { -static base::LazyInstance<base::FilePath> g_components_root = - LAZY_INSTANCE_INITIALIZER; +// This key gives the root directory of all the component installations. +static int g_components_root_key = -1; } // namespace bool PathProvider(int key, base::FilePath* result) { - DCHECK(!g_components_root.Get().empty()); - base::FilePath cur = g_components_root.Get(); + DCHECK_GT(g_components_root_key, 0); + + // Early exit here to prevent a potential infinite loop when we retrieve + // the path for g_components_root_key. + if (key < PATH_START || key > PATH_END) + return false; + + base::FilePath cur; + if (!PathService::Get(g_components_root_key, &cur)) + return false; + switch (key) { case DIR_COMPONENT_CLD2: cur = cur.Append(FILE_PATH_LITERAL("CLD")); @@ -42,11 +51,12 @@ bool PathProvider(int key, base::FilePath* result) { // This cannot be done as a static initializer sadly since Visual Studio will // eliminate this object file if there is no direct entry point into it. -void RegisterPathProvider(const base::FilePath& components_root) { - DCHECK(g_components_root.Get().empty()); - DCHECK(!components_root.empty()); - g_components_root.Get() = components_root; +void RegisterPathProvider(int components_root_key) { + DCHECK_EQ(g_components_root_key, -1); + DCHECK_GT(components_root_key, 0); + DCHECK(components_root_key < PATH_START || components_root_key > PATH_END); + g_components_root_key = components_root_key; PathService::RegisterProvider(PathProvider, PATH_START, PATH_END); } |