| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/extensions/api/processes/processes_api.h" | 5 #include "chrome/browser/extensions/api/processes/processes_api.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 out_process->id = task_manager->GetChildProcessUniqueId(id); | 117 out_process->id = task_manager->GetChildProcessUniqueId(id); |
| 118 out_process->os_process_id = task_manager->GetProcessId(id); | 118 out_process->os_process_id = task_manager->GetProcessId(id); |
| 119 out_process->type = GetProcessType(task_manager->GetType(id)); | 119 out_process->type = GetProcessType(task_manager->GetType(id)); |
| 120 out_process->profile = base::UTF16ToUTF8(task_manager->GetProfileName(id)); | 120 out_process->profile = base::UTF16ToUTF8(task_manager->GetProfileName(id)); |
| 121 out_process->nacl_debug_port = task_manager->GetNaClDebugStubPort(id); | 121 out_process->nacl_debug_port = task_manager->GetNaClDebugStubPort(id); |
| 122 | 122 |
| 123 // Collect the tab IDs of all the tasks sharing this renderer if any. | 123 // Collect the tab IDs of all the tasks sharing this renderer if any. |
| 124 const task_management::TaskIdList tasks_on_process = | 124 const task_management::TaskIdList tasks_on_process = |
| 125 task_manager->GetIdsOfTasksSharingSameProcess(id); | 125 task_manager->GetIdsOfTasksSharingSameProcess(id); |
| 126 for (const auto& task_id : tasks_on_process) { | 126 for (const auto& task_id : tasks_on_process) { |
| 127 linked_ptr<api::processes::TaskInfo> task_info( | 127 api::processes::TaskInfo task_info; |
| 128 new api::processes::TaskInfo()); | 128 task_info.title = base::UTF16ToUTF8(task_manager->GetTitle(task_id)); |
| 129 task_info->title = base::UTF16ToUTF8(task_manager->GetTitle(task_id)); | |
| 130 const int tab_id = task_manager->GetTabId(task_id); | 129 const int tab_id = task_manager->GetTabId(task_id); |
| 131 if (tab_id != -1) | 130 if (tab_id != -1) |
| 132 task_info->tab_id.reset(new int(tab_id)); | 131 task_info.tab_id.reset(new int(tab_id)); |
| 133 | 132 |
| 134 out_process->tasks.push_back(task_info); | 133 out_process->tasks.push_back(std::move(task_info)); |
| 135 } | 134 } |
| 136 | 135 |
| 137 // If we don't need to include the optional properties, just return now. | 136 // If we don't need to include the optional properties, just return now. |
| 138 if (!include_optional) | 137 if (!include_optional) |
| 139 return; | 138 return; |
| 140 | 139 |
| 141 out_process->cpu.reset(new double(task_manager->GetCpuUsage(id))); | 140 out_process->cpu.reset(new double(task_manager->GetCpuUsage(id))); |
| 142 | 141 |
| 143 out_process->network.reset(new double(static_cast<double>( | 142 out_process->network.reset(new double(static_cast<double>( |
| 144 task_manager->GetProcessTotalNetworkUsage(id)))); | 143 task_manager->GetProcessTotalNetworkUsage(id)))); |
| (...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 681 // Send the response. | 680 // Send the response. |
| 682 Respond(ArgumentList( | 681 Respond(ArgumentList( |
| 683 api::processes::GetProcessInfo::Results::Create(processes))); | 682 api::processes::GetProcessInfo::Results::Create(processes))); |
| 684 | 683 |
| 685 // Stop observing the task manager, and balance the AddRef() in Run(). | 684 // Stop observing the task manager, and balance the AddRef() in Run(). |
| 686 task_management::TaskManagerInterface::GetTaskManager()->RemoveObserver(this); | 685 task_management::TaskManagerInterface::GetTaskManager()->RemoveObserver(this); |
| 687 Release(); | 686 Release(); |
| 688 } | 687 } |
| 689 | 688 |
| 690 } // namespace extensions | 689 } // namespace extensions |
| OLD | NEW |