Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(39)

Side by Side Diff: chrome/browser/chromeos/arc/process/arc_process.cc

Issue 2874543002: Refactor ARC OOM handler code (Closed)
Patch Set: address comments from Luis Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "chrome/browser/chromeos/arc/process/arc_process.h" 5 #include "chrome/browser/chromeos/arc/process/arc_process.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 namespace arc { 9 namespace arc {
10 10
11 namespace {
12
13 // A special process on Android side which serves as a dummy "focused" app
14 // when the focused window is a Chrome side window (i.e., all Android
15 // processes are running in the background). We don't want to kill it anyway.
16 constexpr char kArcHomeProcess[] = "org.chromium.arc.home";
cylee1 2017/05/10 16:31:54 A no-so-relevant comment : I'm not sure if what de
Yusuke Sato 2017/05/10 18:29:43 The process still works like that.
17
18 } // namespace
19
11 ArcProcess::ArcProcess(base::ProcessId nspid, 20 ArcProcess::ArcProcess(base::ProcessId nspid,
12 base::ProcessId pid, 21 base::ProcessId pid,
13 const std::string& process_name, 22 const std::string& process_name,
14 mojom::ProcessState process_state, 23 mojom::ProcessState process_state,
15 bool is_focused, 24 bool is_focused,
16 int64_t last_activity_time) 25 int64_t last_activity_time)
17 : nspid_(nspid), 26 : nspid_(nspid),
18 pid_(pid), 27 pid_(pid),
19 process_name_(process_name), 28 process_name_(process_name),
20 process_state_(process_state), 29 process_state_(process_state),
21 is_focused_(is_focused), 30 is_focused_(is_focused),
22 last_activity_time_(last_activity_time) {} 31 last_activity_time_(last_activity_time) {}
23 32
24 ArcProcess::~ArcProcess() = default; 33 ArcProcess::~ArcProcess() = default;
25 34
26 // Sort by (process_state, last_activity_time) pair. 35 // Sort by (process_state, last_activity_time) pair.
27 // Smaller process_state value means higher priority as defined in Android. 36 // Smaller process_state value means higher priority as defined in Android.
28 // Larger last_activity_time means more recently used. 37 // Larger last_activity_time means more recently used.
29 bool ArcProcess::operator<(const ArcProcess& rhs) const { 38 bool ArcProcess::operator<(const ArcProcess& rhs) const {
30 return std::make_pair(process_state(), -last_activity_time()) < 39 return std::make_pair(process_state(), -last_activity_time()) <
31 std::make_pair(rhs.process_state(), -rhs.last_activity_time()); 40 std::make_pair(rhs.process_state(), -rhs.last_activity_time());
32 } 41 }
33 42
34 ArcProcess::ArcProcess(ArcProcess&& other) = default; 43 ArcProcess::ArcProcess(ArcProcess&& other) = default;
35 ArcProcess& ArcProcess::operator=(ArcProcess&& other) = default; 44 ArcProcess& ArcProcess::operator=(ArcProcess&& other) = default;
36 45
46 bool ArcProcess::IsUserVisible() const {
cylee1 2017/05/10 16:31:54 The name is not so right because processes like pe
Yusuke Sato 2017/05/10 18:29:43 Done. Changed to IsImportant.
47 return process_state() <= mojom::ProcessState::IMPORTANT_FOREGROUND ||
48 process_name() == kArcHomeProcess;
49 }
50
51 bool ArcProcess::IsKernelKillable() const {
52 // Protect PERSISTENT, PERSISTENT_UI, and our HOME processes since they should
cylee1 2017/05/10 16:31:55 Thinking it twice, I feel there's no need to separ
Yusuke Sato 2017/05/10 18:29:43 With this CL, because of the explicit SetOomScore(
cylee1 2017/05/11 08:59:53 Yes. I remember that's what Luigi and me discussed
Yusuke Sato 2017/05/11 18:50:16 Acknowledged.
53 // never be killed even by the kernel. Returning false for them allows their
54 // OOM adjustment scores to remain negative.
55 return process_state() > arc::mojom::ProcessState::PERSISTENT_UI &&
56 process_name() != kArcHomeProcess;
57 }
58
37 } // namespace arc 59 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698