Chromium Code Reviews| Index: components/component_updater/component_updater_paths.cc |
| diff --git a/components/component_updater/component_updater_paths.cc b/components/component_updater/component_updater_paths.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..f2aa3aead2004da488e961c0bcfa92852ff4ab00 |
| --- /dev/null |
| +++ b/components/component_updater/component_updater_paths.cc |
| @@ -0,0 +1,54 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "components/component_updater/component_updater_paths.h" |
| + |
| +#include "base/lazy_instance.h" |
| +#include "base/path_service.h" |
| + |
| +namespace component_updater { |
| + |
| +namespace { |
| + |
| +static base::LazyInstance<base::FilePath> g_components_root = |
| + LAZY_INSTANCE_INITIALIZER; |
| + |
| +} // namespace |
| + |
| +bool PathProvider(int key, base::FilePath* result) { |
| + if (g_components_root.Get().empty()) { |
| + NOTREACHED(); |
|
Lei Zhang
2014/07/01 00:23:29
Just DCHECK instead of handling?
tommycli
2014/07/01 00:28:56
Done.
|
| + return false; |
| + } |
| + |
| + base::FilePath cur = g_components_root.Get(); |
| + switch (key) { |
| + case DIR_COMPONENT_CLD2: |
| + cur = cur.Append(FILE_PATH_LITERAL("CLD")); |
| + break; |
| + case DIR_RECOVERY_BASE: |
| + cur = cur.Append(FILE_PATH_LITERAL("recovery")); |
| + break; |
| + case DIR_SWIFT_SHADER: |
| + cur = cur.Append(FILE_PATH_LITERAL("SwiftShader")); |
| + break; |
| + default: |
| + return false; |
| + } |
| + |
| + *result = cur; |
| + return true; |
| +} |
| + |
| +// 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) { |
|
tommycli
2014/07/01 00:05:36
Does this look reasonable? Since the component pat
Lei Zhang
2014/07/01 00:23:29
Seems reasonable.
tommycli
2014/07/01 00:28:56
Done.
|
| + DCHECK(g_components_root.Get().empty()); |
| + DCHECK(!components_root.empty()); |
| + g_components_root.Get() = components_root; |
| + |
| + PathService::RegisterProvider(PathProvider, PATH_START, PATH_END); |
| +} |
| + |
| +} // namespace component_updater |