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

Unified Diff: content/browser/loader/content_size_frame_counter.h

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
« no previous file with comments | « content/browser/loader/DEPS ('k') | content/browser/loader/content_size_frame_counter.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/loader/content_size_frame_counter.h
diff --git a/content/browser/loader/content_size_frame_counter.h b/content/browser/loader/content_size_frame_counter.h
new file mode 100644
index 0000000000000000000000000000000000000000..3e53a7d207238fb5cd9d8e2120f45536f19beddf
--- /dev/null
+++ b/content/browser/loader/content_size_frame_counter.h
@@ -0,0 +1,72 @@
+// 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.
+
+#ifndef CONTENT_BROWSER_LOADER_CONTENT_SIZE_FRAME_COUNTER_H_
+#define CONTENT_BROWSER_LOADER_CONTENT_SIZE_FRAME_COUNTER_H_
+
+#include "base/macros.h"
+#include "content/browser/loader/global_routing_id.h"
+#include "content/public/browser/navigation_throttle.h"
+#include "content/public/browser/web_contents_observer.h"
+
+namespace content {
+
+class FrameTreeNode;
+class NavigationHandle;
+class RenderFrameHost;
+class WebContents;
+
+// This class is designed to do all the UI thread data accounting for the size
+// policy feature. It exchanges messages with the
+// ContentSizeResourceHandlerManager on the IO thread.
+class ContentSizeFrameCounter : public WebContentsObserver {
+ public:
+ explicit ContentSizeFrameCounter(WebContents* web_contents);
+ ~ContentSizeFrameCounter() override;
+
+ // WebContentsObserver:
+ void DidFinishNavigation(NavigationHandle* handle) override;
+
+ static void UpdateGlobalDataAccounting(
+ std::unique_ptr<std::map<GlobalFrameRoutingId, uint64_t>> updates);
+
+ private:
+ // TODO(csharrison): It may be useful to include other data here like
+ // |content_limit|.
+ struct FrameSize {
+ // In bytes. This is the source of truth data for how many bytes are left
+ // per frame tree node in |frame_tree_node_sizes_|.
+ uint64_t content_left = 0;
+ };
+
+ // This method walks up the frame tree, and sees if applying |limit| to the
+ // frame is necessary. If a parent frame has a lower effective limit, then the
+ // child frame's limit is not necessary. Returns the effective limit of
+ // |node|.
+ ContentSizeFrameCounter::FrameSize* AddNewFrame(FrameTreeNode* node,
+ uint64_t limit);
+
+ // Walks up the frame tree starting from |node|. Updates the content_left
+ // count of every parent, and collects all of the routing ids to block due to
+ // this update.
+ void ApplyUpdateToTree(FrameTreeNode* node,
+ uint64_t bytes_downloaded,
+ std::set<GlobalFrameRoutingId>* routing_ids_to_block);
+
+ static void NotifyFramesWentOverSizeLimits(
+ std::unique_ptr<std::set<GlobalFrameRoutingId>> frames);
+ static void NotifyFrameHasLimit(const GlobalFrameRoutingId& frame,
+ uint64_t limit);
+
+ void UpdateDataAccounting(std::map<GlobalFrameRoutingId, uint64_t> updates);
+
+ // frame_tree_node_id -> FrameSize map.
+ std::map<int, FrameSize> frame_tree_node_sizes_;
+
+ DISALLOW_COPY_AND_ASSIGN(ContentSizeFrameCounter);
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_LOADER_CONTENT_SIZE_FRAME_COUNTER_H_
« no previous file with comments | « content/browser/loader/DEPS ('k') | content/browser/loader/content_size_frame_counter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698