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

Side by Side Diff: content/browser/loader/loader_io_thread_notifier.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: rebase on dependent PS 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_BROWSER_LOADER_LOADER_IO_THREAD_NOTIFIER 5 #ifndef CONTENT_BROWSER_LOADER_LOADER_IO_THREAD_NOTIFIER
6 #define CONTENT_BROWSER_LOADER_LOADER_IO_THREAD_NOTIFIER 6 #define CONTENT_BROWSER_LOADER_LOADER_IO_THREAD_NOTIFIER
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "content/browser/loader/global_routing_id.h"
10 #include "content/public/browser/navigation_throttle.h"
9 #include "content/public/browser/web_contents_observer.h" 11 #include "content/public/browser/web_contents_observer.h"
10 12
11 namespace content { 13 namespace content {
12 14
15 class FrameTreeNode;
16 class NavigationHandle;
13 class RenderFrameHost; 17 class RenderFrameHost;
14 class WebContents; 18 class WebContents;
15 19
16 // This class is responsible for notifying the IO thread (specifically, the 20 // This class is responsible for notifying the IO thread (specifically, the
17 // ResourceDispatcherHostImpl) of frame events. It has an interace for callers 21 // ResourceDispatcherHostImpl) of frame events. It has an interace for callers
18 // to use and also sends notifications on WebContentsObserver events. All 22 // to use and also sends notifications on WebContentsObserver events. All
19 // methods (static or class) will be called from the UI thread and post to the 23 // methods (static or class) will be called from the UI thread and post to the
20 // IO thread. 24 // IO thread.
21 class LoaderIOThreadNotifier : public WebContentsObserver { 25 class LoaderIOThreadNotifier : public WebContentsObserver {
22 public: 26 public:
23 explicit LoaderIOThreadNotifier(WebContents* web_contents); 27 explicit LoaderIOThreadNotifier(WebContents* web_contents);
24 ~LoaderIOThreadNotifier() override; 28 ~LoaderIOThreadNotifier() override;
25 29
26 // content::WebContentsObserver: 30 // WebContentsObserver:
31 void RenderFrameCreated(RenderFrameHost* render_frame_host) override;
27 void RenderFrameDeleted(RenderFrameHost* render_frame_host) override; 32 void RenderFrameDeleted(RenderFrameHost* render_frame_host) override;
28 33
34 static void UpdateGlobalDataAccounting(
35 std::unique_ptr<std::map<GlobalFrameRoutingId, int>> updates);
36
37 static NavigationThrottle* MaybeCreateThrottle(NavigationHandle* handle);
38 NavigationThrottle::ThrottleCheckResult WillProcessNavigationResponse(
39 NavigationHandle* handle);
40
29 private: 41 private:
42 struct FrameSize {
43 int content_left = 0;
44 int content_limit = 0;
45 };
46
47 // Returns the effective size limit of this FrameTreeNode by walking up the
48 // tree.
49 LoaderIOThreadNotifier::FrameSize* AddNewFrame(FrameTreeNode* node,
50 int limit);
51 LoaderIOThreadNotifier::FrameSize* GetEffectiveLimit(FrameTreeNode* node);
52
53 static void NotifyFramesWentOverSizeLimits(
54 std::unique_ptr<std::set<GlobalFrameRoutingId>> frames);
55 static void NotifyFrameHasLimit(const GlobalFrameRoutingId& frame,
56 int limit);
57
58 void UpdateDataAccounting(
59 std::map<GlobalFrameRoutingId, int> updates);
60
61 // frame_tree_node_id -> FrameSize map.
62 std::map<int, FrameSize> frame_tree_node_sizes_;
mmenke 2016/08/05 17:16:27 This really doesn't belong in something called "Lo
Charlie Harrison 2016/08/08 14:04:39 Fair point. I mainly stuffed this logic here becau
63
30 DISALLOW_COPY_AND_ASSIGN(LoaderIOThreadNotifier); 64 DISALLOW_COPY_AND_ASSIGN(LoaderIOThreadNotifier);
31 }; 65 };
32 66
33 } // namespace content 67 } // namespace content
34 68
35 #endif // CONTENT_BROWSER_LOADER_LOADER_IO_THREAD_NOTIFIER 69 #endif // CONTENT_BROWSER_LOADER_LOADER_IO_THREAD_NOTIFIER
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698