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