Commit 53d030a1 authored by Karandeep Bhatia's avatar Karandeep Bhatia Committed by Commit Bot

Network servicification: Plumb ResourceContext through WebRequestProxyingURLLoaderFactory.

This CL plumbs the ResourceContext to the WebRequestInfo structure through
WebRequestProxyingURLLoaderFactory. This is necessary to fix
NTPInterceptionWebRequestAPITest.NTPRendererRequestsHidden for the network
servicification path.

BUG=797461, 721414

Cq-Include-Trybots: master.tryserver.chromium.linux:linux_mojo
Change-Id: I2957c1ece0f8f7b44f15156aeb5e554b3a91ff01
Reviewed-on: https://chromium-review.googlesource.com/1029549Reviewed-by: default avatarKen Rockot <rockot@chromium.org>
Commit-Queue: Karan Bhatia <karandeepb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#554556}
parent 39bb0136
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "base/values.h" #include "base/values.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h" #include "content/public/browser/render_process_host.h"
...@@ -451,7 +452,9 @@ bool WebRequestAPI::MaybeProxyURLLoaderFactory( ...@@ -451,7 +452,9 @@ bool WebRequestAPI::MaybeProxyURLLoaderFactory(
} }
auto proxy = base::MakeRefCounted<WebRequestProxyingURLLoaderFactory>( auto proxy = base::MakeRefCounted<WebRequestProxyingURLLoaderFactory>(
frame->GetProcess()->GetBrowserContext(), info_map_); frame->GetProcess()->GetBrowserContext(),
frame->GetProcess()->GetBrowserContext()->GetResourceContext(),
info_map_);
proxies_.emplace(proxy.get(), proxy); proxies_.emplace(proxy.get(), proxy);
BrowserThread::PostTask( BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE, BrowserThread::IO, FROM_HERE,
......
...@@ -287,6 +287,7 @@ WebRequestInfo::WebRequestInfo( ...@@ -287,6 +287,7 @@ WebRequestInfo::WebRequestInfo(
int render_frame_id, int render_frame_id,
std::unique_ptr<ExtensionNavigationUIData> navigation_ui_data, std::unique_ptr<ExtensionNavigationUIData> navigation_ui_data,
int32_t routing_id, int32_t routing_id,
content::ResourceContext* resource_context,
const network::ResourceRequest& request) const network::ResourceRequest& request)
: id(request_id), : id(request_id),
url(request.url), url(request.url),
...@@ -299,7 +300,8 @@ WebRequestInfo::WebRequestInfo( ...@@ -299,7 +300,8 @@ WebRequestInfo::WebRequestInfo(
initiator(request.request_initiator), initiator(request.request_initiator),
type(static_cast<content::ResourceType>(request.resource_type)), type(static_cast<content::ResourceType>(request.resource_type)),
extra_request_headers(request.headers), extra_request_headers(request.headers),
logger(std::make_unique<NetworkServiceLogger>()) { logger(std::make_unique<NetworkServiceLogger>()),
resource_context(resource_context) {
if (url.SchemeIsWSOrWSS()) if (url.SchemeIsWSOrWSS())
web_request_type = WebRequestResourceType::WEB_SOCKET; web_request_type = WebRequestResourceType::WEB_SOCKET;
else else
......
...@@ -74,6 +74,7 @@ struct WebRequestInfo { ...@@ -74,6 +74,7 @@ struct WebRequestInfo {
int render_frame_id, int render_frame_id,
std::unique_ptr<ExtensionNavigationUIData> navigation_ui_data, std::unique_ptr<ExtensionNavigationUIData> navigation_ui_data,
int32_t routing_id, int32_t routing_id,
content::ResourceContext* resource_context,
const network::ResourceRequest& request); const network::ResourceRequest& request);
~WebRequestInfo(); ~WebRequestInfo();
......
...@@ -52,7 +52,7 @@ void WebRequestProxyingURLLoaderFactory::InProgressRequest::Restart() { ...@@ -52,7 +52,7 @@ void WebRequestProxyingURLLoaderFactory::InProgressRequest::Restart() {
request_id_, factory_->render_process_id_, factory_->render_frame_id_, request_id_, factory_->render_process_id_, factory_->render_frame_id_,
factory_->navigation_ui_data_ ? factory_->navigation_ui_data_->DeepCopy() factory_->navigation_ui_data_ ? factory_->navigation_ui_data_->DeepCopy()
: nullptr, : nullptr,
routing_id_, request_); routing_id_, factory_->resource_context_, request_);
auto continuation = auto continuation =
base::BindRepeating(&InProgressRequest::ContinueToBeforeSendHeaders, base::BindRepeating(&InProgressRequest::ContinueToBeforeSendHeaders,
...@@ -404,10 +404,12 @@ void WebRequestProxyingURLLoaderFactory::InProgressRequest::OnRequestError( ...@@ -404,10 +404,12 @@ void WebRequestProxyingURLLoaderFactory::InProgressRequest::OnRequestError(
WebRequestProxyingURLLoaderFactory::WebRequestProxyingURLLoaderFactory( WebRequestProxyingURLLoaderFactory::WebRequestProxyingURLLoaderFactory(
void* browser_context, void* browser_context,
content::ResourceContext* resource_context,
InfoMap* info_map) InfoMap* info_map)
: RefCountedDeleteOnSequence(content::BrowserThread::GetTaskRunnerForThread( : RefCountedDeleteOnSequence(content::BrowserThread::GetTaskRunnerForThread(
content::BrowserThread::IO)), content::BrowserThread::IO)),
browser_context_(browser_context), browser_context_(browser_context),
resource_context_(resource_context),
info_map_(info_map) {} info_map_(info_map) {}
void WebRequestProxyingURLLoaderFactory::StartProxying( void WebRequestProxyingURLLoaderFactory::StartProxying(
......
...@@ -25,6 +25,10 @@ ...@@ -25,6 +25,10 @@
#include "services/network/public/mojom/url_loader_factory.mojom.h" #include "services/network/public/mojom/url_loader_factory.mojom.h"
#include "url/gurl.h" #include "url/gurl.h"
namespace content {
class ResourceContext;
} // namespace content
namespace extensions { namespace extensions {
class ExtensionNavigationUIData; class ExtensionNavigationUIData;
...@@ -131,7 +135,9 @@ class WebRequestProxyingURLLoaderFactory ...@@ -131,7 +135,9 @@ class WebRequestProxyingURLLoaderFactory
DISALLOW_COPY_AND_ASSIGN(InProgressRequest); DISALLOW_COPY_AND_ASSIGN(InProgressRequest);
}; };
WebRequestProxyingURLLoaderFactory(void* browser_context, InfoMap* info_map); WebRequestProxyingURLLoaderFactory(void* browser_context,
content::ResourceContext* resource_context,
InfoMap* info_map);
void StartProxying( void StartProxying(
int render_process_id, int render_process_id,
...@@ -164,6 +170,7 @@ class WebRequestProxyingURLLoaderFactory ...@@ -164,6 +170,7 @@ class WebRequestProxyingURLLoaderFactory
void RemoveRequest(uint64_t request_id); void RemoveRequest(uint64_t request_id);
void* const browser_context_; void* const browser_context_;
content::ResourceContext* const resource_context_;
int render_process_id_ = -1; int render_process_id_ = -1;
int render_frame_id_ = -1; int render_frame_id_ = -1;
std::unique_ptr<ExtensionNavigationUIData> navigation_ui_data_; std::unique_ptr<ExtensionNavigationUIData> navigation_ui_data_;
......
...@@ -154,7 +154,6 @@ ...@@ -154,7 +154,6 @@
-ExtensionWebRequestApiTest.WebRequestDeclarative2 -ExtensionWebRequestApiTest.WebRequestDeclarative2
-ExtensionWebRequestApiTest.WebRequestDiceHeaderProtection -ExtensionWebRequestApiTest.WebRequestDiceHeaderProtection
-ExtensionWebRequestApiTest.WebRequestTypes -ExtensionWebRequestApiTest.WebRequestTypes
-NTPInterceptionWebRequestAPITest.NTPRendererRequestsHidden
# https://crbug.com/721400 # https://crbug.com/721400
# WebSocket with the network service # WebSocket with the network service
......
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