Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(804)

Unified Diff: content/browser/loader/resource_dispatcher_host_impl.cc

Issue 2180933002: Add experimental code behind a flag for Content Size Policy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: while -> for Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/loader/resource_dispatcher_host_impl.cc
diff --git a/content/browser/loader/resource_dispatcher_host_impl.cc b/content/browser/loader/resource_dispatcher_host_impl.cc
index 981c71ba454f337c573f6c9b64805d7934a13ce5..7fa16021fdebcc3bcbb9bd4ed81000c2a81e2c2a 100644
--- a/content/browser/loader/resource_dispatcher_host_impl.cc
+++ b/content/browser/loader/resource_dispatcher_host_impl.cc
@@ -47,6 +47,7 @@
#include "content/browser/frame_host/navigator.h"
#include "content/browser/loader/async_resource_handler.h"
#include "content/browser/loader/async_revalidation_manager.h"
+#include "content/browser/loader/content_size_resource_handler_manager.h"
#include "content/browser/loader/cross_site_resource_handler.h"
#include "content/browser/loader/detachable_resource_handler.h"
#include "content/browser/loader/loader_delegate.h"
@@ -1070,6 +1071,10 @@ std::unique_ptr<net::ClientCertStore>
void ResourceDispatcherHostImpl::OnInit() {
scheduler_.reset(new ResourceScheduler);
+ if (base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kContentSizePolicy)) {
+ content_size_manager_.reset(new ContentSizeResourceHandlerManager());
+ }
}
void ResourceDispatcherHostImpl::OnShutdown() {
@@ -1099,6 +1104,7 @@ void ResourceDispatcherHostImpl::OnShutdown() {
}
scheduler_.reset();
+ content_size_manager_.reset();
}
bool ResourceDispatcherHostImpl::OnMessageReceived(
@@ -1679,6 +1685,14 @@ ResourceDispatcherHostImpl::AddStandardHandlers(
BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE)));
}
+ // Insert a handler for inspecting content sizes as they come in. Note that
+ // this handler can cancel requests if they are associated with frames that go
+ // over a prescribed limit.
+ if (content_size_manager_) {
+ handler =
+ content_size_manager_->MaybeAddHandler(std::move(handler), request);
+ }
+
// TODO(ricea): Stop looking this up so much.
ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request);
throttles.push_back(scheduler_->ScheduleRequest(child_id, route_id,
@@ -2279,6 +2293,8 @@ void ResourceDispatcherHostImpl::SetLoaderDelegate(
void ResourceDispatcherHostImpl::OnRenderFrameDeleted(
const GlobalFrameRoutingId& global_routing_id) {
CancelRequestsForRoute(global_routing_id);
+ if (content_size_manager_)
+ content_size_manager_->FrameDeleted(global_routing_id);
}
// static
« no previous file with comments | « content/browser/loader/resource_dispatcher_host_impl.h ('k') | content/browser/loader/resource_request_info_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698