OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 <iostream> | 5 #include <iostream> |
6 #include <memory> | 6 #include <memory> |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
152 .SetPolicy(emulation::VirtualTimePolicy:: | 152 .SetPolicy(emulation::VirtualTimePolicy:: |
153 PAUSE_IF_NETWORK_FETCHES_PENDING) | 153 PAUSE_IF_NETWORK_FETCHES_PENDING) |
154 .SetBudget(budget_ms) | 154 .SetBudget(budget_ms) |
155 .Build()); | 155 .Build()); |
156 } else { | 156 } else { |
157 PollReadyState(); | 157 PollReadyState(); |
158 } | 158 } |
159 // TODO(skyostil): Implement more features to demonstrate the devtools API. | 159 // TODO(skyostil): Implement more features to demonstrate the devtools API. |
160 } | 160 } |
161 | 161 |
162 void RenderProcessExited(base::TerminationStatus status, | |
163 int exit_code) override { | |
164 if (status == base::TERMINATION_STATUS_NORMAL_TERMINATION) | |
165 return; | |
166 | |
167 LOG(ERROR) << "Abnormal renderer termination."; | |
168 web_contents_->RemoveObserver(this); | |
altimin
2016/11/18 14:36:45
Looks like we do not detail devtools observers her
alex clarke (OOO till 29th)
2016/11/18 14:59:38
I had to figure out why it was crashing. That's (m
| |
169 web_contents_ = nullptr; | |
170 browser_context_->Close(); | |
171 browser_->Shutdown(); | |
172 } | |
173 | |
162 void PollReadyState() { | 174 void PollReadyState() { |
163 // We need to check the current location in addition to the ready state to | 175 // We need to check the current location in addition to the ready state to |
164 // be sure the expected page is ready. | 176 // be sure the expected page is ready. |
165 devtools_client_->GetRuntime()->Evaluate( | 177 devtools_client_->GetRuntime()->Evaluate( |
166 "document.readyState + ' ' + document.location.href", | 178 "document.readyState + ' ' + document.location.href", |
167 base::Bind(&HeadlessShell::OnReadyState, base::Unretained(this))); | 179 base::Bind(&HeadlessShell::OnReadyState, base::Unretained(this))); |
168 } | 180 } |
169 | 181 |
170 void OnReadyState(std::unique_ptr<runtime::EvaluateResult> result) { | 182 void OnReadyState(std::unique_ptr<runtime::EvaluateResult> result) { |
171 std::string ready_state_and_url; | 183 std::string ready_state_and_url; |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
429 } | 441 } |
430 builder.SetWindowSize(parsed_window_size); | 442 builder.SetWindowSize(parsed_window_size); |
431 } | 443 } |
432 | 444 |
433 return HeadlessBrowserMain( | 445 return HeadlessBrowserMain( |
434 builder.Build(), | 446 builder.Build(), |
435 base::Bind(&HeadlessShell::OnStart, base::Unretained(&shell))); | 447 base::Bind(&HeadlessShell::OnStart, base::Unretained(&shell))); |
436 } | 448 } |
437 | 449 |
438 } // namespace headless | 450 } // namespace headless |
OLD | NEW |