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

Side by Side Diff: content/browser/frame_host/render_widget_host_view_child_frame_browsertest.cc

Issue 2927173002: Prevent CompositingHelper from prematurely Satisfying Surface reference (Closed)
Patch Set: Release a pending sequence if new one received Created 3 years, 6 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
« no previous file with comments | « no previous file | content/renderer/child_frame_compositing_helper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #include "base/macros.h" 5 #include "base/macros.h"
6 #include "cc/surfaces/surface_id.h"
7 #include "cc/surfaces/surface_sequence.h"
6 #include "content/browser/frame_host/frame_tree_node.h" 8 #include "content/browser/frame_host/frame_tree_node.h"
7 #include "content/browser/web_contents/web_contents_impl.h" 9 #include "content/browser/web_contents/web_contents_impl.h"
10 #include "content/common/frame_messages.h"
8 #include "content/common/view_messages.h" 11 #include "content/common/view_messages.h"
9 #include "content/public/browser/render_frame_host.h" 12 #include "content/public/browser/render_frame_host.h"
10 #include "content/public/browser/web_contents.h" 13 #include "content/public/browser/web_contents.h"
11 #include "content/public/test/browser_test_utils.h" 14 #include "content/public/test/browser_test_utils.h"
12 #include "content/public/test/content_browser_test.h" 15 #include "content/public/test/content_browser_test.h"
13 #include "content/public/test/content_browser_test_utils.h" 16 #include "content/public/test/content_browser_test_utils.h"
14 #include "content/public/test/test_utils.h" 17 #include "content/public/test/test_utils.h"
15 #include "content/shell/browser/shell.h" 18 #include "content/shell/browser/shell.h"
16 #include "content/test/content_browser_test_utils_internal.h" 19 #include "content/test/content_browser_test_utils_internal.h"
17 #include "content/test/test_content_browser_client.h" 20 #include "content/test/test_content_browser_client.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 base::RunLoop run_loop; 110 base::RunLoop run_loop;
108 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, 111 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE,
109 run_loop.QuitClosure()); 112 run_loop.QuitClosure());
110 run_loop.Run(); 113 run_loop.Run();
111 114
112 // The child frame's RenderWidgetHostView should now use the auto-resize value 115 // The child frame's RenderWidgetHostView should now use the auto-resize value
113 // for its visible viewport. 116 // for its visible viewport.
114 EXPECT_EQ(gfx::Size(75, 75), rwhv->GetVisibleViewportSize()); 117 EXPECT_EQ(gfx::Size(75, 75), rwhv->GetVisibleViewportSize());
115 } 118 }
116 119
120 // A class to filter RequireSequence and SatisfySequence messages sent from
121 // an embedding renderer for its child's Surfaces.
122 class SurfaceRefMessageFilter : public BrowserMessageFilter {
123 public:
124 SurfaceRefMessageFilter()
125 : BrowserMessageFilter(FrameMsgStart),
126 require_message_loop_runner_(new content::MessageLoopRunner),
127 satisfy_message_loop_runner_(new content::MessageLoopRunner),
128 satisfy_received_(false),
129 require_received_first_(false) {}
130
131 void WaitForRequire() { require_message_loop_runner_->Run(); }
132
133 void WaitForSatisfy() { satisfy_message_loop_runner_->Run(); }
134
135 bool require_received_first() { return require_received_first_; }
136
137 protected:
138 ~SurfaceRefMessageFilter() override {}
139
140 private:
141 // BrowserMessageFilter:
142 bool OnMessageReceived(const IPC::Message& message) override {
143 IPC_BEGIN_MESSAGE_MAP(SurfaceRefMessageFilter, message)
144 IPC_MESSAGE_HANDLER(FrameHostMsg_RequireSequence, OnRequire)
145 IPC_MESSAGE_HANDLER(FrameHostMsg_SatisfySequence, OnSatisfy)
146 IPC_END_MESSAGE_MAP()
147 return false;
148 }
149
150 void OnRequire(const cc::SurfaceId& id, const cc::SurfaceSequence sequence) {
151 content::BrowserThread::PostTask(
152 content::BrowserThread::UI, FROM_HERE,
153 base::Bind(&SurfaceRefMessageFilter::OnRequireOnUI, this));
154 }
155
156 void OnRequireOnUI() {
157 if (!satisfy_received_)
158 require_received_first_ = true;
159 require_message_loop_runner_->Quit();
160 }
161
162 void OnSatisfy(const cc::SurfaceSequence sequence) {
163 content::BrowserThread::PostTask(
164 content::BrowserThread::UI, FROM_HERE,
165 base::Bind(&SurfaceRefMessageFilter::OnSatisfyOnUI, this));
166 }
167
168 void OnSatisfyOnUI() {
169 satisfy_received_ = true;
170 satisfy_message_loop_runner_->Quit();
171 }
172
173 scoped_refptr<content::MessageLoopRunner> require_message_loop_runner_;
174 scoped_refptr<content::MessageLoopRunner> satisfy_message_loop_runner_;
175 bool satisfy_received_;
176 bool require_received_first_;
177
178 DISALLOW_COPY_AND_ASSIGN(SurfaceRefMessageFilter);
179 };
180
181 // Test that when a child frame submits its first compositor frame, the
182 // embedding renderer process properly acquires and releases references to the
183 // new Surface. See https://crbug.com/701175.
184 IN_PROC_BROWSER_TEST_F(RenderWidgetHostViewChildFrameTest,
185 ChildFrameSurfaceReference) {
186 EXPECT_TRUE(NavigateToURL(
187 shell(), embedded_test_server()->GetURL(
188 "a.com", "/cross_site_iframe_factory.html?a(a)")));
189
190 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents())
191 ->GetFrameTree()
192 ->root();
193 ASSERT_EQ(1U, root->child_count());
194
195 scoped_refptr<SurfaceRefMessageFilter> filter = new SurfaceRefMessageFilter();
196 root->current_frame_host()->GetProcess()->AddFilter(filter.get());
197
198 GURL foo_url = embedded_test_server()->GetURL("foo.com", "/title1.html");
199 NavigateFrameToURL(root->child_at(0), foo_url);
200
201 // If one of these messages isn't received, this test times out.
202 filter->WaitForRequire();
203 filter->WaitForSatisfy();
204
205 EXPECT_TRUE(filter->require_received_first());
206 }
207
117 } // namespace content 208 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/renderer/child_frame_compositing_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698