| 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 "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 // The tabs list only makes sense for render processes, so if we don't find | 105 // The tabs list only makes sense for render processes, so if we don't find |
| 106 // one, just return the empty list. | 106 // one, just return the empty list. |
| 107 content::RenderProcessHost* rph = | 107 content::RenderProcessHost* rph = |
| 108 content::RenderProcessHost::FromID(process_id); | 108 content::RenderProcessHost::FromID(process_id); |
| 109 if (rph == NULL) | 109 if (rph == NULL) |
| 110 return tabs_list; | 110 return tabs_list; |
| 111 | 111 |
| 112 int tab_id = -1; | 112 int tab_id = -1; |
| 113 // We need to loop through all the RVHs to ensure we collect the set of all | 113 // We need to loop through all the RVHs to ensure we collect the set of all |
| 114 // tabs using this renderer process. | 114 // tabs using this renderer process. |
| 115 content::RenderProcessHost::RenderWidgetHostsIterator iter( | 115 content::RenderWidgetHost::List widgets = |
| 116 rph->GetRenderWidgetHostsIterator()); | 116 content::RenderWidgetHost::GetRenderWidgetHosts(); |
| 117 for (; !iter.IsAtEnd(); iter.Advance()) { | 117 for (size_t i = 0; i < widgets.size(); ++i) { |
| 118 const content::RenderWidgetHost* widget = iter.GetCurrentValue(); | 118 if (widgets[i]->GetProcess()->GetID() != process_id) |
| 119 DCHECK(widget); | 119 continue; |
| 120 if (!widget || !widget->IsRenderView()) | 120 if (!widgets[i]->IsRenderView()) |
| 121 continue; | 121 continue; |
| 122 | 122 |
| 123 content::RenderViewHost* host = content::RenderViewHost::From( | 123 content::RenderViewHost* host = content::RenderViewHost::From(widgets[i]); |
| 124 const_cast<content::RenderWidgetHost*>(widget)); | |
| 125 content::WebContents* contents = | 124 content::WebContents* contents = |
| 126 content::WebContents::FromRenderViewHost(host); | 125 content::WebContents::FromRenderViewHost(host); |
| 127 if (contents) { | 126 if (contents) { |
| 128 tab_id = ExtensionTabUtil::GetTabId(contents); | 127 tab_id = ExtensionTabUtil::GetTabId(contents); |
| 129 if (tab_id != -1) | 128 if (tab_id != -1) |
| 130 tabs_list->Append(Value::CreateIntegerValue(tab_id)); | 129 tabs_list->Append(Value::CreateIntegerValue(tab_id)); |
| 131 } | 130 } |
| 132 } | 131 } |
| 133 | 132 |
| 134 return tabs_list; | 133 return tabs_list; |
| (...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 771 | 770 |
| 772 SetResult(processes); | 771 SetResult(processes); |
| 773 SendResponse(true); | 772 SendResponse(true); |
| 774 | 773 |
| 775 // Balance the AddRef in the RunImpl. | 774 // Balance the AddRef in the RunImpl. |
| 776 Release(); | 775 Release(); |
| 777 #endif // defined(ENABLE_TASK_MANAGER) | 776 #endif // defined(ENABLE_TASK_MANAGER) |
| 778 } | 777 } |
| 779 | 778 |
| 780 } // namespace extensions | 779 } // namespace extensions |
| OLD | NEW |