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/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 if (g_components_root.Get().empty()) { | |
| 21 NOTREACHED(); | |
|
Lei Zhang
2014/07/01 00:23:29
Just DCHECK instead of handling?
tommycli
2014/07/01 00:28:56
Done.
| |
| 22 return false; | |
| 23 } | |
| 24 | |
| 25 base::FilePath cur = g_components_root.Get(); | |
| 26 switch (key) { | |
| 27 case DIR_COMPONENT_CLD2: | |
| 28 cur = cur.Append(FILE_PATH_LITERAL("CLD")); | |
| 29 break; | |
| 30 case DIR_RECOVERY_BASE: | |
| 31 cur = cur.Append(FILE_PATH_LITERAL("recovery")); | |
| 32 break; | |
| 33 case DIR_SWIFT_SHADER: | |
| 34 cur = cur.Append(FILE_PATH_LITERAL("SwiftShader")); | |
| 35 break; | |
| 36 default: | |
| 37 return false; | |
| 38 } | |
| 39 | |
| 40 *result = cur; | |
| 41 return true; | |
| 42 } | |
| 43 | |
| 44 // This cannot be done as a static initializer sadly since Visual Studio will | |
| 45 // eliminate this object file if there is no direct entry point into it. | |
| 46 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.
| |
| 47 DCHECK(g_components_root.Get().empty()); | |
| 48 DCHECK(!components_root.empty()); | |
| 49 g_components_root.Get() = components_root; | |
| 50 | |
| 51 PathService::RegisterProvider(PathProvider, PATH_START, PATH_END); | |
| 52 } | |
| 53 | |
| 54 } // namespace component_updater | |
| OLD | NEW |