Remove some dead code in devtools for old loading path.
Bug: 934009 Change-Id: I859a008b9a68313d3d0479225d20b2b23acf4de4 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1738667 Commit-Queue: John Abd-El-Malek <jam@chromium.org> Auto-Submit: John Abd-El-Malek <jam@chromium.org> Reviewed-by: Andrey Kosyakov <caseq@chromium.org> Cr-Commit-Position: refs/heads/master@{#684440}
This commit is contained in:

committed by
Commit Bot

parent
1a0997e055
commit
f2ea3ba5d0
@ -688,15 +688,12 @@ jumbo_source_set("browser") {
|
||||
"devtools/devtools_http_handler.h",
|
||||
"devtools/devtools_instrumentation.cc",
|
||||
"devtools/devtools_instrumentation.h",
|
||||
"devtools/devtools_interceptor_controller.cc",
|
||||
"devtools/devtools_interceptor_controller.h",
|
||||
"devtools/devtools_io_context.cc",
|
||||
"devtools/devtools_io_context.h",
|
||||
"devtools/devtools_manager.cc",
|
||||
"devtools/devtools_manager.h",
|
||||
"devtools/devtools_network_interceptor.cc",
|
||||
"devtools/devtools_network_interceptor.h",
|
||||
"devtools/devtools_network_transaction_factory.cc",
|
||||
"devtools/devtools_pipe_handler.cc",
|
||||
"devtools/devtools_pipe_handler.h",
|
||||
"devtools/devtools_protocol_encoding.cc",
|
||||
|
@ -170,16 +170,6 @@ std::vector<std::unique_ptr<NavigationThrottle>> CreateNavigationThrottles(
|
||||
|
||||
DevToolsAgentHostImpl* agent_host =
|
||||
RenderFrameDevToolsAgentHost::GetFor(frame_tree_node);
|
||||
if (agent_host) {
|
||||
// Interception might throttle navigations in inspected frames.
|
||||
for (auto* network_handler :
|
||||
protocol::NetworkHandler::ForAgentHost(agent_host)) {
|
||||
std::unique_ptr<NavigationThrottle> throttle =
|
||||
network_handler->CreateThrottleForNavigation(navigation_handle);
|
||||
if (throttle)
|
||||
result.push_back(std::move(throttle));
|
||||
}
|
||||
}
|
||||
FrameTreeNode* parent = frame_tree_node->parent();
|
||||
if (!parent) {
|
||||
if (WebContentsImpl::FromFrameTreeNode(frame_tree_node)->IsPortal() &&
|
||||
|
@ -1,132 +0,0 @@
|
||||
// Copyright 2017 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 "content/browser/devtools/devtools_interceptor_controller.h"
|
||||
|
||||
#include "base/bind.h"
|
||||
#include "base/supports_user_data.h"
|
||||
#include "base/task/post_task.h"
|
||||
#include "content/browser/frame_host/frame_tree_node.h"
|
||||
#include "content/browser/web_contents/web_contents_impl.h"
|
||||
#include "content/public/browser/browser_context.h"
|
||||
#include "content/public/browser/browser_task_traits.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
|
||||
namespace content {
|
||||
|
||||
namespace {
|
||||
const char kDevToolsInterceptorController[] = "DevToolsInterceptorController";
|
||||
}
|
||||
|
||||
std::unique_ptr<InterceptionHandle>
|
||||
DevToolsInterceptorController::StartInterceptingRequests(
|
||||
const FrameTreeNode* target_frame,
|
||||
std::vector<Pattern> intercepted_patterns,
|
||||
RequestInterceptedCallback callback) {
|
||||
DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
||||
|
||||
const base::UnguessableToken& target_id =
|
||||
target_frame->devtools_frame_token();
|
||||
|
||||
auto filter_entry = std::make_unique<DevToolsNetworkInterceptor::FilterEntry>(
|
||||
target_id, std::move(intercepted_patterns), std::move(callback));
|
||||
DevToolsTargetRegistry::RegistrationHandle registration_handle =
|
||||
target_registry_->RegisterWebContents(
|
||||
WebContentsImpl::FromFrameTreeNode(target_frame));
|
||||
std::unique_ptr<InterceptionHandle> handle(new InterceptionHandle(
|
||||
std::move(registration_handle), interceptor_, filter_entry.get()));
|
||||
|
||||
base::PostTask(FROM_HERE, {BrowserThread::IO},
|
||||
base::BindOnce(&DevToolsNetworkInterceptor::AddFilterEntry,
|
||||
interceptor_, std::move(filter_entry)));
|
||||
return handle;
|
||||
}
|
||||
|
||||
void DevToolsInterceptorController::ContinueInterceptedRequest(
|
||||
std::string interception_id,
|
||||
std::unique_ptr<Modifications> modifications,
|
||||
std::unique_ptr<ContinueInterceptedRequestCallback> callback) {
|
||||
DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
||||
|
||||
base::PostTask(
|
||||
FROM_HERE, {BrowserThread::IO},
|
||||
base::BindOnce(&DevToolsNetworkInterceptor::ContinueInterceptedRequest,
|
||||
interceptor_, interception_id, std::move(modifications),
|
||||
std::move(callback)));
|
||||
}
|
||||
|
||||
bool DevToolsInterceptorController::ShouldCancelNavigation(
|
||||
const GlobalRequestID& global_request_id) {
|
||||
DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
||||
auto it = canceled_navigation_requests_.find(global_request_id);
|
||||
if (it == canceled_navigation_requests_.end())
|
||||
return false;
|
||||
canceled_navigation_requests_.erase(it);
|
||||
return true;
|
||||
}
|
||||
|
||||
void DevToolsInterceptorController::GetResponseBody(
|
||||
std::string interception_id,
|
||||
std::unique_ptr<GetResponseBodyForInterceptionCallback> callback) {
|
||||
DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
||||
base::PostTask(
|
||||
FROM_HERE, {BrowserThread::IO},
|
||||
base::BindOnce(&DevToolsNetworkInterceptor::GetResponseBody, interceptor_,
|
||||
std::move(interception_id), std::move(callback)));
|
||||
}
|
||||
|
||||
void DevToolsInterceptorController::NavigationStarted(
|
||||
const std::string& interception_id,
|
||||
const GlobalRequestID& request_id) {
|
||||
navigation_requests_[interception_id] = request_id;
|
||||
}
|
||||
|
||||
void DevToolsInterceptorController::NavigationFinished(
|
||||
const std::string& interception_id) {
|
||||
navigation_requests_.erase(interception_id);
|
||||
}
|
||||
|
||||
// static
|
||||
DevToolsInterceptorController*
|
||||
DevToolsInterceptorController::FromBrowserContext(BrowserContext* context) {
|
||||
DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
||||
return static_cast<DevToolsInterceptorController*>(
|
||||
context->GetUserData(kDevToolsInterceptorController));
|
||||
}
|
||||
|
||||
DevToolsInterceptorController::DevToolsInterceptorController(
|
||||
base::WeakPtr<DevToolsNetworkInterceptor> interceptor,
|
||||
std::unique_ptr<DevToolsTargetRegistry> target_registry,
|
||||
BrowserContext* browser_context)
|
||||
: interceptor_(interceptor), target_registry_(std::move(target_registry)) {
|
||||
browser_context->SetUserData(
|
||||
kDevToolsInterceptorController,
|
||||
std::unique_ptr<DevToolsInterceptorController>(this));
|
||||
}
|
||||
|
||||
DevToolsInterceptorController::~DevToolsInterceptorController() = default;
|
||||
|
||||
InterceptionHandle::InterceptionHandle(
|
||||
DevToolsTargetRegistry::RegistrationHandle registration,
|
||||
base::WeakPtr<DevToolsNetworkInterceptor> interceptor,
|
||||
DevToolsNetworkInterceptor::FilterEntry* entry)
|
||||
: registration_(registration),
|
||||
interceptor_(std::move(interceptor)),
|
||||
entry_(entry) {}
|
||||
|
||||
InterceptionHandle::~InterceptionHandle() {
|
||||
base::PostTask(FROM_HERE, {BrowserThread::IO},
|
||||
base::BindOnce(&DevToolsNetworkInterceptor::RemoveFilterEntry,
|
||||
interceptor_, entry_));
|
||||
}
|
||||
|
||||
void InterceptionHandle::UpdatePatterns(
|
||||
std::vector<DevToolsNetworkInterceptor::Pattern> patterns) {
|
||||
base::PostTask(
|
||||
FROM_HERE, {BrowserThread::IO},
|
||||
base::BindOnce(&DevToolsNetworkInterceptor::UpdatePatterns, interceptor_,
|
||||
base::Unretained(entry_), std::move(patterns)));
|
||||
}
|
||||
|
||||
} // namespace content
|
@ -1,97 +0,0 @@
|
||||
// Copyright 2017 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 CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_INTERCEPTOR_CONTROLLER_
|
||||
#define CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_INTERCEPTOR_CONTROLLER_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "base/containers/flat_map.h"
|
||||
#include "base/macros.h"
|
||||
#include "base/memory/weak_ptr.h"
|
||||
#include "base/supports_user_data.h"
|
||||
#include "base/unguessable_token.h"
|
||||
#include "content/browser/devtools/devtools_network_interceptor.h"
|
||||
#include "content/browser/devtools/devtools_target_registry.h"
|
||||
|
||||
namespace content {
|
||||
|
||||
class BrowserContext;
|
||||
class FrameTreeNode;
|
||||
class InterceptionHandle;
|
||||
|
||||
struct GlobalRequestID;
|
||||
|
||||
class DevToolsInterceptorController : public base::SupportsUserData::Data {
|
||||
public:
|
||||
using GetResponseBodyForInterceptionCallback =
|
||||
DevToolsNetworkInterceptor::GetResponseBodyForInterceptionCallback;
|
||||
using RequestInterceptedCallback =
|
||||
DevToolsNetworkInterceptor::RequestInterceptedCallback;
|
||||
using ContinueInterceptedRequestCallback =
|
||||
DevToolsNetworkInterceptor::ContinueInterceptedRequestCallback;
|
||||
using Modifications = DevToolsNetworkInterceptor::Modifications;
|
||||
using Pattern = DevToolsNetworkInterceptor::Pattern;
|
||||
|
||||
static DevToolsInterceptorController* FromBrowserContext(
|
||||
BrowserContext* context);
|
||||
|
||||
void ContinueInterceptedRequest(
|
||||
std::string interception_id,
|
||||
std::unique_ptr<Modifications> modifications,
|
||||
std::unique_ptr<ContinueInterceptedRequestCallback> callback);
|
||||
|
||||
std::unique_ptr<InterceptionHandle> StartInterceptingRequests(
|
||||
const FrameTreeNode* target_frame,
|
||||
std::vector<Pattern> intercepted_patterns,
|
||||
RequestInterceptedCallback callback);
|
||||
|
||||
bool ShouldCancelNavigation(const GlobalRequestID& global_request_id);
|
||||
|
||||
void GetResponseBody(
|
||||
std::string request_id,
|
||||
std::unique_ptr<GetResponseBodyForInterceptionCallback> callback);
|
||||
|
||||
~DevToolsInterceptorController() override;
|
||||
|
||||
private:
|
||||
DevToolsInterceptorController(
|
||||
base::WeakPtr<DevToolsNetworkInterceptor> interceptor,
|
||||
std::unique_ptr<DevToolsTargetRegistry> target_registry,
|
||||
BrowserContext* browser_context);
|
||||
|
||||
void NavigationStarted(const std::string& interception_id,
|
||||
const GlobalRequestID& request_id);
|
||||
void NavigationFinished(const std::string& interception_id);
|
||||
|
||||
base::WeakPtr<DevToolsNetworkInterceptor> interceptor_;
|
||||
std::unique_ptr<DevToolsTargetRegistry> target_registry_;
|
||||
base::flat_map<std::string, GlobalRequestID> navigation_requests_;
|
||||
base::flat_set<GlobalRequestID> canceled_navigation_requests_;
|
||||
base::WeakPtrFactory<DevToolsInterceptorController> weak_factory_{this};
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(DevToolsInterceptorController);
|
||||
};
|
||||
|
||||
class InterceptionHandle {
|
||||
public:
|
||||
~InterceptionHandle();
|
||||
void UpdatePatterns(std::vector<DevToolsNetworkInterceptor::Pattern>);
|
||||
|
||||
private:
|
||||
friend class DevToolsInterceptorController;
|
||||
InterceptionHandle(DevToolsTargetRegistry::RegistrationHandle registration,
|
||||
base::WeakPtr<DevToolsNetworkInterceptor> interceptor,
|
||||
DevToolsNetworkInterceptor::FilterEntry* entry);
|
||||
|
||||
DevToolsTargetRegistry::RegistrationHandle registration_;
|
||||
base::WeakPtr<DevToolsNetworkInterceptor> interceptor_;
|
||||
DevToolsNetworkInterceptor::FilterEntry* entry_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(InterceptionHandle);
|
||||
};
|
||||
|
||||
} // namespace content
|
||||
|
||||
#endif // CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_INTERCEPTOR_CONTROLLER_
|
@ -1,17 +0,0 @@
|
||||
// Copyright 2017 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 "content/public/browser/devtools_network_transaction_factory.h"
|
||||
|
||||
#include "services/network/throttling/throttling_network_transaction_factory.h"
|
||||
|
||||
namespace content {
|
||||
|
||||
std::unique_ptr<net::HttpTransactionFactory>
|
||||
CreateDevToolsNetworkTransactionFactory(net::HttpNetworkSession* session) {
|
||||
return std::make_unique<network::ThrottlingNetworkTransactionFactory>(
|
||||
session);
|
||||
}
|
||||
|
||||
} // namespace content
|
@ -20,7 +20,6 @@
|
||||
#include "base/time/time.h"
|
||||
#include "content/browser/background_sync/background_sync_manager.h"
|
||||
#include "content/browser/devtools/devtools_agent_host_impl.h"
|
||||
#include "content/browser/devtools/devtools_interceptor_controller.h"
|
||||
#include "content/browser/devtools/devtools_io_context.h"
|
||||
#include "content/browser/devtools/devtools_stream_pipe.h"
|
||||
#include "content/browser/devtools/devtools_url_loader_interceptor.h"
|
||||
@ -1098,7 +1097,6 @@ Response NetworkHandler::Enable(Maybe<int> max_total_size,
|
||||
|
||||
Response NetworkHandler::Disable() {
|
||||
enabled_ = false;
|
||||
interception_handle_.reset();
|
||||
url_loader_interceptor_.reset();
|
||||
SetNetworkConditions(nullptr);
|
||||
extra_headers_.clear();
|
||||
@ -1791,7 +1789,6 @@ DispatchResponse NetworkHandler::SetRequestInterception(
|
||||
std::unique_ptr<protocol::Array<protocol::Network::RequestPattern>>
|
||||
patterns) {
|
||||
if (patterns->empty()) {
|
||||
interception_handle_.reset();
|
||||
if (url_loader_interceptor_) {
|
||||
url_loader_interceptor_.reset();
|
||||
update_loader_factories_callback_.Run();
|
||||
@ -1819,38 +1816,15 @@ DispatchResponse NetworkHandler::SetRequestInterception(
|
||||
if (!host_)
|
||||
return Response::InternalError();
|
||||
|
||||
if (base::FeatureList::IsEnabled(network::features::kNetworkService)) {
|
||||
if (!url_loader_interceptor_) {
|
||||
url_loader_interceptor_ = std::make_unique<DevToolsURLLoaderInterceptor>(
|
||||
base::BindRepeating(&NetworkHandler::RequestIntercepted,
|
||||
weak_factory_.GetWeakPtr()));
|
||||
url_loader_interceptor_->SetPatterns(interceptor_patterns, true);
|
||||
update_loader_factories_callback_.Run();
|
||||
} else {
|
||||
url_loader_interceptor_->SetPatterns(interceptor_patterns, true);
|
||||
}
|
||||
return Response::OK();
|
||||
}
|
||||
|
||||
WebContents* web_contents = WebContents::FromRenderFrameHost(host_);
|
||||
if (!web_contents)
|
||||
return Response::InternalError();
|
||||
|
||||
DevToolsInterceptorController* interceptor =
|
||||
DevToolsInterceptorController::FromBrowserContext(
|
||||
web_contents->GetBrowserContext());
|
||||
if (!interceptor)
|
||||
return Response::Error("Interception not supported");
|
||||
|
||||
if (interception_handle_) {
|
||||
interception_handle_->UpdatePatterns(interceptor_patterns);
|
||||
if (!url_loader_interceptor_) {
|
||||
url_loader_interceptor_ =
|
||||
std::make_unique<DevToolsURLLoaderInterceptor>(base::BindRepeating(
|
||||
&NetworkHandler::RequestIntercepted, weak_factory_.GetWeakPtr()));
|
||||
url_loader_interceptor_->SetPatterns(interceptor_patterns, true);
|
||||
update_loader_factories_callback_.Run();
|
||||
} else {
|
||||
interception_handle_ = interceptor->StartInterceptingRequests(
|
||||
host_->frame_tree_node(), interceptor_patterns,
|
||||
base::BindRepeating(&NetworkHandler::RequestIntercepted,
|
||||
weak_factory_.GetWeakPtr()));
|
||||
url_loader_interceptor_->SetPatterns(interceptor_patterns, true);
|
||||
}
|
||||
|
||||
return Response::OK();
|
||||
}
|
||||
|
||||
@ -1948,38 +1922,21 @@ void NetworkHandler::ContinueInterceptedRequest(
|
||||
std::move(method), std::move(post_data), std::move(override_headers),
|
||||
std::move(override_auth));
|
||||
|
||||
if (url_loader_interceptor_) {
|
||||
url_loader_interceptor_->ContinueInterceptedRequest(
|
||||
interception_id, std::move(modifications), std::move(callback));
|
||||
if (!url_loader_interceptor_)
|
||||
return;
|
||||
}
|
||||
|
||||
DevToolsInterceptorController* interceptor =
|
||||
DevToolsInterceptorController::FromBrowserContext(browser_context_);
|
||||
if (!interceptor) {
|
||||
callback->sendFailure(Response::InternalError());
|
||||
return;
|
||||
}
|
||||
interceptor->ContinueInterceptedRequest(
|
||||
url_loader_interceptor_->ContinueInterceptedRequest(
|
||||
interception_id, std::move(modifications), std::move(callback));
|
||||
}
|
||||
|
||||
void NetworkHandler::GetResponseBodyForInterception(
|
||||
const String& interception_id,
|
||||
std::unique_ptr<GetResponseBodyForInterceptionCallback> callback) {
|
||||
if (url_loader_interceptor_) {
|
||||
url_loader_interceptor_->GetResponseBody(interception_id,
|
||||
std::move(callback));
|
||||
if (!url_loader_interceptor_)
|
||||
return;
|
||||
}
|
||||
|
||||
DevToolsInterceptorController* interceptor =
|
||||
DevToolsInterceptorController::FromBrowserContext(browser_context_);
|
||||
if (!interceptor) {
|
||||
callback->sendFailure(Response::InternalError());
|
||||
return;
|
||||
}
|
||||
interceptor->GetResponseBody(interception_id, std::move(callback));
|
||||
url_loader_interceptor_->GetResponseBody(interception_id,
|
||||
std::move(callback));
|
||||
}
|
||||
|
||||
void NetworkHandler::TakeResponseBodyForInterceptionAsStream(
|
||||
@ -2091,24 +2048,9 @@ std::unique_ptr<Network::Request> NetworkHandler::CreateRequestFromURLRequest(
|
||||
return request_object;
|
||||
}
|
||||
|
||||
std::unique_ptr<NavigationThrottle> NetworkHandler::CreateThrottleForNavigation(
|
||||
NavigationHandle* navigation_handle) {
|
||||
if (!interception_handle_)
|
||||
return nullptr;
|
||||
std::unique_ptr<NavigationThrottle> throttle(new NetworkNavigationThrottle(
|
||||
weak_factory_.GetWeakPtr(), navigation_handle));
|
||||
return throttle;
|
||||
}
|
||||
|
||||
bool NetworkHandler::ShouldCancelNavigation(
|
||||
const GlobalRequestID& global_request_id) {
|
||||
WebContents* web_contents = WebContents::FromRenderFrameHost(host_);
|
||||
if (!web_contents)
|
||||
return false;
|
||||
DevToolsInterceptorController* interceptor =
|
||||
DevToolsInterceptorController::FromBrowserContext(
|
||||
web_contents->GetBrowserContext());
|
||||
return interceptor && interceptor->ShouldCancelNavigation(global_request_id);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool NetworkHandler::MaybeCreateProxyForInterception(
|
||||
|
@ -41,10 +41,7 @@ class DevToolsAgentHostImpl;
|
||||
class DevToolsIOContext;
|
||||
class RenderFrameHostImpl;
|
||||
class RenderProcessHost;
|
||||
class InterceptionHandle;
|
||||
class NavigationHandle;
|
||||
class NavigationRequest;
|
||||
class NavigationThrottle;
|
||||
class SignedExchangeEnvelope;
|
||||
class StoragePartition;
|
||||
struct GlobalRequestID;
|
||||
@ -210,8 +207,6 @@ class NetworkHandler : public DevToolsDomainHandler,
|
||||
const net::URLRequest* request,
|
||||
const std::string& cookie);
|
||||
|
||||
std::unique_ptr<NavigationThrottle> CreateThrottleForNavigation(
|
||||
NavigationHandle* navigation_handle);
|
||||
bool ShouldCancelNavigation(const GlobalRequestID& global_request_id);
|
||||
void WillSendNavigationRequest(net::HttpRequestHeaders* headers,
|
||||
bool* skip_service_worker,
|
||||
@ -239,7 +234,6 @@ class NetworkHandler : public DevToolsDomainHandler,
|
||||
RenderFrameHostImpl* host_;
|
||||
bool enabled_;
|
||||
std::vector<std::pair<std::string, std::string>> extra_headers_;
|
||||
std::unique_ptr<InterceptionHandle> interception_handle_;
|
||||
std::unique_ptr<DevToolsURLLoaderInterceptor> url_loader_interceptor_;
|
||||
bool bypass_service_worker_;
|
||||
bool cache_disabled_;
|
||||
|
Reference in New Issue
Block a user