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..62f484b6afc2c0b6da1967567cb1ebfeffea0bef |
--- /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 |