Index: content/browser/devtools/protocol/network_handler.cc |
diff --git a/content/browser/devtools/protocol/network_handler.cc b/content/browser/devtools/protocol/network_handler.cc |
index 013609738d34bb0c010df75e2bc86050e3b409d1..4e3f2746c56f08364e7a7b8f03a2a7bfb6654140 100644 |
--- a/content/browser/devtools/protocol/network_handler.cc |
+++ b/content/browser/devtools/protocol/network_handler.cc |
@@ -9,6 +9,7 @@ |
#include "base/barrier_closure.h" |
#include "base/command_line.h" |
#include "base/containers/hash_tables.h" |
+#include "base/process/process_handle.h" |
#include "base/strings/string_number_conversions.h" |
#include "base/strings/stringprintf.h" |
#include "base/time/time.h" |
@@ -17,6 +18,7 @@ |
#include "content/browser/devtools/protocol/security.h" |
#include "content/browser/frame_host/frame_tree_node.h" |
#include "content/browser/frame_host/render_frame_host_impl.h" |
+#include "content/common/navigation_params.h" |
#include "content/common/resource_request.h" |
#include "content/common/resource_request_completion_status.h" |
#include "content/public/browser/browser_context.h" |
@@ -31,6 +33,7 @@ |
#include "content/public/common/content_switches.h" |
#include "content/public/common/resource_devtools_info.h" |
#include "content/public/common/resource_response.h" |
+#include "net/base/net_errors.h" |
#include "net/cookies/cookie_store.h" |
#include "net/http/http_response_headers.h" |
#include "net/url_request/url_request_context.h" |
@@ -671,6 +674,53 @@ void NetworkHandler::NavigationPreloadCompleted( |
completion_status.encoded_data_length); |
} |
+void NetworkHandler::NavigationFailed( |
+ const CommonNavigationParams& common_params, |
+ const BeginNavigationParams& begin_params, |
+ net::Error error_code) { |
+ if (!enabled_) |
+ return; |
+ |
+ static int next_id = 0; |
+ std::string request_id = base::IntToString(base::GetCurrentProcId()) + "." + |
+ base::IntToString(++next_id); |
+ std::string error_string = net::ErrorToString(error_code); |
+ bool cancelled = error_code == net::Error::ERR_ABORTED; |
+ |
+ std::unique_ptr<DictionaryValue> headers_dict(DictionaryValue::create()); |
+ net::HttpRequestHeaders headers; |
+ headers.AddHeadersFromString(begin_params.headers); |
+ for (net::HttpRequestHeaders::Iterator it(headers); it.GetNext();) |
+ headers_dict->setString(it.name(), it.value()); |
+ frontend_->RequestWillBeSent( |
+ request_id, request_id /* frameId */, request_id /* loaderId */, |
+ common_params.url.spec(), |
+ Network::Request::Create() |
+ .SetUrl(common_params.url.spec()) |
+ .SetMethod(common_params.method) |
+ .SetHeaders(Object::fromValue(headers_dict.get(), nullptr)) |
+ // Note: the priority value is copied from |
+ // ResourceDispatcherHostImpl::BeginNavigationRequest but there isn't |
+ // a good way of sharing this. |
+ .SetInitialPriority(resourcePriority(net::HIGHEST)) |
+ .SetReferrerPolicy(referrerPolicy(common_params.referrer.policy)) |
+ .Build(), |
+ base::TimeTicks::Now().ToInternalValue() / |
+ static_cast<double>(base::Time::kMicrosecondsPerSecond), |
+ base::Time::Now().ToDoubleT(), |
+ Network::Initiator::Create() |
+ .SetType(Network::Initiator::TypeEnum::Parser) |
+ .Build(), |
+ std::unique_ptr<Network::Response>(), |
+ std::string(Page::ResourceTypeEnum::Document)); |
+ |
+ frontend_->LoadingFailed( |
+ request_id, |
+ base::TimeTicks::Now().ToInternalValue() / |
+ static_cast<double>(base::Time::kMicrosecondsPerSecond), |
+ Page::ResourceTypeEnum::Document, error_string, cancelled); |
+} |
+ |
std::string NetworkHandler::UserAgentOverride() const { |
return enabled_ ? user_agent_ : std::string(); |
} |