Chromium Code Reviews| Index: chrome/browser/task_manager/providers/arc/arc_process_whitelist.cc |
| diff --git a/chrome/browser/task_manager/providers/arc/arc_process_whitelist.cc b/chrome/browser/task_manager/providers/arc/arc_process_whitelist.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..d4903461debf8574d6d705c655534a85b1f5bf5c |
| --- /dev/null |
| +++ b/chrome/browser/task_manager/providers/arc/arc_process_whitelist.cc |
| @@ -0,0 +1,41 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/task_manager/providers/arc/arc_process_whitelist.h" |
| + |
| +#include "components/arc/common/process.mojom.h" |
| + |
| +namespace task_manager { |
| + |
| +namespace { |
| + |
| +const char* kDefaultWhitelist[] = {"/system/bin/surfaceflinger"}; |
| +} |
|
Luis Héctor Chávez
2017/01/24 17:09:41
nit: // namespace
(also, add a blank line above).
Eliot Courtney
2017/01/25 02:08:12
Done.
|
| + |
| +ArcProcessWhitelist::ArcProcessWhitelist() |
| + : whitelist_(std::begin(kDefaultWhitelist), std::end(kDefaultWhitelist)) {} |
| + |
| +ArcProcessWhitelist::ArcProcessWhitelist(std::set<std::string>&& whitelist) |
| + : whitelist_(whitelist) {} |
| + |
| +ArcProcessWhitelist::~ArcProcessWhitelist() = default; |
| + |
| +bool ArcProcessWhitelist::ShouldDisplayProcess( |
| + const arc::ArcProcess& process) const { |
| + // Check the explicit whitelist. If it is not in there, decide based on its |
| + // ProcessState. |
| + if (whitelist_.count(process.process_name())) |
| + return true; |
| + switch (process.process_state()) { |
| + case arc::mojom::ProcessState::TOP: // Fallthrough. |
| + case arc::mojom::ProcessState::IMPORTANT_FOREGROUND: |
| + case arc::mojom::ProcessState::TOP_SLEEPING: |
| + return true; |
| + default: |
| + break; |
| + } |
| + return false; |
| +} |
| + |
| +} // namespace task_manager |