| 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 "headless/lib/browser/headless_devtools_client_impl.h" | 5 #include "headless/lib/browser/headless_devtools_client_impl.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 } | 126 } |
| 127 return true; | 127 return true; |
| 128 } | 128 } |
| 129 | 129 |
| 130 bool HeadlessDevToolsClientImpl::DispatchEvent( | 130 bool HeadlessDevToolsClientImpl::DispatchEvent( |
| 131 std::unique_ptr<base::Value> owning_message, | 131 std::unique_ptr<base::Value> owning_message, |
| 132 const base::DictionaryValue& message_dict) { | 132 const base::DictionaryValue& message_dict) { |
| 133 std::string method; | 133 std::string method; |
| 134 if (!message_dict.GetString("method", &method)) | 134 if (!message_dict.GetString("method", &method)) |
| 135 return false; | 135 return false; |
| 136 if (method == "Inspector.targetCrashed") |
| 137 renderer_crashed_ = true; |
| 136 EventHandlerMap::const_iterator it = event_handlers_.find(method); | 138 EventHandlerMap::const_iterator it = event_handlers_.find(method); |
| 137 if (it == event_handlers_.end()) { | 139 if (it == event_handlers_.end()) { |
| 138 // Silently swallow errors related to the target crashing. This can be | |
| 139 // observed via HeadlessWebContents::Observer::RenderProcessExited. | |
| 140 if (method == "Inspector.targetCrashed") { | |
| 141 renderer_crashed_ = true; | |
| 142 return true; | |
| 143 } | |
| 144 | |
| 145 NOTREACHED() << "Unknown event: " << method; | 140 NOTREACHED() << "Unknown event: " << method; |
| 146 return false; | 141 return false; |
| 147 } | 142 } |
| 148 if (!it->second.is_null()) { | 143 if (!it->second.is_null()) { |
| 149 const base::DictionaryValue* result_dict; | 144 const base::DictionaryValue* result_dict; |
| 150 if (!message_dict.GetDictionary("params", &result_dict)) { | 145 if (!message_dict.GetDictionary("params", &result_dict)) { |
| 151 NOTREACHED() << "Badly formed event parameters"; | 146 NOTREACHED() << "Badly formed event parameters"; |
| 152 return false; | 147 return false; |
| 153 } | 148 } |
| 154 // DevTools assumes event handling is async so we must post a task here or | 149 // DevTools assumes event handling is async so we must post a task here or |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 HeadlessDevToolsClientImpl::Callback::Callback( | 369 HeadlessDevToolsClientImpl::Callback::Callback( |
| 375 base::Callback<void(const base::Value&)> callback) | 370 base::Callback<void(const base::Value&)> callback) |
| 376 : callback_with_result(callback) {} | 371 : callback_with_result(callback) {} |
| 377 | 372 |
| 378 HeadlessDevToolsClientImpl::Callback::~Callback() {} | 373 HeadlessDevToolsClientImpl::Callback::~Callback() {} |
| 379 | 374 |
| 380 HeadlessDevToolsClientImpl::Callback& HeadlessDevToolsClientImpl::Callback:: | 375 HeadlessDevToolsClientImpl::Callback& HeadlessDevToolsClientImpl::Callback:: |
| 381 operator=(Callback&& other) = default; | 376 operator=(Callback&& other) = default; |
| 382 | 377 |
| 383 } // namespace headless | 378 } // namespace headless |
| OLD | NEW |