OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/arc/arc_util.h" | 5 #include "components/arc/arc_util.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "ash/shared/app_types.h" | 9 #include "ash/shared/app_types.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/feature_list.h" | 11 #include "base/feature_list.h" |
12 #include "chromeos/chromeos_switches.h" | 12 #include "chromeos/chromeos_switches.h" |
| 13 #include "chromeos/dbus/dbus_thread_manager.h" |
| 14 #include "chromeos/dbus/session_manager_client.h" |
13 #include "components/user_manager/user_manager.h" | 15 #include "components/user_manager/user_manager.h" |
14 #include "ui/aura/client/aura_constants.h" | 16 #include "ui/aura/client/aura_constants.h" |
15 #include "ui/aura/window.h" | 17 #include "ui/aura/window.h" |
16 | 18 |
17 namespace arc { | 19 namespace arc { |
18 | 20 |
19 namespace { | 21 namespace { |
20 | 22 |
21 // This is for finch. See also crbug.com/633704 for details. | 23 // This is for finch. See also crbug.com/633704 for details. |
22 // TODO(hidehiko): More comments of the intention how this works, when | 24 // TODO(hidehiko): More comments of the intention how this works, when |
23 // we unify the commandline flags. | 25 // we unify the commandline flags. |
24 const base::Feature kEnableArcFeature{"EnableARC", | 26 const base::Feature kEnableArcFeature{"EnableARC", |
25 base::FEATURE_DISABLED_BY_DEFAULT}; | 27 base::FEATURE_DISABLED_BY_DEFAULT}; |
26 | 28 |
27 // Possible values for --arc-availability flag. | 29 // Possible values for --arc-availability flag. |
28 constexpr char kAvailabilityNone[] = "none"; | 30 constexpr char kAvailabilityNone[] = "none"; |
29 constexpr char kAvailabilityInstalled[] = "installed"; | 31 constexpr char kAvailabilityInstalled[] = "installed"; |
30 constexpr char kAvailabilityOfficiallySupported[] = "officially-supported"; | 32 constexpr char kAvailabilityOfficiallySupported[] = "officially-supported"; |
31 | 33 |
| 34 void SetArcCpuRestrictionCallback(bool success) { |
| 35 VLOG(2) << "Finished prioritizing the instance: result=" << success; |
| 36 if (!success) |
| 37 LOG(ERROR) << "Failed to prioritize ARC"; |
| 38 } |
| 39 |
32 } // namespace | 40 } // namespace |
33 | 41 |
34 bool IsArcAvailable() { | 42 bool IsArcAvailable() { |
35 const auto* command_line = base::CommandLine::ForCurrentProcess(); | 43 const auto* command_line = base::CommandLine::ForCurrentProcess(); |
36 | 44 |
37 if (command_line->HasSwitch(chromeos::switches::kArcAvailability)) { | 45 if (command_line->HasSwitch(chromeos::switches::kArcAvailability)) { |
38 std::string value = command_line->GetSwitchValueASCII( | 46 std::string value = command_line->GetSwitchValueASCII( |
39 chromeos::switches::kArcAvailability); | 47 chromeos::switches::kArcAvailability); |
40 DCHECK(value == kAvailabilityNone || value == kAvailabilityInstalled || | 48 DCHECK(value == kAvailabilityNone || value == kAvailabilityInstalled || |
41 value == kAvailabilityOfficiallySupported) | 49 value == kAvailabilityOfficiallySupported) |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 chromeos::switches::kDisableArcOptInVerification); | 106 chromeos::switches::kDisableArcOptInVerification); |
99 } | 107 } |
100 | 108 |
101 bool IsArcAppWindow(aura::Window* window) { | 109 bool IsArcAppWindow(aura::Window* window) { |
102 if (!window) | 110 if (!window) |
103 return false; | 111 return false; |
104 return window->GetProperty(aura::client::kAppType) == | 112 return window->GetProperty(aura::client::kAppType) == |
105 static_cast<int>(ash::AppType::ARC_APP); | 113 static_cast<int>(ash::AppType::ARC_APP); |
106 } | 114 } |
107 | 115 |
| 116 void PrioritizeArcContainer() { |
| 117 VLOG(2) << "Prioritizing the instance"; |
| 118 chromeos::SessionManagerClient* session_manager_client = |
| 119 chromeos::DBusThreadManager::Get()->GetSessionManagerClient(); |
| 120 session_manager_client->SetArcCpuRestriction( |
| 121 login_manager::CONTAINER_CPU_RESTRICTION_FOREGROUND, |
| 122 base::Bind(SetArcCpuRestrictionCallback)); |
| 123 } |
| 124 |
108 } // namespace arc | 125 } // namespace arc |
OLD | NEW |