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.
5 #include "components/component_updater/component_updater_paths.h"
7 #include "base/lazy_instance.h"
8 #include "base/path_service.h"
10 namespace component_updater
{
14 // This key gives the root directory of all the component installations.
15 static int g_components_root_key
= -1;
19 bool PathProvider(int key
, base::FilePath
* result
) {
20 DCHECK_GT(g_components_root_key
, 0);
22 // Early exit here to prevent a potential infinite loop when we retrieve
23 // the path for g_components_root_key.
24 if (key
< PATH_START
|| key
> PATH_END
)
28 if (!PathService::Get(g_components_root_key
, &cur
))
32 case DIR_COMPONENT_CLD2
:
33 cur
= cur
.Append(FILE_PATH_LITERAL("CLD"));
35 case DIR_RECOVERY_BASE
:
36 cur
= cur
.Append(FILE_PATH_LITERAL("recovery"));
38 case DIR_SWIFT_SHADER
:
39 cur
= cur
.Append(FILE_PATH_LITERAL("SwiftShader"));
42 cur
= cur
.Append(FILE_PATH_LITERAL("SwReporter"));
44 case DIR_COMPONENT_EV_WHITELIST
:
45 cur
= cur
.Append(FILE_PATH_LITERAL("EVWhitelist"));
55 // This cannot be done as a static initializer sadly since Visual Studio will
56 // eliminate this object file if there is no direct entry point into it.
57 void RegisterPathProvider(int components_root_key
) {
58 DCHECK_EQ(g_components_root_key
, -1);
59 DCHECK_GT(components_root_key
, 0);
60 DCHECK(components_root_key
< PATH_START
|| components_root_key
> PATH_END
);
62 g_components_root_key
= components_root_key
;
63 PathService::RegisterProvider(PathProvider
, PATH_START
, PATH_END
);
66 } // namespace component_updater