| 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" |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 #else | 209 #else |
| 210 ui::ContextProviderFactory::SetInstance(nullptr); | 210 ui::ContextProviderFactory::SetInstance(nullptr); |
| 211 ContextProviderFactoryImpl::Terminate(); | 211 ContextProviderFactoryImpl::Terminate(); |
| 212 #endif | 212 #endif |
| 213 } | 213 } |
| 214 | 214 |
| 215 cc::SurfaceId GetSurfaceId() const { | 215 cc::SurfaceId GetSurfaceId() const { |
| 216 DCHECK(view_); | 216 DCHECK(view_); |
| 217 RenderWidgetHostViewChildFrame* rwhvcf = | 217 RenderWidgetHostViewChildFrame* rwhvcf = |
| 218 static_cast<RenderWidgetHostViewChildFrame*>(view_); | 218 static_cast<RenderWidgetHostViewChildFrame*>(view_); |
| 219 if (rwhvcf->local_frame_id_.is_null()) | 219 if (!rwhvcf->local_frame_id_.is_valid()) |
| 220 return cc::SurfaceId(); | 220 return cc::SurfaceId(); |
| 221 return cc::SurfaceId(rwhvcf->frame_sink_id_, rwhvcf->local_frame_id_); | 221 return cc::SurfaceId(rwhvcf->frame_sink_id_, rwhvcf->local_frame_id_); |
| 222 } | 222 } |
| 223 | 223 |
| 224 protected: | 224 protected: |
| 225 TestBrowserThreadBundle thread_bundle_; | 225 TestBrowserThreadBundle thread_bundle_; |
| 226 std::unique_ptr<BrowserContext> browser_context_; | 226 std::unique_ptr<BrowserContext> browser_context_; |
| 227 MockRenderWidgetHostDelegate delegate_; | 227 MockRenderWidgetHostDelegate delegate_; |
| 228 BrowserPluginGuestDelegate browser_plugin_guest_delegate_; | 228 BrowserPluginGuestDelegate browser_plugin_guest_delegate_; |
| 229 std::unique_ptr<TestWebContents> web_contents_; | 229 std::unique_ptr<TestWebContents> web_contents_; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 ASSERT_TRUE(browser_plugin_guest_); | 265 ASSERT_TRUE(browser_plugin_guest_); |
| 266 | 266 |
| 267 view_->SetSize(view_size); | 267 view_->SetSize(view_size); |
| 268 view_->Show(); | 268 view_->Show(); |
| 269 | 269 |
| 270 browser_plugin_guest_->set_attached(true); | 270 browser_plugin_guest_->set_attached(true); |
| 271 view_->OnSwapCompositorFrame( | 271 view_->OnSwapCompositorFrame( |
| 272 0, CreateDelegatedFrame(scale_factor, view_size, view_rect)); | 272 0, CreateDelegatedFrame(scale_factor, view_size, view_rect)); |
| 273 | 273 |
| 274 cc::SurfaceId id = GetSurfaceId(); | 274 cc::SurfaceId id = GetSurfaceId(); |
| 275 if (!id.is_null()) { | 275 if (id.is_valid()) { |
| 276 #if !defined(OS_ANDROID) | 276 #if !defined(OS_ANDROID) |
| 277 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 277 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
| 278 cc::SurfaceManager* manager = factory->GetSurfaceManager(); | 278 cc::SurfaceManager* manager = factory->GetSurfaceManager(); |
| 279 cc::Surface* surface = manager->GetSurfaceForId(id); | 279 cc::Surface* surface = manager->GetSurfaceForId(id); |
| 280 EXPECT_TRUE(surface); | 280 EXPECT_TRUE(surface); |
| 281 // There should be a SurfaceSequence created by the RWHVGuest. | 281 // There should be a SurfaceSequence created by the RWHVGuest. |
| 282 EXPECT_EQ(1u, surface->GetDestructionDependencyCount()); | 282 EXPECT_EQ(1u, surface->GetDestructionDependencyCount()); |
| 283 #endif | 283 #endif |
| 284 // Surface ID should have been passed to BrowserPluginGuest to | 284 // Surface ID should have been passed to BrowserPluginGuest to |
| 285 // be sent to the embedding renderer. | 285 // be sent to the embedding renderer. |
| 286 EXPECT_EQ(id, browser_plugin_guest_->last_surface_id_received_); | 286 EXPECT_EQ(id, browser_plugin_guest_->last_surface_id_received_); |
| 287 EXPECT_EQ(view_size, browser_plugin_guest_->last_frame_size_received_); | 287 EXPECT_EQ(view_size, browser_plugin_guest_->last_frame_size_received_); |
| 288 EXPECT_EQ(scale_factor, browser_plugin_guest_->last_scale_factor_received_); | 288 EXPECT_EQ(scale_factor, browser_plugin_guest_->last_scale_factor_received_); |
| 289 } | 289 } |
| 290 | 290 |
| 291 browser_plugin_guest_->ResetTestData(); | 291 browser_plugin_guest_->ResetTestData(); |
| 292 browser_plugin_guest_->set_has_attached_since_surface_set(true); | 292 browser_plugin_guest_->set_has_attached_since_surface_set(true); |
| 293 | 293 |
| 294 view_->OnSwapCompositorFrame( | 294 view_->OnSwapCompositorFrame( |
| 295 0, CreateDelegatedFrame(scale_factor, view_size, view_rect)); | 295 0, CreateDelegatedFrame(scale_factor, view_size, view_rect)); |
| 296 | 296 |
| 297 id = GetSurfaceId(); | 297 id = GetSurfaceId(); |
| 298 if (!id.is_null()) { | 298 if (id.is_valid()) { |
| 299 #if !defined(OS_ANDROID) | 299 #if !defined(OS_ANDROID) |
| 300 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 300 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
| 301 cc::SurfaceManager* manager = factory->GetSurfaceManager(); | 301 cc::SurfaceManager* manager = factory->GetSurfaceManager(); |
| 302 cc::Surface* surface = manager->GetSurfaceForId(id); | 302 cc::Surface* surface = manager->GetSurfaceForId(id); |
| 303 EXPECT_TRUE(surface); | 303 EXPECT_TRUE(surface); |
| 304 // There should be a SurfaceSequence created by the RWHVGuest. | 304 // There should be a SurfaceSequence created by the RWHVGuest. |
| 305 EXPECT_EQ(1u, surface->GetDestructionDependencyCount()); | 305 EXPECT_EQ(1u, surface->GetDestructionDependencyCount()); |
| 306 #endif | 306 #endif |
| 307 // Surface ID should have been passed to BrowserPluginGuest to | 307 // Surface ID should have been passed to BrowserPluginGuest to |
| 308 // be sent to the embedding renderer. | 308 // be sent to the embedding renderer. |
| 309 EXPECT_EQ(id, browser_plugin_guest_->last_surface_id_received_); | 309 EXPECT_EQ(id, browser_plugin_guest_->last_surface_id_received_); |
| 310 EXPECT_EQ(view_size, browser_plugin_guest_->last_frame_size_received_); | 310 EXPECT_EQ(view_size, browser_plugin_guest_->last_frame_size_received_); |
| 311 EXPECT_EQ(scale_factor, | 311 EXPECT_EQ(scale_factor, |
| 312 browser_plugin_guest_->last_scale_factor_received_); | 312 browser_plugin_guest_->last_scale_factor_received_); |
| 313 } | 313 } |
| 314 | 314 |
| 315 browser_plugin_guest_->set_attached(false); | 315 browser_plugin_guest_->set_attached(false); |
| 316 browser_plugin_guest_->ResetTestData(); | 316 browser_plugin_guest_->ResetTestData(); |
| 317 | 317 |
| 318 view_->OnSwapCompositorFrame( | 318 view_->OnSwapCompositorFrame( |
| 319 0, CreateDelegatedFrame(scale_factor, view_size, view_rect)); | 319 0, CreateDelegatedFrame(scale_factor, view_size, view_rect)); |
| 320 EXPECT_TRUE(GetSurfaceId().is_null()); | 320 EXPECT_FALSE(GetSurfaceId().is_valid()); |
| 321 } | 321 } |
| 322 | 322 |
| 323 } // namespace content | 323 } // namespace content |
| OLD | NEW |