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

Side by Side Diff: chrome/browser/task_manager/providers/arc/arc_process_task.cc

Issue 2347293002: arc: Add InstanceHelper::GetInstanceForMethod() (Closed)
Patch Set: git cl format/lint Created 4 years, 3 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
Yusuke Sato 2016/09/16 23:58:48 Can you also modify the version() check in ArcInte
Luis Héctor Chávez 2016/09/17 00:30:52 Discussed offline. I'll keep the code as-is becaus
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/task_manager/providers/arc/arc_process_task.h" 5 #include "chrome/browser/task_manager/providers/arc/arc_process_task.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/i18n/rtl.h" 8 #include "base/i18n/rtl.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "chrome/grit/generated_resources.h" 11 #include "chrome/grit/generated_resources.h"
12 #include "components/arc/arc_service_manager.h" 12 #include "components/arc/arc_service_manager.h"
13 #include "components/arc/common/process.mojom.h" 13 #include "components/arc/common/process.mojom.h"
14 #include "content/public/browser/browser_thread.h" 14 #include "content/public/browser/browser_thread.h"
15 #include "content/public/common/child_process_host.h" 15 #include "content/public/common/child_process_host.h"
16 #include "ui/base/l10n/l10n_util.h" 16 #include "ui/base/l10n/l10n_util.h"
17 #include "ui/gfx/image/image.h" 17 #include "ui/gfx/image/image.h"
18 18
19 namespace task_manager { 19 namespace task_manager {
20 20
21 namespace { 21 namespace {
22 22
23 constexpr uint32_t kKillProcessMinInstanceVersion = 1;
24
23 base::string16 MakeTitle(const std::string& process_name, 25 base::string16 MakeTitle(const std::string& process_name,
24 arc::mojom::ProcessState process_state) { 26 arc::mojom::ProcessState process_state) {
25 int name_template = IDS_TASK_MANAGER_ARC_PREFIX; 27 int name_template = IDS_TASK_MANAGER_ARC_PREFIX;
26 switch (process_state) { 28 switch (process_state) {
27 case arc::mojom::ProcessState::PERSISTENT: 29 case arc::mojom::ProcessState::PERSISTENT:
28 case arc::mojom::ProcessState::PERSISTENT_UI: 30 case arc::mojom::ProcessState::PERSISTENT_UI:
29 case arc::mojom::ProcessState::TOP: 31 case arc::mojom::ProcessState::TOP:
30 name_template = IDS_TASK_MANAGER_ARC_SYSTEM; 32 name_template = IDS_TASK_MANAGER_ARC_SYSTEM;
31 break; 33 break;
32 case arc::mojom::ProcessState::BOUND_FOREGROUND_SERVICE: 34 case arc::mojom::ProcessState::BOUND_FOREGROUND_SERVICE:
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 // ARC process is not a child process of the browser. 121 // ARC process is not a child process of the browser.
120 return content::ChildProcessHost::kInvalidUniqueID; 122 return content::ChildProcessHost::kInvalidUniqueID;
121 } 123 }
122 124
123 bool ArcProcessTask::IsKillable() { 125 bool ArcProcessTask::IsKillable() {
124 // Do not kill persistent processes. 126 // Do not kill persistent processes.
125 return process_state_ > arc::mojom::ProcessState::PERSISTENT_UI; 127 return process_state_ > arc::mojom::ProcessState::PERSISTENT_UI;
126 } 128 }
127 129
128 void ArcProcessTask::Kill() { 130 void ArcProcessTask::Kill() {
129 arc::mojom::ProcessInstance* arc_process_instance = 131 auto* process_instance =
130 arc::ArcBridgeService::Get()->process()->instance(); 132 arc::ArcBridgeService::Get()->process()->GetInstanceForVersion(
131 if (!arc_process_instance) { 133 kKillProcessMinInstanceVersion, "KillProcess");
132 LOG(ERROR) << "ARC process instance is not ready."; 134 if (!process_instance)
133 return; 135 return;
134 } 136 process_instance->KillProcess(nspid_, "Killed manually from Task Manager");
135 if (arc::ArcBridgeService::Get()->process()->version() < 1) {
136 LOG(ERROR) << "ARC KillProcess IPC is unavailable.";
137 return;
138 }
139 arc_process_instance->KillProcess(nspid_,
140 "Killed manually from Task Manager");
141 } 137 }
142 138
143 void ArcProcessTask::OnInstanceReady() { 139 void ArcProcessTask::OnInstanceReady() {
144 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 140 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
145 141
146 VLOG(2) << "intent_helper instance is ready. Fetching the icon for " 142 VLOG(2) << "intent_helper instance is ready. Fetching the icon for "
147 << package_name_; 143 << package_name_;
148 arc::ArcBridgeService::Get()->intent_helper()->RemoveObserver(this); 144 arc::ArcBridgeService::Get()->intent_helper()->RemoveObserver(this);
149 145
150 // Instead of calling into StartIconLoading() directly, return to the main 146 // Instead of calling into StartIconLoading() directly, return to the main
(...skipping 14 matching lines...) Expand all
165 for (const auto& kv : *icons) { 161 for (const auto& kv : *icons) {
166 const gfx::Image& icon = kv.second.icon16; 162 const gfx::Image& icon = kv.second.icon16;
167 if (icon.IsEmpty()) 163 if (icon.IsEmpty())
168 continue; 164 continue;
169 set_icon(*icon.ToImageSkia()); 165 set_icon(*icon.ToImageSkia());
170 break; // Since the parent class can hold only one icon, break here. 166 break; // Since the parent class can hold only one icon, break here.
171 } 167 }
172 } 168 }
173 169
174 } // namespace task_manager 170 } // namespace task_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698