[M120 Migration][VD] Enable direct rendering for TVPlus
[platform/framework/web/chromium-efl.git] / components / component_updater / component_updater_paths.cc
1 // Copyright 2014 The Chromium Authors
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/files/file_path.h"
8 #include "base/lazy_instance.h"
9 #include "base/path_service.h"
10
11 namespace component_updater {
12
13 namespace {
14
15 // This key gives the root directory of all the component installations.
16 static int g_components_preinstalled_root_key = -1;
17 static int g_components_preinstalled_root_key_alt = -1;
18 static int g_components_user_root_key = -1;
19
20 }  // namespace
21
22 bool PathProvider(int key, base::FilePath* result) {
23   DCHECK_GT(g_components_user_root_key, 0);
24   DCHECK_GT(g_components_preinstalled_root_key, 0);
25
26   // Early exit here to prevent a potential infinite loop when we retrieve
27   // the path for g_components_*_root_key.
28   if (key < PATH_START || key > PATH_END)
29     return false;
30
31   switch (key) {
32     case DIR_COMPONENT_PREINSTALLED:
33       return base::PathService::Get(g_components_preinstalled_root_key, result);
34     case DIR_COMPONENT_PREINSTALLED_ALT:
35       return base::PathService::Get(g_components_preinstalled_root_key_alt,
36                                     result);
37     case DIR_COMPONENT_USER:
38       return base::PathService::Get(g_components_user_root_key, result);
39   }
40
41   base::FilePath cur;
42   if (!base::PathService::Get(g_components_user_root_key, &cur))
43     return false;
44
45   switch (key) {
46     case DIR_COMPONENT_CLD2:
47       cur = cur.Append(FILE_PATH_LITERAL("CLD"));
48       break;
49     case DIR_RECOVERY_BASE:
50       cur = cur.Append(FILE_PATH_LITERAL("recovery"));
51       break;
52     case DIR_SWIFT_SHADER:
53       cur = cur.Append(FILE_PATH_LITERAL("SwiftShader"));
54       break;
55     default:
56       return false;
57   }
58
59   *result = cur;
60   return true;
61 }
62
63 // This cannot be done as a static initializer sadly since Visual Studio will
64 // eliminate this object file if there is no direct entry point into it.
65 void RegisterPathProvider(int components_preinstalled_root_key,
66                           int components_preinstalled_root_key_alt,
67                           int components_user_root_key) {
68   DCHECK_EQ(g_components_preinstalled_root_key, -1);
69   DCHECK_EQ(g_components_preinstalled_root_key_alt, -1);
70   DCHECK_EQ(g_components_user_root_key, -1);
71   DCHECK_GT(components_preinstalled_root_key, 0);
72   DCHECK_GT(components_preinstalled_root_key_alt, 0);
73   DCHECK_GT(components_user_root_key, 0);
74   DCHECK(components_preinstalled_root_key < PATH_START ||
75          components_preinstalled_root_key > PATH_END);
76   DCHECK(components_preinstalled_root_key_alt < PATH_START ||
77          components_preinstalled_root_key_alt > PATH_END);
78   DCHECK(components_user_root_key < PATH_START ||
79          components_user_root_key > PATH_END);
80
81   g_components_preinstalled_root_key = components_preinstalled_root_key;
82   g_components_preinstalled_root_key_alt = components_preinstalled_root_key_alt;
83   g_components_user_root_key = components_user_root_key;
84   base::PathService::RegisterProvider(PathProvider, PATH_START, PATH_END);
85 }
86
87 }  // namespace component_updater