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

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

Issue 2557513004: Remove explicit singletonness of ArcBridgeService part 3. (Closed)
Patch Set: Address comments. Created 4 years 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.
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"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 // would be shown on task manager but does not have a package name. 100 // would be shown on task manager but does not have a package name.
101 std::vector<arc::ActivityIconLoader::ActivityName> activities = { 101 std::vector<arc::ActivityIconLoader::ActivityName> activities = {
102 {package_name_, kEmptyActivityName}}; 102 {package_name_, kEmptyActivityName}};
103 result = icon_loader->GetActivityIcons( 103 result = icon_loader->GetActivityIcons(
104 activities, base::Bind(&ArcProcessTask::OnIconLoaded, 104 activities, base::Bind(&ArcProcessTask::OnIconLoaded,
105 weak_ptr_factory_.GetWeakPtr())); 105 weak_ptr_factory_.GetWeakPtr()));
106 } 106 }
107 107
108 if (result == arc::ActivityIconLoader::GetResult::FAILED_ARC_NOT_READY) { 108 if (result == arc::ActivityIconLoader::GetResult::FAILED_ARC_NOT_READY) {
109 // Need to retry loading the icon. 109 // Need to retry loading the icon.
110 arc::ArcBridgeService::Get()->intent_helper()->AddObserver(this); 110 arc::ArcServiceManager::Get()
111 ->arc_bridge_service()
112 ->intent_helper()
113 ->AddObserver(this);
111 } 114 }
112 } 115 }
113 116
114 ArcProcessTask::~ArcProcessTask() { 117 ArcProcessTask::~ArcProcessTask() {
115 arc::ArcBridgeService::Get()->intent_helper()->RemoveObserver(this); 118 arc::ArcServiceManager::Get()
119 ->arc_bridge_service()
120 ->intent_helper()
121 ->RemoveObserver(this);
116 } 122 }
117 123
118 Task::Type ArcProcessTask::GetType() const { 124 Task::Type ArcProcessTask::GetType() const {
119 return Task::ARC; 125 return Task::ARC;
120 } 126 }
121 127
122 int ArcProcessTask::GetChildProcessUniqueID() const { 128 int ArcProcessTask::GetChildProcessUniqueID() const {
123 // ARC process is not a child process of the browser. 129 // ARC process is not a child process of the browser.
124 return content::ChildProcessHost::kInvalidUniqueID; 130 return content::ChildProcessHost::kInvalidUniqueID;
125 } 131 }
126 132
127 bool ArcProcessTask::IsKillable() { 133 bool ArcProcessTask::IsKillable() {
128 // Do not kill persistent processes. 134 // Do not kill persistent processes.
129 return process_state_ > arc::mojom::ProcessState::PERSISTENT_UI; 135 return process_state_ > arc::mojom::ProcessState::PERSISTENT_UI;
130 } 136 }
131 137
132 void ArcProcessTask::Kill() { 138 void ArcProcessTask::Kill() {
133 auto* process_instance = 139 auto* process_instance =
134 arc::ArcBridgeService::Get()->process()->GetInstanceForMethod( 140 arc::ArcServiceManager::Get()
135 "KillProcess", kKillProcessMinInstanceVersion); 141 ->arc_bridge_service()
142 ->process()
143 ->GetInstanceForMethod("KillProcess", kKillProcessMinInstanceVersion);
136 if (!process_instance) 144 if (!process_instance)
137 return; 145 return;
138 process_instance->KillProcess(nspid_, "Killed manually from Task Manager"); 146 process_instance->KillProcess(nspid_, "Killed manually from Task Manager");
139 } 147 }
140 148
141 void ArcProcessTask::OnInstanceReady() { 149 void ArcProcessTask::OnInstanceReady() {
142 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 150 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
143 151
144 VLOG(2) << "intent_helper instance is ready. Fetching the icon for " 152 VLOG(2) << "intent_helper instance is ready. Fetching the icon for "
145 << package_name_; 153 << package_name_;
146 arc::ArcBridgeService::Get()->intent_helper()->RemoveObserver(this); 154 arc::ArcServiceManager::Get()
155 ->arc_bridge_service()
156 ->intent_helper()
157 ->RemoveObserver(this);
147 158
148 // Instead of calling into StartIconLoading() directly, return to the main 159 // Instead of calling into StartIconLoading() directly, return to the main
149 // loop first to make sure other ArcBridgeService observers are notified. 160 // loop first to make sure other ArcBridgeService observers are notified.
150 // Otherwise, arc::ActivityIconLoader::GetActivityIcon() may fail again. 161 // Otherwise, arc::ActivityIconLoader::GetActivityIcon() may fail again.
151 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, 162 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
152 base::Bind(&ArcProcessTask::StartIconLoading, 163 base::Bind(&ArcProcessTask::StartIconLoading,
153 weak_ptr_factory_.GetWeakPtr())); 164 weak_ptr_factory_.GetWeakPtr()));
154 } 165 }
155 166
156 void ArcProcessTask::SetProcessState(arc::mojom::ProcessState process_state) { 167 void ArcProcessTask::SetProcessState(arc::mojom::ProcessState process_state) {
157 process_state_ = process_state; 168 process_state_ = process_state;
158 } 169 }
159 170
160 void ArcProcessTask::OnIconLoaded( 171 void ArcProcessTask::OnIconLoaded(
161 std::unique_ptr<arc::ActivityIconLoader::ActivityToIconsMap> icons) { 172 std::unique_ptr<arc::ActivityIconLoader::ActivityToIconsMap> icons) {
162 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 173 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
163 for (const auto& kv : *icons) { 174 for (const auto& kv : *icons) {
164 const gfx::Image& icon = kv.second.icon16; 175 const gfx::Image& icon = kv.second.icon16;
165 if (icon.IsEmpty()) 176 if (icon.IsEmpty())
166 continue; 177 continue;
167 set_icon(*icon.ToImageSkia()); 178 set_icon(*icon.ToImageSkia());
168 break; // Since the parent class can hold only one icon, break here. 179 break; // Since the parent class can hold only one icon, break here.
169 } 180 }
170 } 181 }
171 182
172 } // namespace task_manager 183 } // namespace task_manager
OLDNEW
« no previous file with comments | « chrome/browser/speech/tts_chromeos.cc ('k') | chrome/browser/ui/app_list/arc/arc_app_list_prefs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698