OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "components/component_updater/component_updater_paths.h" |
| 6 |
| 7 #include "base/lazy_instance.h" |
| 8 #include "base/path_service.h" |
| 9 |
| 10 namespace component_updater { |
| 11 |
| 12 namespace { |
| 13 |
| 14 static base::LazyInstance<base::FilePath> g_components_root = |
| 15 LAZY_INSTANCE_INITIALIZER; |
| 16 |
| 17 } // namespace |
| 18 |
| 19 bool PathProvider(int key, base::FilePath* result) { |
| 20 DCHECK(!g_components_root.Get().empty()); |
| 21 base::FilePath cur = g_components_root.Get(); |
| 22 switch (key) { |
| 23 case DIR_COMPONENT_CLD2: |
| 24 cur = cur.Append(FILE_PATH_LITERAL("CLD")); |
| 25 break; |
| 26 case DIR_RECOVERY_BASE: |
| 27 cur = cur.Append(FILE_PATH_LITERAL("recovery")); |
| 28 break; |
| 29 case DIR_SWIFT_SHADER: |
| 30 cur = cur.Append(FILE_PATH_LITERAL("SwiftShader")); |
| 31 break; |
| 32 default: |
| 33 return false; |
| 34 } |
| 35 |
| 36 *result = cur; |
| 37 return true; |
| 38 } |
| 39 |
| 40 // This cannot be done as a static initializer sadly since Visual Studio will |
| 41 // eliminate this object file if there is no direct entry point into it. |
| 42 void RegisterPathProvider(const base::FilePath& components_root) { |
| 43 DCHECK(g_components_root.Get().empty()); |
| 44 DCHECK(!components_root.empty()); |
| 45 g_components_root.Get() = components_root; |
| 46 |
| 47 PathService::RegisterProvider(PathProvider, PATH_START, PATH_END); |
| 48 } |
| 49 |
| 50 } // namespace component_updater |
OLD | NEW |