| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
| 7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 #include "content/browser/renderer_host/render_process_host_impl.h" | 9 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 10 #include "content/common/child_process_messages.h" | 10 #include "content/common/child_process_messages.h" |
| 11 #include "content/public/browser/render_process_host.h" | 11 #include "content/public/browser/render_process_host.h" |
| 12 #include "content/public/browser/render_process_host_observer.h" | 12 #include "content/public/browser/render_process_host_observer.h" |
| 13 #include "content/public/browser/render_view_host.h" | 13 #include "content/public/browser/render_view_host.h" |
| 14 #include "content/public/browser/web_contents.h" | 14 #include "content/public/browser/web_contents.h" |
| 15 #include "content/public/common/content_switches.h" | 15 #include "content/public/common/content_switches.h" |
| 16 #include "content/public/common/service_registry.h" | |
| 17 #include "content/public/common/url_constants.h" | 16 #include "content/public/common/url_constants.h" |
| 18 #include "content/public/test/content_browser_test.h" | 17 #include "content/public/test/content_browser_test.h" |
| 19 #include "content/public/test/content_browser_test_utils.h" | 18 #include "content/public/test/content_browser_test_utils.h" |
| 20 #include "content/public/test/test_mojo_service.mojom.h" | 19 #include "content/public/test/test_mojo_service.mojom.h" |
| 21 #include "content/shell/browser/shell.h" | 20 #include "content/shell/browser/shell.h" |
| 22 #include "net/test/embedded_test_server/embedded_test_server.h" | 21 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 22 #include "services/shell/public/cpp/interface_provider.h" |
| 23 | 23 |
| 24 #if defined(OS_WIN) | 24 #if defined(OS_WIN) |
| 25 #include "base/win/windows_version.h" | 25 #include "base/win/windows_version.h" |
| 26 #endif | 26 #endif |
| 27 | 27 |
| 28 namespace content { | 28 namespace content { |
| 29 namespace { | 29 namespace { |
| 30 | 30 |
| 31 int RenderProcessHostCount() { | 31 int RenderProcessHostCount() { |
| 32 content::RenderProcessHost::iterator hosts = | 32 content::RenderProcessHost::iterator hosts = |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 GURL test_url = embedded_test_server()->GetURL("/simple_page.html"); | 215 GURL test_url = embedded_test_server()->GetURL("/simple_page.html"); |
| 216 NavigateToURL(shell(), test_url); | 216 NavigateToURL(shell(), test_url); |
| 217 RenderProcessHost* rph = | 217 RenderProcessHost* rph = |
| 218 shell()->web_contents()->GetRenderViewHost()->GetProcess(); | 218 shell()->web_contents()->GetRenderViewHost()->GetProcess(); |
| 219 | 219 |
| 220 host_destructions_ = 0; | 220 host_destructions_ = 0; |
| 221 process_exits_ = 0; | 221 process_exits_ = 0; |
| 222 rph->AddObserver(this); | 222 rph->AddObserver(this); |
| 223 | 223 |
| 224 mojom::TestMojoServicePtr service; | 224 mojom::TestMojoServicePtr service; |
| 225 rph->GetServiceRegistry()->ConnectToRemoteService(mojo::GetProxy(&service)); | 225 rph->GetRemoteInterfaces()->GetInterface(&service); |
| 226 | 226 |
| 227 base::RunLoop run_loop; | 227 base::RunLoop run_loop; |
| 228 set_process_exit_callback(run_loop.QuitClosure()); | 228 set_process_exit_callback(run_loop.QuitClosure()); |
| 229 | 229 |
| 230 // Should reply with a bad message and cause process death. | 230 // Should reply with a bad message and cause process death. |
| 231 service->DoSomething(base::Bind(&base::DoNothing)); | 231 service->DoSomething(base::Bind(&base::DoNothing)); |
| 232 | 232 |
| 233 run_loop.Run(); | 233 run_loop.Run(); |
| 234 | 234 |
| 235 EXPECT_EQ(1, process_exits_); | 235 EXPECT_EQ(1, process_exits_); |
| 236 EXPECT_EQ(0, host_destructions_); | 236 EXPECT_EQ(0, host_destructions_); |
| 237 if (!host_destructions_) | 237 if (!host_destructions_) |
| 238 rph->RemoveObserver(this); | 238 rph->RemoveObserver(this); |
| 239 } | 239 } |
| 240 | 240 |
| 241 } // namespace | 241 } // namespace |
| 242 } // namespace content | 242 } // namespace content |
| OLD | NEW |