summaryrefslogtreecommitdiffstats
path: root/components/component_updater/component_updater_paths.cc
diff options
context:
space:
mode:
authortommycli@chromium.org <tommycli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-08 14:17:00 +0000
committertommycli@chromium.org <tommycli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-08 14:17:00 +0000
commit6c0c9736ddcd8a677414f64a270b5a48a9bc5705 (patch)
tree2dd896a715fa55f90ed85f69f4b1b9f3274c5206 /components/component_updater/component_updater_paths.cc
parent44c8cc8bc2a354669c80714ad1426d2a2156843c (diff)
downloadchromium_src-6c0c9736ddcd8a677414f64a270b5a48a9bc5705.zip
chromium_src-6c0c9736ddcd8a677414f64a270b5a48a9bc5705.tar.gz
chromium_src-6c0c9736ddcd8a677414f64a270b5a48a9bc5705.tar.bz2
Break some of the chrome/common dependencies in implementation by moving some paths and constants to the component.
Design doc: https://docs.google.com/document/d/1F76yNZCnPnGzgNXhI-sCFKlXulwx_s_OKTGbJS5NhbA/edit?usp=sharing BUG=371463 Review URL: https://codereview.chromium.org/334783002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@281744 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'components/component_updater/component_updater_paths.cc')
-rw-r--r--components/component_updater/component_updater_paths.cc50
1 files changed, 50 insertions, 0 deletions
diff --git a/components/component_updater/component_updater_paths.cc b/components/component_updater/component_updater_paths.cc
new file mode 100644
index 0000000..62f484b
--- /dev/null
+++ b/components/component_updater/component_updater_paths.cc
@@ -0,0 +1,50 @@
+// 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) {
+ DCHECK(!g_components_root.Get().empty());
+ 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) {
+ 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