Commit 2653cfc6 authored by Sigurd Schneider's avatar Sigurd Schneider Committed by Commit Bot

[devtools] Resynchronize loadNetworkResource implementation..

..between browser and shell bindings. The interface has gotten out of
sync after crrev.com/c/1951104 which introduced additional error
reporting.

TBR=yangguo@chromium.org

Bug: chromium:1030746
Change-Id: If609eb709156e3d0b2142e631878c8821fc1f84c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2000622Reviewed-by: default avatarSigurd Schneider <sigurds@chromium.org>
Reviewed-by: default avatarJohn Abd-El-Malek <jam@chromium.org>
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#732383}
parent 1d9249a5
...@@ -213,6 +213,7 @@ std::unique_ptr<base::DictionaryValue> BuildObjectForResponse( ...@@ -213,6 +213,7 @@ std::unique_ptr<base::DictionaryValue> BuildObjectForResponse(
} }
response->SetInteger("statusCode", responseCode); response->SetInteger("statusCode", responseCode);
response->SetInteger("netError", net_error); response->SetInteger("netError", net_error);
response->SetString("netErrorName", net::ErrorToString(net_error));
auto headers = std::make_unique<base::DictionaryValue>(); auto headers = std::make_unique<base::DictionaryValue>();
size_t iterator = 0; size_t iterator = 0;
...@@ -707,6 +708,12 @@ void DevToolsUIBindings::HandleMessageFromDevToolsFrontend( ...@@ -707,6 +708,12 @@ void DevToolsUIBindings::HandleMessageFromDevToolsFrontend(
} }
// content::DevToolsAgentHostClient implementation -------------------------- // content::DevToolsAgentHostClient implementation --------------------------
// There is a sibling implementation of DevToolsAgentHostClient in
// content/shell/browser/shell_devtools_bindings.cc
// that is used in layout tests, which only use content_shell.
// The two implementations needs to be kept in sync wrt. the interface they
// provide to the DevTools front-end.
void DevToolsUIBindings::DispatchProtocolMessage( void DevToolsUIBindings::DispatchProtocolMessage(
content::DevToolsAgentHost* agent_host, content::DevToolsAgentHost* agent_host,
base::span<const uint8_t> message) { base::span<const uint8_t> message) {
......
...@@ -56,7 +56,8 @@ std::vector<ShellDevToolsBindings*>* GetShellDevtoolsBindingsInstances() { ...@@ -56,7 +56,8 @@ std::vector<ShellDevToolsBindings*>* GetShellDevtoolsBindingsInstances() {
std::unique_ptr<base::DictionaryValue> BuildObjectForResponse( std::unique_ptr<base::DictionaryValue> BuildObjectForResponse(
const net::HttpResponseHeaders* rh, const net::HttpResponseHeaders* rh,
bool success) { bool success,
int net_error) {
auto response = std::make_unique<base::DictionaryValue>(); auto response = std::make_unique<base::DictionaryValue>();
int responseCode = 200; int responseCode = 200;
if (rh) { if (rh) {
...@@ -66,6 +67,8 @@ std::unique_ptr<base::DictionaryValue> BuildObjectForResponse( ...@@ -66,6 +67,8 @@ std::unique_ptr<base::DictionaryValue> BuildObjectForResponse(
responseCode = 404; responseCode = 404;
} }
response->SetInteger("statusCode", responseCode); response->SetInteger("statusCode", responseCode);
response->SetInteger("netError", net_error);
response->SetString("netErrorName", net::ErrorToString(net_error));
auto headers = std::make_unique<base::DictionaryValue>(); auto headers = std::make_unique<base::DictionaryValue>();
size_t iterator = 0; size_t iterator = 0;
...@@ -126,7 +129,8 @@ class ShellDevToolsBindings::NetworkResourceLoader ...@@ -126,7 +129,8 @@ class ShellDevToolsBindings::NetworkResourceLoader
} }
void OnComplete(bool success) override { void OnComplete(bool success) override {
auto response = BuildObjectForResponse(response_headers_.get(), success); auto response = BuildObjectForResponse(response_headers_.get(), success,
loader_->NetError());
bindings_->SendMessageAck(request_id_, response.get()); bindings_->SendMessageAck(request_id_, response.get());
bindings_->loaders_.erase(bindings_->loaders_.find(this)); bindings_->loaders_.erase(bindings_->loaders_.find(this));
} }
...@@ -285,6 +289,7 @@ void ShellDevToolsBindings::HandleMessageFromDevToolsFrontend( ...@@ -285,6 +289,7 @@ void ShellDevToolsBindings::HandleMessageFromDevToolsFrontend(
if (!gurl.is_valid()) { if (!gurl.is_valid()) {
base::DictionaryValue response; base::DictionaryValue response;
response.SetInteger("statusCode", 404); response.SetInteger("statusCode", 404);
response.SetBoolean("urlValid", false);
SendMessageAck(request_id, &response); SendMessageAck(request_id, &response);
return; return;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment