OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/child_process_resource_provider.h" | 5 #include "chrome/browser/task_manager/child_process_resource_provider.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
181 case content::PROCESS_TYPE_PPAPI_BROKER: | 181 case content::PROCESS_TYPE_PPAPI_BROKER: |
182 return l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_PLUGIN_BROKER_PREFIX, | 182 return l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_PLUGIN_BROKER_PREFIX, |
183 title); | 183 title); |
184 case PROCESS_TYPE_NACL_BROKER: | 184 case PROCESS_TYPE_NACL_BROKER: |
185 return l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NACL_BROKER_PREFIX); | 185 return l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NACL_BROKER_PREFIX); |
186 case PROCESS_TYPE_NACL_LOADER: | 186 case PROCESS_TYPE_NACL_LOADER: |
187 return l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_NACL_PREFIX, title); | 187 return l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_NACL_PREFIX, title); |
188 // These types don't need display names or get them from elsewhere. | 188 // These types don't need display names or get them from elsewhere. |
189 case content::PROCESS_TYPE_BROWSER: | 189 case content::PROCESS_TYPE_BROWSER: |
190 case content::PROCESS_TYPE_RENDERER: | 190 case content::PROCESS_TYPE_RENDERER: |
191 case content::PROCESS_TYPE_WORKER_DEPRICATED: | |
jochen (gone - plz use gerrit)
2014/07/24 09:25:09
DEPRICATED?
horo
2014/07/24 10:22:58
Deleted.
| |
191 case content::PROCESS_TYPE_ZYGOTE: | 192 case content::PROCESS_TYPE_ZYGOTE: |
192 case content::PROCESS_TYPE_SANDBOX_HELPER: | 193 case content::PROCESS_TYPE_SANDBOX_HELPER: |
193 case content::PROCESS_TYPE_MAX: | 194 case content::PROCESS_TYPE_MAX: |
194 NOTREACHED(); | 195 NOTREACHED(); |
195 break; | 196 break; |
196 | |
197 case content::PROCESS_TYPE_WORKER: | |
198 NOTREACHED() << "Workers are not handled by this provider."; | |
199 break; | |
200 case content::PROCESS_TYPE_UNKNOWN: | 197 case content::PROCESS_TYPE_UNKNOWN: |
201 NOTREACHED() << "Need localized name for child process type."; | 198 NOTREACHED() << "Need localized name for child process type."; |
202 } | 199 } |
203 | 200 |
204 return title; | 201 return title; |
205 } | 202 } |
206 | 203 |
207 //////////////////////////////////////////////////////////////////////////////// | 204 //////////////////////////////////////////////////////////////////////////////// |
208 // ChildProcessResourceProvider class | 205 // ChildProcessResourceProvider class |
209 //////////////////////////////////////////////////////////////////////////////// | 206 //////////////////////////////////////////////////////////////////////////////// |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
252 resources_.clear(); | 249 resources_.clear(); |
253 pid_to_resources_.clear(); | 250 pid_to_resources_.clear(); |
254 | 251 |
255 BrowserChildProcessObserver::Remove(this); | 252 BrowserChildProcessObserver::Remove(this); |
256 } | 253 } |
257 | 254 |
258 void ChildProcessResourceProvider::BrowserChildProcessHostConnected( | 255 void ChildProcessResourceProvider::BrowserChildProcessHostConnected( |
259 const content::ChildProcessData& data) { | 256 const content::ChildProcessData& data) { |
260 DCHECK(updating_); | 257 DCHECK(updating_); |
261 | 258 |
262 // Workers are handled by WorkerResourceProvider. | |
263 if (data.process_type == content::PROCESS_TYPE_WORKER) | |
264 return; | |
265 if (resources_.count(data.handle)) { | 259 if (resources_.count(data.handle)) { |
266 // The case may happen that we have added a child_process_info as part of | 260 // The case may happen that we have added a child_process_info as part of |
267 // the iteration performed during StartUpdating() call but the notification | 261 // the iteration performed during StartUpdating() call but the notification |
268 // that it has connected was not fired yet. So when the notification | 262 // that it has connected was not fired yet. So when the notification |
269 // happens, we already know about this plugin and just ignore it. | 263 // happens, we already know about this plugin and just ignore it. |
270 return; | 264 return; |
271 } | 265 } |
272 AddToTaskManager(data); | 266 AddToTaskManager(data); |
273 } | 267 } |
274 | 268 |
275 void ChildProcessResourceProvider:: | 269 void ChildProcessResourceProvider:: |
276 BrowserChildProcessHostDisconnected( | 270 BrowserChildProcessHostDisconnected( |
277 const content::ChildProcessData& data) { | 271 const content::ChildProcessData& data) { |
278 DCHECK(updating_); | 272 DCHECK(updating_); |
279 | 273 |
280 if (data.process_type == content::PROCESS_TYPE_WORKER) | |
281 return; | |
282 ChildProcessMap::iterator iter = resources_.find(data.handle); | 274 ChildProcessMap::iterator iter = resources_.find(data.handle); |
283 if (iter == resources_.end()) { | 275 if (iter == resources_.end()) { |
284 // ChildProcessData disconnection notifications are asynchronous, so we | 276 // ChildProcessData disconnection notifications are asynchronous, so we |
285 // might be notified for a plugin we don't know anything about (if it was | 277 // might be notified for a plugin we don't know anything about (if it was |
286 // closed before the task manager was shown and destroyed after that). | 278 // closed before the task manager was shown and destroyed after that). |
287 return; | 279 return; |
288 } | 280 } |
289 // Remove the resource from the Task Manager. | 281 // Remove the resource from the Task Manager. |
290 ChildProcessResource* resource = iter->second; | 282 ChildProcessResource* resource = iter->second; |
291 task_manager_->RemoveResource(resource); | 283 task_manager_->RemoveResource(resource); |
(...skipping 23 matching lines...) Expand all Loading... | |
315 task_manager_->AddResource(resource); | 307 task_manager_->AddResource(resource); |
316 } | 308 } |
317 | 309 |
318 // The ChildProcessData::Iterator has to be used from the IO thread. | 310 // The ChildProcessData::Iterator has to be used from the IO thread. |
319 void ChildProcessResourceProvider::RetrieveChildProcessData() { | 311 void ChildProcessResourceProvider::RetrieveChildProcessData() { |
320 std::vector<content::ChildProcessData> child_processes; | 312 std::vector<content::ChildProcessData> child_processes; |
321 for (BrowserChildProcessHostIterator iter; !iter.Done(); ++iter) { | 313 for (BrowserChildProcessHostIterator iter; !iter.Done(); ++iter) { |
322 // Only add processes which are already started, since we need their handle. | 314 // Only add processes which are already started, since we need their handle. |
323 if (iter.GetData().handle == base::kNullProcessHandle) | 315 if (iter.GetData().handle == base::kNullProcessHandle) |
324 continue; | 316 continue; |
325 if (iter.GetData().process_type == content::PROCESS_TYPE_WORKER) | |
326 continue; | |
327 child_processes.push_back(iter.GetData()); | 317 child_processes.push_back(iter.GetData()); |
328 } | 318 } |
329 // Now notify the UI thread that we have retrieved information about child | 319 // Now notify the UI thread that we have retrieved information about child |
330 // processes. | 320 // processes. |
331 BrowserThread::PostTask( | 321 BrowserThread::PostTask( |
332 BrowserThread::UI, FROM_HERE, | 322 BrowserThread::UI, FROM_HERE, |
333 base::Bind( | 323 base::Bind( |
334 &ChildProcessResourceProvider::ChildProcessDataRetreived, | 324 &ChildProcessResourceProvider::ChildProcessDataRetreived, |
335 this, child_processes)); | 325 this, child_processes)); |
336 } | 326 } |
337 | 327 |
338 // This is called on the UI thread. | 328 // This is called on the UI thread. |
339 void ChildProcessResourceProvider::ChildProcessDataRetreived( | 329 void ChildProcessResourceProvider::ChildProcessDataRetreived( |
340 const std::vector<content::ChildProcessData>& child_processes) { | 330 const std::vector<content::ChildProcessData>& child_processes) { |
341 for (size_t i = 0; i < child_processes.size(); ++i) | 331 for (size_t i = 0; i < child_processes.size(); ++i) |
342 AddToTaskManager(child_processes[i]); | 332 AddToTaskManager(child_processes[i]); |
343 | 333 |
344 task_manager_->model()->NotifyDataReady(); | 334 task_manager_->model()->NotifyDataReady(); |
345 } | 335 } |
346 | 336 |
347 } // namespace task_manager | 337 } // namespace task_manager |
OLD | NEW |