Commit 9635d3fe authored by John Abd-El-Malek's avatar John Abd-El-Malek Committed by Commit Bot

Get rid of a dependency on ResourceDispatcherHostImpl reloaded to LoadInfo.

This is in preparation of deleting RDH.

Bug: 934009
Change-Id: I148a4cf6935a33ba97faa4ce4c0fbec71f55f1e4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1724819Reviewed-by: default avatarClark DuVall <cduvall@chromium.org>
Commit-Queue: John Abd-El-Malek <jam@chromium.org>
Cr-Commit-Position: refs/heads/master@{#681914}
parent 8a4b083f
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
#include "content/browser/devtools/devtools_instrumentation.h" #include "content/browser/devtools/devtools_instrumentation.h"
#include "content/browser/devtools/devtools_url_loader_interceptor.h" #include "content/browser/devtools/devtools_url_loader_interceptor.h"
#include "content/browser/frame_host/frame_tree_node.h" #include "content/browser/frame_host/frame_tree_node.h"
#include "content/browser/loader/resource_dispatcher_host_impl.h"
#include "content/browser/loader/webrtc_connections_observer.h" #include "content/browser/loader/webrtc_connections_observer.h"
#include "content/browser/ssl/ssl_client_auth_handler.h" #include "content/browser/ssl/ssl_client_auth_handler.h"
#include "content/browser/ssl/ssl_error_handler.h" #include "content/browser/ssl/ssl_error_handler.h"
...@@ -38,6 +37,7 @@ ...@@ -38,6 +37,7 @@
#include "mojo/public/cpp/bindings/strong_binding.h" #include "mojo/public/cpp/bindings/strong_binding.h"
#include "net/http/http_auth_preferences.h" #include "net/http/http_auth_preferences.h"
#include "net/ssl/client_cert_store.h" #include "net/ssl/client_cert_store.h"
#include "services/network/public/cpp/load_info_util.h"
#include "services/network/public/mojom/network_context.mojom.h" #include "services/network/public/mojom/network_context.mojom.h"
#include "third_party/blink/public/mojom/web_feature/web_feature.mojom.h" #include "third_party/blink/public/mojom/web_feature/web_feature.mojom.h"
...@@ -567,28 +567,26 @@ void NetworkServiceClient::OnFileUploadRequested( ...@@ -567,28 +567,26 @@ void NetworkServiceClient::OnFileUploadRequested(
void NetworkServiceClient::OnLoadingStateUpdate( void NetworkServiceClient::OnLoadingStateUpdate(
std::vector<network::mojom::LoadInfoPtr> infos, std::vector<network::mojom::LoadInfoPtr> infos,
OnLoadingStateUpdateCallback callback) { OnLoadingStateUpdateCallback callback) {
auto rdh_infos = std::make_unique<ResourceDispatcherHostImpl::LoadInfoList>(); std::map<WebContents*, network::mojom::LoadInfo> info_map;
// TODO(jam): once ResourceDispatcherHost is gone remove the translation
// (other than adding the WebContents callback).
for (auto& info : infos) { for (auto& info : infos) {
ResourceDispatcherHostImpl::LoadInfo load_info; auto* web_contents = GetWebContents(info->process_id, info->routing_id);
load_info.host = std::move(info->host); if (!web_contents)
load_info.load_state.state = static_cast<net::LoadState>(info->load_state); continue;
load_info.load_state.param = std::move(info->state_param);
load_info.upload_position = info->upload_position; auto existing = info_map.find(web_contents);
load_info.upload_size = info->upload_size; if (existing == info_map.end() ||
load_info.web_contents_getter = network::LoadInfoIsMoreInteresting(*info, existing->second)) {
base::BindRepeating(GetWebContents, info->process_id, info->routing_id); info_map[web_contents] = *info;
rdh_infos->push_back(std::move(load_info)); }
} }
std::unique_ptr<ResourceDispatcherHostImpl::LoadInfoMap> info_map = for (const auto& load_info : info_map) {
ResourceDispatcherHostImpl::PickMoreInterestingLoadInfos( net::LoadStateWithParam load_state;
std::move(rdh_infos)); load_state.state = static_cast<net::LoadState>(load_info.second.load_state);
for (const auto& load_info : *info_map) { load_state.param = load_info.second.state_param;
static_cast<WebContentsImpl*>(load_info.first) static_cast<WebContentsImpl*>(load_info.first)
->LoadStateChanged(load_info.second.host, load_info.second.load_state, ->LoadStateChanged(load_info.second.host, load_state,
load_info.second.upload_position, load_info.second.upload_position,
load_info.second.upload_size); load_info.second.upload_size);
} }
......
...@@ -53,6 +53,7 @@ ...@@ -53,6 +53,7 @@
#include "services/network/network_context.h" #include "services/network/network_context.h"
#include "services/network/network_usage_accumulator.h" #include "services/network/network_usage_accumulator.h"
#include "services/network/public/cpp/features.h" #include "services/network/public/cpp/features.h"
#include "services/network/public/cpp/load_info_util.h"
#include "services/network/public/cpp/network_switches.h" #include "services/network/public/cpp/network_switches.h"
#include "services/network/url_loader.h" #include "services/network/url_loader.h"
#include "services/network/url_request_context_builder_mojo.h" #include "services/network/url_request_context_builder_mojo.h"
...@@ -109,26 +110,6 @@ std::unique_ptr<net::NetworkChangeNotifier> CreateNetworkChangeNotifierIfNeeded( ...@@ -109,26 +110,6 @@ std::unique_ptr<net::NetworkChangeNotifier> CreateNetworkChangeNotifierIfNeeded(
return nullptr; return nullptr;
} }
// This is duplicated in content/browser/loader/resource_dispatcher_host_impl.cc
bool LoadInfoIsMoreInteresting(const mojom::LoadInfo& a,
const mojom::LoadInfo& b) {
// Set |*_uploading_size| to be the size of the corresponding upload body if
// it's currently being uploaded.
uint64_t a_uploading_size = 0;
if (a.load_state == net::LOAD_STATE_SENDING_REQUEST)
a_uploading_size = a.upload_size;
uint64_t b_uploading_size = 0;
if (b.load_state == net::LOAD_STATE_SENDING_REQUEST)
b_uploading_size = b.upload_size;
if (a_uploading_size != b_uploading_size)
return a_uploading_size > b_uploading_size;
return a.load_state > b.load_state;
}
void OnGetNetworkList(std::unique_ptr<net::NetworkInterfaceList> networks, void OnGetNetworkList(std::unique_ptr<net::NetworkInterfaceList> networks,
mojom::NetworkService::GetNetworkListCallback callback, mojom::NetworkService::GetNetworkListCallback callback,
bool success) { bool success) {
......
...@@ -35,6 +35,8 @@ jumbo_component("cpp") { ...@@ -35,6 +35,8 @@ jumbo_component("cpp") {
"header_util.h", "header_util.h",
"is_potentially_trustworthy.cc", "is_potentially_trustworthy.cc",
"is_potentially_trustworthy.h", "is_potentially_trustworthy.h",
"load_info_util.cc",
"load_info_util.h",
"net_adapters.cc", "net_adapters.cc",
"net_adapters.h", "net_adapters.h",
"network_connection_tracker.cc", "network_connection_tracker.cc",
......
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "services/network/public/cpp/load_info_util.h"
#include "services/network/public/mojom/network_service.mojom.h"
namespace network {
bool LoadInfoIsMoreInteresting(const mojom::LoadInfo& a,
const mojom::LoadInfo& b) {
// Set |*_uploading_size| to be the size of the corresponding upload body if
// it's currently being uploaded.
uint64_t a_uploading_size = 0;
if (a.load_state == net::LOAD_STATE_SENDING_REQUEST)
a_uploading_size = a.upload_size;
uint64_t b_uploading_size = 0;
if (b.load_state == net::LOAD_STATE_SENDING_REQUEST)
b_uploading_size = b.upload_size;
if (a_uploading_size != b_uploading_size)
return a_uploading_size > b_uploading_size;
return a.load_state > b.load_state;
}
} // namespace network
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SERVICES_NETWORK_PUBLIC_CPP_LOAD_INFO_UTIL_H_
#define SERVICES_NETWORK_PUBLIC_CPP_LOAD_INFO_UTIL_H_
#include "base/component_export.h"
namespace network {
namespace mojom {
class LoadInfo;
}
// This function returns true if the LoadInfo of |a| is "more interesting"
// than the LoadInfo of |b|. The load that is currently sending the larger
// request body is considered more interesting. If neither request is
// sending a body (Neither request has a body, or any request that has a body
// is not currently sending the body), the request that is further along is
// considered more interesting.
//
// This takes advantage of the fact that the load states are an enumeration
// listed in the order in which they usually occur during the lifetime of a
// request, so states with larger numeric values are generally further along
// toward completion.
//
// For example, by this measure "tranferring data" is a more interesting state
// than "resolving host" because when transferring data something is being
// done that corresponds to changes that the user might observe, whereas
// waiting for a host name to resolve implies being stuck.
COMPONENT_EXPORT(NETWORK_CPP)
bool LoadInfoIsMoreInteresting(const mojom::LoadInfo& a,
const mojom::LoadInfo& b);
} // namespace network
#endif // SERVICES_NETWORK_PUBLIC_CPP_LOAD_INFO_UTIL_H_
\ No newline at end of file
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