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 25 matching lines...) Expand all Loading... |
36 } | 36 } |
37 | 37 |
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, | |
47 base::TerminationStatus status, | 46 base::TerminationStatus status, |
48 int exit_code) override { | 47 int exit_code) override { |
49 ++process_exits_; | 48 ++process_exits_; |
50 } | 49 } |
51 virtual void RenderProcessHostDestroyed(RenderProcessHost* host) override { | 50 virtual void RenderProcessHostDestroyed(RenderProcessHost* host) override { |
52 ++host_destructions_; | 51 ++host_destructions_; |
53 } | 52 } |
54 | 53 |
55 int process_exits_; | 54 int process_exits_; |
56 int host_destructions_; | 55 int host_destructions_; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 } | 114 } |
116 | 115 |
117 class ShellCloser : public RenderProcessHostObserver { | 116 class ShellCloser : public RenderProcessHostObserver { |
118 public: | 117 public: |
119 ShellCloser(Shell* shell, std::string* logging_string) | 118 ShellCloser(Shell* shell, std::string* logging_string) |
120 : shell_(shell), logging_string_(logging_string) {} | 119 : shell_(shell), logging_string_(logging_string) {} |
121 | 120 |
122 protected: | 121 protected: |
123 // RenderProcessHostObserver: | 122 // RenderProcessHostObserver: |
124 virtual void RenderProcessExited(RenderProcessHost* host, | 123 virtual void RenderProcessExited(RenderProcessHost* host, |
125 base::ProcessHandle handle, | |
126 base::TerminationStatus status, | 124 base::TerminationStatus status, |
127 int exit_code) override { | 125 int exit_code) override { |
128 logging_string_->append("ShellCloser::RenderProcessExited "); | 126 logging_string_->append("ShellCloser::RenderProcessExited "); |
129 shell_->Close(); | 127 shell_->Close(); |
130 } | 128 } |
131 | 129 |
132 virtual void RenderProcessHostDestroyed(RenderProcessHost* host) override { | 130 virtual void RenderProcessHostDestroyed(RenderProcessHost* host) override { |
133 logging_string_->append("ShellCloser::RenderProcessHostDestroyed "); | 131 logging_string_->append("ShellCloser::RenderProcessHostDestroyed "); |
134 } | 132 } |
135 | 133 |
136 Shell* shell_; | 134 Shell* shell_; |
137 std::string* logging_string_; | 135 std::string* logging_string_; |
138 }; | 136 }; |
139 | 137 |
140 class ObserverLogger : public RenderProcessHostObserver { | 138 class ObserverLogger : public RenderProcessHostObserver { |
141 public: | 139 public: |
142 explicit ObserverLogger(std::string* logging_string) | 140 explicit ObserverLogger(std::string* logging_string) |
143 : logging_string_(logging_string), host_destroyed_(false) {} | 141 : logging_string_(logging_string), host_destroyed_(false) {} |
144 | 142 |
145 bool host_destroyed() { return host_destroyed_; } | 143 bool host_destroyed() { return host_destroyed_; } |
146 | 144 |
147 protected: | 145 protected: |
148 // RenderProcessHostObserver: | 146 // RenderProcessHostObserver: |
149 virtual void RenderProcessExited(RenderProcessHost* host, | 147 virtual void RenderProcessExited(RenderProcessHost* host, |
150 base::ProcessHandle handle, | |
151 base::TerminationStatus status, | 148 base::TerminationStatus status, |
152 int exit_code) override { | 149 int exit_code) override { |
153 logging_string_->append("ObserverLogger::RenderProcessExited "); | 150 logging_string_->append("ObserverLogger::RenderProcessExited "); |
154 } | 151 } |
155 | 152 |
156 virtual void RenderProcessHostDestroyed(RenderProcessHost* host) override { | 153 virtual void RenderProcessHostDestroyed(RenderProcessHost* host) override { |
157 logging_string_->append("ObserverLogger::RenderProcessHostDestroyed "); | 154 logging_string_->append("ObserverLogger::RenderProcessHostDestroyed "); |
158 host_destroyed_ = true; | 155 host_destroyed_ = true; |
159 } | 156 } |
160 | 157 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 GURL test_url = embedded_test_server()->GetURL("/simple_page.html"); | 227 GURL test_url = embedded_test_server()->GetURL("/simple_page.html"); |
231 NavigateToURL(shell(), test_url); | 228 NavigateToURL(shell(), test_url); |
232 | 229 |
233 EXPECT_EQ(1, RenderProcessHostCount()); | 230 EXPECT_EQ(1, RenderProcessHostCount()); |
234 EXPECT_EQ(0, process_exits_); | 231 EXPECT_EQ(0, process_exits_); |
235 } | 232 } |
236 #endif | 233 #endif |
237 | 234 |
238 } // namespace | 235 } // namespace |
239 } // namespace content | 236 } // namespace content |
OLD | NEW |