Chromium Code Reviews| 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/common/component_updater_paths.h" | |
| 6 | |
| 7 #include "base/lazy_instance.h" | |
| 8 #include "base/path_service.h" | |
| 9 #include "components/component_updater/common/component_updater_constants.h" | |
| 10 | |
| 11 namespace component_updater { | |
| 12 | |
| 13 namespace { | |
| 14 | |
| 15 static base::LazyInstance<base::FilePath> g_components_root = | |
| 16 LAZY_INSTANCE_INITIALIZER; | |
| 17 | |
| 18 } // namespace | |
| 19 | |
| 20 bool PathProvider(int key, base::FilePath* result) { | |
| 21 if (g_components_root.Get().empty()) { | |
| 22 NOTREACHED(); | |
| 23 return false; | |
| 24 } | |
| 25 | |
| 26 base::FilePath cur = g_components_root.Get(); | |
| 27 switch (key) { | |
| 28 case DIR_COMPONENT_CLD2: | |
| 29 cur = cur.Append(kCLDDataFilename); | |
| 30 break; | |
| 31 case DIR_RECOVERY_BASE: | |
| 32 cur = cur.Append(FILE_PATH_LITERAL("recovery")); | |
| 33 break; | |
| 34 case DIR_SWIFT_SHADER: | |
| 35 cur = cur.Append(FILE_PATH_LITERAL("SwiftShader")); | |
| 36 break; | |
| 37 default: | |
| 38 return false; | |
| 39 } | |
| 40 | |
| 41 *result = cur; | |
| 42 return true; | |
| 43 } | |
| 44 | |
| 45 // This cannot be done as a static initializer sadly since Visual Studio will | |
| 46 // eliminate this object file if there is no direct entry point into it. | |
| 47 void RegisterPathProvider(const base::FilePath& components_root) { | |
|
tommycli
2014/06/27 17:48:12
Are we okay with this path provider needing a root
Sorin Jianu
2014/06/30 22:27:53
No idea, I don't know how these providers work.
tommycli
2014/07/01 00:03:04
No problem, I'll ask thestig to take a second look
| |
| 48 DCHECK(g_components_root.Get().empty()); | |
| 49 DCHECK(!components_root.empty()); | |
| 50 g_components_root.Get() = components_root; | |
| 51 | |
| 52 PathService::RegisterProvider(PathProvider, PATH_START, PATH_END); | |
| 53 } | |
| 54 | |
| 55 } // namespace component_updater | |
| OLD | NEW |