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

Unified Diff: content/browser/loader/content_size_resource_handler.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/content_size_resource_handler.cc
diff --git a/content/browser/loader/content_size_resource_handler.cc b/content/browser/loader/content_size_resource_handler.cc
new file mode 100644
index 0000000000000000000000000000000000000000..724f7e25221dab1c704c9214bcc2f361653c71f3
--- /dev/null
+++ b/content/browser/loader/content_size_resource_handler.cc
@@ -0,0 +1,41 @@
+// Copyright 2016 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/loader/content_size_resource_handler.h"
+
+#include "content/browser/loader/content_size_resource_handler_manager.h"
+#include "net/url_request/url_request.h"
+
+namespace content {
+
+ContentSizeResourceHandler::ContentSizeResourceHandler(
+ std::unique_ptr<ResourceHandler> next_handler,
+ net::URLRequest* request,
+ ContentSizeResourceHandlerManager* manager)
+ : LayeredResourceHandler(request, std::move(next_handler)),
+ manager_(manager) {}
+
+ContentSizeResourceHandler::~ContentSizeResourceHandler() {}
+
+bool ContentSizeResourceHandler::OnWillStart(const GURL& url, bool* defer) {
+ if (manager_->ShouldCancelRequest(GetRequestInfo(), 0))
+ return false;
+ return next_handler_->OnWillStart(url, defer);
+}
+
+bool ContentSizeResourceHandler::OnReadCompleted(int bytes_read, bool* defer) {
+ if (manager_->ShouldCancelRequest(GetRequestInfo(), bytes_read))
+ return false;
+ return next_handler_->OnReadCompleted(bytes_read, defer);
+}
+
+void ContentSizeResourceHandler::OnResponseCompleted(
+ const net::URLRequestStatus& status,
+ const std::string& security_info,
+ bool* defer) {
+ manager_->NotifyUIThreadReadUpdates();
+ next_handler_->OnResponseCompleted(status, security_info, defer);
+}
+
+} // namespace content
« no previous file with comments | « content/browser/loader/content_size_resource_handler.h ('k') | content/browser/loader/content_size_resource_handler_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698