| 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 scoped_ptr<content::RenderWidgetHost::List> hosts = |
| 116 rph->GetRenderWidgetHostsIterator()); | 116 content::RenderWidgetHost::GetRenderWidgetHosts(); |
| 117 for (; !iter.IsAtEnd(); iter.Advance()) { | 117 for (content::RenderWidgetHost::List::const_iterator it = hosts->begin(); |
| 118 const content::RenderWidgetHost* widget = iter.GetCurrentValue(); | 118 it != hosts->end(); |
| 119 DCHECK(widget); | 119 ++it) { |
| 120 if (!widget || !widget->IsRenderView()) | 120 const content::RenderWidgetHost* widget = *it; |
| 121 if (widget->GetProcess()->GetID() != process_id) |
| 122 continue; |
| 123 if (!widget->IsRenderView()) |
| 121 continue; | 124 continue; |
| 122 | 125 |
| 123 content::RenderViewHost* host = content::RenderViewHost::From( | 126 content::RenderViewHost* host = content::RenderViewHost::From( |
| 124 const_cast<content::RenderWidgetHost*>(widget)); | 127 const_cast<content::RenderWidgetHost*>(widget)); |
| 125 content::WebContents* contents = | 128 content::WebContents* contents = |
| 126 content::WebContents::FromRenderViewHost(host); | 129 content::WebContents::FromRenderViewHost(host); |
| 127 if (contents) { | 130 if (contents) { |
| 128 tab_id = ExtensionTabUtil::GetTabId(contents); | 131 tab_id = ExtensionTabUtil::GetTabId(contents); |
| 129 if (tab_id != -1) | 132 if (tab_id != -1) |
| 130 tabs_list->Append(Value::CreateIntegerValue(tab_id)); | 133 tabs_list->Append(Value::CreateIntegerValue(tab_id)); |
| (...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 771 | 774 |
| 772 SetResult(processes); | 775 SetResult(processes); |
| 773 SendResponse(true); | 776 SendResponse(true); |
| 774 | 777 |
| 775 // Balance the AddRef in the RunImpl. | 778 // Balance the AddRef in the RunImpl. |
| 776 Release(); | 779 Release(); |
| 777 #endif // defined(ENABLE_TASK_MANAGER) | 780 #endif // defined(ENABLE_TASK_MANAGER) |
| 778 } | 781 } |
| 779 | 782 |
| 780 } // namespace extensions | 783 } // namespace extensions |
| OLD | NEW |