| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/browser/frame_host/render_widget_host_view_guest.h" | 5 #include "content/browser/frame_host/render_widget_host_view_guest.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 12 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
| 13 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
| 14 #include "base/test/scoped_task_scheduler.h" | 14 #include "base/test/scoped_task_scheduler.h" |
| 15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
| 16 #include "cc/surfaces/surface.h" | 16 #include "cc/surfaces/surface.h" |
| 17 #include "cc/surfaces/surface_factory.h" | 17 #include "cc/surfaces/surface_factory.h" |
| 18 #include "cc/surfaces/surface_manager.h" | 18 #include "cc/surfaces/surface_manager.h" |
| 19 #include "cc/surfaces/surface_sequence.h" | 19 #include "cc/surfaces/surface_sequence.h" |
| 20 #include "content/browser/browser_plugin/browser_plugin_guest.h" | 20 #include "content/browser/browser_plugin/browser_plugin_guest.h" |
| 21 #include "content/browser/compositor/test/no_transport_image_transport_factory.h
" | 21 #include "content/browser/compositor/test/no_transport_image_transport_factory.h
" |
| 22 #include "content/browser/gpu/compositor_util.h" | 22 #include "content/browser/gpu/compositor_util.h" |
| 23 #include "content/browser/renderer_host/render_widget_host_delegate.h" | 23 #include "content/browser/renderer_host/render_widget_host_delegate.h" |
| 24 #include "content/browser/renderer_host/render_widget_host_impl.h" | 24 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 25 #include "content/common/view_messages.h" | 25 #include "content/common/view_messages.h" |
| 26 #include "content/public/browser/browser_plugin_guest_delegate.h" | 26 #include "content/public/browser/browser_plugin_guest_delegate.h" |
| 27 #include "content/public/browser/render_widget_host_view.h" | 27 #include "content/public/browser/render_widget_host_view.h" |
| 28 #include "content/public/test/mock_render_process_host.h" | 28 #include "content/public/test/mock_render_process_host.h" |
| 29 #include "content/public/test/test_browser_context.h" | 29 #include "content/public/test/test_browser_context.h" |
| 30 #include "content/test/fake_renderer_compositor_frame_sink.h" |
| 30 #include "content/test/test_render_view_host.h" | 31 #include "content/test/test_render_view_host.h" |
| 31 #include "content/test/test_web_contents.h" | 32 #include "content/test/test_web_contents.h" |
| 32 #include "testing/gtest/include/gtest/gtest.h" | 33 #include "testing/gtest/include/gtest/gtest.h" |
| 33 #include "ui/compositor/compositor.h" | 34 #include "ui/compositor/compositor.h" |
| 34 | 35 |
| 35 namespace content { | 36 namespace content { |
| 36 namespace { | 37 namespace { |
| 37 class MockRenderWidgetHostDelegate : public RenderWidgetHostDelegate { | 38 class MockRenderWidgetHostDelegate : public RenderWidgetHostDelegate { |
| 38 public: | 39 public: |
| 39 MockRenderWidgetHostDelegate() {} | 40 MockRenderWidgetHostDelegate() {} |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 // We don't own the BPG, the WebContents does. | 163 // We don't own the BPG, the WebContents does. |
| 163 browser_plugin_guest_ = new TestBrowserPluginGuest( | 164 browser_plugin_guest_ = new TestBrowserPluginGuest( |
| 164 web_contents_.get(), &browser_plugin_guest_delegate_); | 165 web_contents_.get(), &browser_plugin_guest_delegate_); |
| 165 | 166 |
| 166 int32_t routing_id = process_host->GetNextRoutingID(); | 167 int32_t routing_id = process_host->GetNextRoutingID(); |
| 167 widget_host_ = | 168 widget_host_ = |
| 168 new RenderWidgetHostImpl(&delegate_, process_host, routing_id, false); | 169 new RenderWidgetHostImpl(&delegate_, process_host, routing_id, false); |
| 169 view_ = RenderWidgetHostViewGuest::Create( | 170 view_ = RenderWidgetHostViewGuest::Create( |
| 170 widget_host_, browser_plugin_guest_, | 171 widget_host_, browser_plugin_guest_, |
| 171 (new TestRenderWidgetHostView(widget_host_))->GetWeakPtr()); | 172 (new TestRenderWidgetHostView(widget_host_))->GetWeakPtr()); |
| 173 cc::mojom::MojoCompositorFrameSinkPtr sink; |
| 174 cc::mojom::MojoCompositorFrameSinkRequest sink_request = |
| 175 mojo::MakeRequest(&sink); |
| 176 cc::mojom::MojoCompositorFrameSinkClientPtr client; |
| 177 cc::mojom::MojoCompositorFrameSinkClientRequest client_request = |
| 178 mojo::MakeRequest(&client); |
| 179 renderer_compositor_frame_sink_ = |
| 180 base::MakeUnique<FakeRendererCompositorFrameSink>( |
| 181 std::move(sink), std::move(client_request)); |
| 182 view_->DidCreateNewRendererCompositorFrameSink( |
| 183 renderer_compositor_frame_sink_.get()); |
| 172 } | 184 } |
| 173 | 185 |
| 174 void TearDown() override { | 186 void TearDown() override { |
| 175 if (view_) | 187 if (view_) |
| 176 view_->Destroy(); | 188 view_->Destroy(); |
| 177 delete widget_host_; | 189 delete widget_host_; |
| 178 | 190 |
| 179 // It's important to make sure that the view finishes destructing before | 191 // It's important to make sure that the view finishes destructing before |
| 180 // we hit the destructor for the TestBrowserThreadBundle, so run the message | 192 // we hit the destructor for the TestBrowserThreadBundle, so run the message |
| 181 // loop here. | 193 // loop here. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 199 std::unique_ptr<BrowserContext> browser_context_; | 211 std::unique_ptr<BrowserContext> browser_context_; |
| 200 MockRenderWidgetHostDelegate delegate_; | 212 MockRenderWidgetHostDelegate delegate_; |
| 201 BrowserPluginGuestDelegate browser_plugin_guest_delegate_; | 213 BrowserPluginGuestDelegate browser_plugin_guest_delegate_; |
| 202 std::unique_ptr<TestWebContents> web_contents_; | 214 std::unique_ptr<TestWebContents> web_contents_; |
| 203 TestBrowserPluginGuest* browser_plugin_guest_; | 215 TestBrowserPluginGuest* browser_plugin_guest_; |
| 204 | 216 |
| 205 // Tests should set these to NULL if they've already triggered their | 217 // Tests should set these to NULL if they've already triggered their |
| 206 // destruction. | 218 // destruction. |
| 207 RenderWidgetHostImpl* widget_host_; | 219 RenderWidgetHostImpl* widget_host_; |
| 208 RenderWidgetHostViewGuest* view_; | 220 RenderWidgetHostViewGuest* view_; |
| 221 std::unique_ptr<FakeRendererCompositorFrameSink> |
| 222 renderer_compositor_frame_sink_; |
| 209 | 223 |
| 210 private: | 224 private: |
| 211 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewGuestSurfaceTest); | 225 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewGuestSurfaceTest); |
| 212 }; | 226 }; |
| 213 | 227 |
| 214 namespace { | 228 namespace { |
| 215 cc::CompositorFrame CreateDelegatedFrame(float scale_factor, | 229 cc::CompositorFrame CreateDelegatedFrame(float scale_factor, |
| 216 gfx::Size size, | 230 gfx::Size size, |
| 217 const gfx::Rect& damage) { | 231 const gfx::Rect& damage) { |
| 218 cc::CompositorFrame frame; | 232 cc::CompositorFrame frame; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 | 302 |
| 289 view_->SubmitCompositorFrame( | 303 view_->SubmitCompositorFrame( |
| 290 local_surface_id, | 304 local_surface_id, |
| 291 CreateDelegatedFrame(scale_factor, view_size, view_rect)); | 305 CreateDelegatedFrame(scale_factor, view_size, view_rect)); |
| 292 // Since guest is not attached, the CompositorFrame must be processed but the | 306 // Since guest is not attached, the CompositorFrame must be processed but the |
| 293 // frame must be evicted to return the resources immediately. | 307 // frame must be evicted to return the resources immediately. |
| 294 EXPECT_FALSE(view_->has_frame()); | 308 EXPECT_FALSE(view_->has_frame()); |
| 295 } | 309 } |
| 296 | 310 |
| 297 } // namespace content | 311 } // namespace content |
| OLD | NEW |