| 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "chrome/browser/devtools/devtools_window.h" | 6 #include "chrome/browser/devtools/devtools_window.h" |
| 7 #include "chrome/browser/ui/browser.h" | 7 #include "chrome/browser/ui/browser.h" |
| 8 #include "chrome/browser/ui/browser_commands.h" | 8 #include "chrome/browser/ui/browser_commands.h" |
| 9 #include "chrome/browser/ui/singleton_tabs.h" | 9 #include "chrome/browser/ui/singleton_tabs.h" |
| 10 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 10 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 int count = 0; | 29 int count = 0; |
| 30 while (!hosts.IsAtEnd()) { | 30 while (!hosts.IsAtEnd()) { |
| 31 if (hosts.GetCurrentValue()->HasConnection()) | 31 if (hosts.GetCurrentValue()->HasConnection()) |
| 32 count++; | 32 count++; |
| 33 hosts.Advance(); | 33 hosts.Advance(); |
| 34 } | 34 } |
| 35 return count; | 35 return count; |
| 36 } | 36 } |
| 37 | 37 |
| 38 RenderViewHost* FindFirstDevToolsHost() { | 38 RenderViewHost* FindFirstDevToolsHost() { |
| 39 content::RenderProcessHost::iterator hosts = | 39 |
| 40 content::RenderProcessHost::AllHostsIterator(); | 40 scoped_ptr<RenderWidgetHost::List> hosts = |
| 41 for (; !hosts.IsAtEnd(); hosts.Advance()) { | 41 RenderWidgetHost::GetRenderWidgetHosts(); |
| 42 content::RenderProcessHost* render_process_host = hosts.GetCurrentValue(); | 42 for (RenderWidgetHost::List::const_iterator it = hosts->begin(); |
| 43 DCHECK(render_process_host); | 43 it != hosts->end(); |
| 44 if (!render_process_host->HasConnection()) | 44 ++it) { |
| 45 const RenderWidgetHost* widget = *it; |
| 46 if (!widget->GetProcess()->HasConnection()) |
| 45 continue; | 47 continue; |
| 46 content::RenderProcessHost::RenderWidgetHostsIterator iter( | 48 if (!widget->IsRenderView()) |
| 47 render_process_host->GetRenderWidgetHostsIterator()); | 49 continue; |
| 48 for (; !iter.IsAtEnd(); iter.Advance()) { | 50 RenderViewHost* host = |
| 49 const RenderWidgetHost* widget = iter.GetCurrentValue(); | 51 RenderViewHost::From(const_cast<RenderWidgetHost*>(widget)); |
| 50 DCHECK(widget); | 52 WebContents* contents = WebContents::FromRenderViewHost(host); |
| 51 if (!widget || !widget->IsRenderView()) | 53 GURL url = contents->GetURL(); |
| 52 continue; | 54 if (url.SchemeIs(chrome::kChromeDevToolsScheme)) |
| 53 RenderViewHost* host = | 55 return host; |
| 54 RenderViewHost::From(const_cast<RenderWidgetHost*>(widget)); | |
| 55 WebContents* contents = WebContents::FromRenderViewHost(host); | |
| 56 GURL url = contents->GetURL(); | |
| 57 if (url.SchemeIs(chrome::kChromeDevToolsScheme)) | |
| 58 return host; | |
| 59 } | |
| 60 } | 56 } |
| 57 |
| 61 return NULL; | 58 return NULL; |
| 62 } | 59 } |
| 63 | 60 |
| 64 } // namespace | 61 } // namespace |
| 65 | 62 |
| 66 class ChromeRenderProcessHostTest : public InProcessBrowserTest { | 63 class ChromeRenderProcessHostTest : public InProcessBrowserTest { |
| 67 public: | 64 public: |
| 68 ChromeRenderProcessHostTest() {} | 65 ChromeRenderProcessHostTest() {} |
| 69 | 66 |
| 70 // Show a tab, activating the current one if there is one, and wait for | 67 // Show a tab, activating the current one if there is one, and wait for |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 RenderViewHost* devtools = FindFirstDevToolsHost(); | 352 RenderViewHost* devtools = FindFirstDevToolsHost(); |
| 356 DCHECK(devtools); | 353 DCHECK(devtools); |
| 357 | 354 |
| 358 // DevTools start in a separate process. | 355 // DevTools start in a separate process. |
| 359 DevToolsWindow::ToggleDevToolsWindow( | 356 DevToolsWindow::ToggleDevToolsWindow( |
| 360 devtools, true, DEVTOOLS_TOGGLE_ACTION_INSPECT); | 357 devtools, true, DEVTOOLS_TOGGLE_ACTION_INSPECT); |
| 361 host_count++; | 358 host_count++; |
| 362 EXPECT_EQ(tab_count, browser()->tab_strip_model()->count()); | 359 EXPECT_EQ(tab_count, browser()->tab_strip_model()->count()); |
| 363 EXPECT_EQ(host_count, RenderProcessHostCount()); | 360 EXPECT_EQ(host_count, RenderProcessHostCount()); |
| 364 } | 361 } |
| OLD | NEW |