| 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/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "content/browser/renderer_host/render_process_host_impl.h" | 6 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 7 #include "content/common/child_process_messages.h" | 7 #include "content/common/child_process_messages.h" |
| 8 #include "content/public/browser/render_process_host.h" | 8 #include "content/public/browser/render_process_host.h" |
| 9 #include "content/public/browser/render_process_host_observer.h" | 9 #include "content/public/browser/render_process_host_observer.h" |
| 10 #include "content/public/browser/render_view_host.h" | 10 #include "content/public/browser/render_view_host.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 class RenderProcessHostTest : public ContentBrowserTest, | 38 class RenderProcessHostTest : public ContentBrowserTest, |
| 39 public RenderProcessHostObserver { | 39 public RenderProcessHostObserver { |
| 40 public: | 40 public: |
| 41 RenderProcessHostTest() : process_exits_(0), host_destructions_(0) {} | 41 RenderProcessHostTest() : process_exits_(0), host_destructions_(0) {} |
| 42 | 42 |
| 43 protected: | 43 protected: |
| 44 // RenderProcessHostObserver: | 44 // RenderProcessHostObserver: |
| 45 virtual void RenderProcessExited(RenderProcessHost* host, | 45 virtual void RenderProcessExited(RenderProcessHost* host, |
| 46 base::ProcessHandle handle, | 46 base::ProcessHandle handle, |
| 47 base::TerminationStatus status, | 47 base::TerminationStatus status, |
| 48 int exit_code) OVERRIDE { | 48 int exit_code) override { |
| 49 ++process_exits_; | 49 ++process_exits_; |
| 50 } | 50 } |
| 51 virtual void RenderProcessHostDestroyed(RenderProcessHost* host) OVERRIDE { | 51 virtual void RenderProcessHostDestroyed(RenderProcessHost* host) override { |
| 52 ++host_destructions_; | 52 ++host_destructions_; |
| 53 } | 53 } |
| 54 | 54 |
| 55 int process_exits_; | 55 int process_exits_; |
| 56 int host_destructions_; | 56 int host_destructions_; |
| 57 }; | 57 }; |
| 58 | 58 |
| 59 // Sometimes the renderer process's ShutdownRequest (corresponding to the | 59 // Sometimes the renderer process's ShutdownRequest (corresponding to the |
| 60 // ViewMsg_WasSwappedOut from a previous navigation) doesn't arrive until after | 60 // ViewMsg_WasSwappedOut from a previous navigation) doesn't arrive until after |
| 61 // the browser process decides to re-use the renderer for a new purpose. This | 61 // the browser process decides to re-use the renderer for a new purpose. This |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 class ShellCloser : public RenderProcessHostObserver { | 117 class ShellCloser : public RenderProcessHostObserver { |
| 118 public: | 118 public: |
| 119 ShellCloser(Shell* shell, std::string* logging_string) | 119 ShellCloser(Shell* shell, std::string* logging_string) |
| 120 : shell_(shell), logging_string_(logging_string) {} | 120 : shell_(shell), logging_string_(logging_string) {} |
| 121 | 121 |
| 122 protected: | 122 protected: |
| 123 // RenderProcessHostObserver: | 123 // RenderProcessHostObserver: |
| 124 virtual void RenderProcessExited(RenderProcessHost* host, | 124 virtual void RenderProcessExited(RenderProcessHost* host, |
| 125 base::ProcessHandle handle, | 125 base::ProcessHandle handle, |
| 126 base::TerminationStatus status, | 126 base::TerminationStatus status, |
| 127 int exit_code) OVERRIDE { | 127 int exit_code) override { |
| 128 logging_string_->append("ShellCloser::RenderProcessExited "); | 128 logging_string_->append("ShellCloser::RenderProcessExited "); |
| 129 shell_->Close(); | 129 shell_->Close(); |
| 130 } | 130 } |
| 131 | 131 |
| 132 virtual void RenderProcessHostDestroyed(RenderProcessHost* host) OVERRIDE { | 132 virtual void RenderProcessHostDestroyed(RenderProcessHost* host) override { |
| 133 logging_string_->append("ShellCloser::RenderProcessHostDestroyed "); | 133 logging_string_->append("ShellCloser::RenderProcessHostDestroyed "); |
| 134 } | 134 } |
| 135 | 135 |
| 136 Shell* shell_; | 136 Shell* shell_; |
| 137 std::string* logging_string_; | 137 std::string* logging_string_; |
| 138 }; | 138 }; |
| 139 | 139 |
| 140 class ObserverLogger : public RenderProcessHostObserver { | 140 class ObserverLogger : public RenderProcessHostObserver { |
| 141 public: | 141 public: |
| 142 explicit ObserverLogger(std::string* logging_string) | 142 explicit ObserverLogger(std::string* logging_string) |
| 143 : logging_string_(logging_string), host_destroyed_(false) {} | 143 : logging_string_(logging_string), host_destroyed_(false) {} |
| 144 | 144 |
| 145 bool host_destroyed() { return host_destroyed_; } | 145 bool host_destroyed() { return host_destroyed_; } |
| 146 | 146 |
| 147 protected: | 147 protected: |
| 148 // RenderProcessHostObserver: | 148 // RenderProcessHostObserver: |
| 149 virtual void RenderProcessExited(RenderProcessHost* host, | 149 virtual void RenderProcessExited(RenderProcessHost* host, |
| 150 base::ProcessHandle handle, | 150 base::ProcessHandle handle, |
| 151 base::TerminationStatus status, | 151 base::TerminationStatus status, |
| 152 int exit_code) OVERRIDE { | 152 int exit_code) override { |
| 153 logging_string_->append("ObserverLogger::RenderProcessExited "); | 153 logging_string_->append("ObserverLogger::RenderProcessExited "); |
| 154 } | 154 } |
| 155 | 155 |
| 156 virtual void RenderProcessHostDestroyed(RenderProcessHost* host) OVERRIDE { | 156 virtual void RenderProcessHostDestroyed(RenderProcessHost* host) override { |
| 157 logging_string_->append("ObserverLogger::RenderProcessHostDestroyed "); | 157 logging_string_->append("ObserverLogger::RenderProcessHostDestroyed "); |
| 158 host_destroyed_ = true; | 158 host_destroyed_ = true; |
| 159 } | 159 } |
| 160 | 160 |
| 161 std::string* logging_string_; | 161 std::string* logging_string_; |
| 162 bool host_destroyed_; | 162 bool host_destroyed_; |
| 163 }; | 163 }; |
| 164 | 164 |
| 165 IN_PROC_BROWSER_TEST_F(RenderProcessHostTest, | 165 IN_PROC_BROWSER_TEST_F(RenderProcessHostTest, |
| 166 AllProcessExitedCallsBeforeAnyHostDestroyedCalls) { | 166 AllProcessExitedCallsBeforeAnyHostDestroyedCalls) { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 #if defined(OS_WIN) | 201 #if defined(OS_WIN) |
| 202 // Provides functionality to test renderer processes with the Win32K lockdown | 202 // Provides functionality to test renderer processes with the Win32K lockdown |
| 203 // process mitigation. | 203 // process mitigation. |
| 204 class Win32KLockdownRendererProcessHostTest : public RenderProcessHostTest { | 204 class Win32KLockdownRendererProcessHostTest : public RenderProcessHostTest { |
| 205 public: | 205 public: |
| 206 Win32KLockdownRendererProcessHostTest() {} | 206 Win32KLockdownRendererProcessHostTest() {} |
| 207 | 207 |
| 208 virtual ~Win32KLockdownRendererProcessHostTest() {} | 208 virtual ~Win32KLockdownRendererProcessHostTest() {} |
| 209 | 209 |
| 210 protected: | 210 protected: |
| 211 virtual void SetUp() OVERRIDE { | 211 virtual void SetUp() override { |
| 212 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 212 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 213 command_line->AppendSwitch(switches::kEnableWin32kRendererLockDown); | 213 command_line->AppendSwitch(switches::kEnableWin32kRendererLockDown); |
| 214 RenderProcessHostTest::SetUp(); | 214 RenderProcessHostTest::SetUp(); |
| 215 } | 215 } |
| 216 | 216 |
| 217 private: | 217 private: |
| 218 DISALLOW_COPY_AND_ASSIGN(Win32KLockdownRendererProcessHostTest); | 218 DISALLOW_COPY_AND_ASSIGN(Win32KLockdownRendererProcessHostTest); |
| 219 }; | 219 }; |
| 220 | 220 |
| 221 // Tests whether navigation requests with the Win32K lockdown mitigation set | 221 // Tests whether navigation requests with the Win32K lockdown mitigation set |
| 222 // work correctly. | 222 // work correctly. |
| 223 IN_PROC_BROWSER_TEST_F(Win32KLockdownRendererProcessHostTest, | 223 IN_PROC_BROWSER_TEST_F(Win32KLockdownRendererProcessHostTest, |
| 224 RendererWin32KLockdownNavigationTest) { | 224 RendererWin32KLockdownNavigationTest) { |
| 225 if (base::win::GetVersion() < base::win::VERSION_WIN8) | 225 if (base::win::GetVersion() < base::win::VERSION_WIN8) |
| 226 return; | 226 return; |
| 227 | 227 |
| 228 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 228 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 229 | 229 |
| 230 GURL test_url = embedded_test_server()->GetURL("/simple_page.html"); | 230 GURL test_url = embedded_test_server()->GetURL("/simple_page.html"); |
| 231 NavigateToURL(shell(), test_url); | 231 NavigateToURL(shell(), test_url); |
| 232 | 232 |
| 233 EXPECT_EQ(1, RenderProcessHostCount()); | 233 EXPECT_EQ(1, RenderProcessHostCount()); |
| 234 EXPECT_EQ(0, process_exits_); | 234 EXPECT_EQ(0, process_exits_); |
| 235 } | 235 } |
| 236 #endif | 236 #endif |
| 237 | 237 |
| 238 } // namespace | 238 } // namespace |
| 239 } // namespace content | 239 } // namespace content |
| OLD | NEW |