| 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_
|
|
|