| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/run_loop.h" | 6 #include "base/run_loop.h" |
| 7 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" | 7 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" |
| 8 #include "content/browser/gpu/gpu_process_host_ui_shim.h" | 8 #include "content/browser/gpu/gpu_process_host_ui_shim.h" |
| 9 #include "content/common/gpu/client/context_provider_command_buffer.h" | 9 #include "content/common/gpu/client/context_provider_command_buffer.h" |
| 10 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" | 10 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 virtual void SetUpOnMainThread() OVERRIDE { | 28 virtual void SetUpOnMainThread() OVERRIDE { |
| 29 if (!content::BrowserGpuChannelHostFactory::CanUseForTesting()) | 29 if (!content::BrowserGpuChannelHostFactory::CanUseForTesting()) |
| 30 return; | 30 return; |
| 31 | 31 |
| 32 if (!content::BrowserGpuChannelHostFactory::instance()) | 32 if (!content::BrowserGpuChannelHostFactory::instance()) |
| 33 content::BrowserGpuChannelHostFactory::Initialize(true); | 33 content::BrowserGpuChannelHostFactory::Initialize(true); |
| 34 | 34 |
| 35 content::BrowserGpuChannelHostFactory* factory = | 35 content::BrowserGpuChannelHostFactory* factory = |
| 36 content::BrowserGpuChannelHostFactory::instance(); | 36 content::BrowserGpuChannelHostFactory::instance(); |
| 37 CHECK(factory); | 37 CHECK(factory); |
| 38 bool lose_context_when_out_of_memory = false; |
| 38 scoped_refptr<content::GpuChannelHost> gpu_channel_host( | 39 scoped_refptr<content::GpuChannelHost> gpu_channel_host( |
| 39 factory->EstablishGpuChannelSync(kInitCause)); | 40 factory->EstablishGpuChannelSync(kInitCause)); |
| 40 context_.reset( | 41 context_.reset( |
| 41 WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext( | 42 WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext( |
| 42 gpu_channel_host.get(), | 43 gpu_channel_host.get(), |
| 43 blink::WebGraphicsContext3D::Attributes(), | 44 blink::WebGraphicsContext3D::Attributes(), |
| 45 lose_context_when_out_of_memory, |
| 44 GURL(), | 46 GURL(), |
| 45 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits(), | 47 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits(), |
| 46 NULL)); | 48 NULL)); |
| 47 CHECK(context_.get()); | 49 CHECK(context_.get()); |
| 48 context_->makeContextCurrent(); | 50 context_->makeContextCurrent(); |
| 49 context_support_ = context_->GetContextSupport(); | 51 context_support_ = context_->GetContextSupport(); |
| 50 ContentBrowserTest::SetUpOnMainThread(); | 52 ContentBrowserTest::SetUpOnMainThread(); |
| 51 } | 53 } |
| 52 | 54 |
| 53 virtual void TearDownOnMainThread() OVERRIDE { | 55 virtual void TearDownOnMainThread() OVERRIDE { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 GpuChannelHost* GetGpuChannel() { | 110 GpuChannelHost* GetGpuChannel() { |
| 109 return GetFactory()->GetGpuChannel(); | 111 return GetFactory()->GetGpuChannel(); |
| 110 } | 112 } |
| 111 | 113 |
| 112 static void Signal(bool *event) { | 114 static void Signal(bool *event) { |
| 113 CHECK_EQ(*event, false); | 115 CHECK_EQ(*event, false); |
| 114 *event = true; | 116 *event = true; |
| 115 } | 117 } |
| 116 | 118 |
| 117 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> CreateContext() { | 119 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> CreateContext() { |
| 120 bool lose_context_when_out_of_memory = false; |
| 118 return make_scoped_ptr( | 121 return make_scoped_ptr( |
| 119 WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext( | 122 WebGraphicsContext3DCommandBufferImpl::CreateOffscreenContext( |
| 120 GetGpuChannel(), | 123 GetGpuChannel(), |
| 121 blink::WebGraphicsContext3D::Attributes(), | 124 blink::WebGraphicsContext3D::Attributes(), |
| 125 lose_context_when_out_of_memory, |
| 122 GURL(), | 126 GURL(), |
| 123 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits(), | 127 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits(), |
| 124 NULL)); | 128 NULL)); |
| 125 } | 129 } |
| 126 }; | 130 }; |
| 127 | 131 |
| 128 // Fails since UI Compositor establishes a GpuChannel. | 132 // Fails since UI Compositor establishes a GpuChannel. |
| 129 IN_PROC_BROWSER_TEST_F(BrowserGpuChannelHostFactoryTest, DISABLED_Basic) { | 133 IN_PROC_BROWSER_TEST_F(BrowserGpuChannelHostFactoryTest, DISABLED_Basic) { |
| 130 DCHECK(!IsChannelEstablished()); | 134 DCHECK(!IsChannelEstablished()); |
| 131 EstablishAndWait(); | 135 EstablishAndWait(); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 shim->SimulateCrash(); | 186 shim->SimulateCrash(); |
| 183 run_loop.Run(); | 187 run_loop.Run(); |
| 184 | 188 |
| 185 EXPECT_EQ(1, counter); | 189 EXPECT_EQ(1, counter); |
| 186 EXPECT_FALSE(IsChannelEstablished()); | 190 EXPECT_FALSE(IsChannelEstablished()); |
| 187 EstablishAndWait(); | 191 EstablishAndWait(); |
| 188 EXPECT_TRUE(IsChannelEstablished()); | 192 EXPECT_TRUE(IsChannelEstablished()); |
| 189 } | 193 } |
| 190 | 194 |
| 191 } // namespace content | 195 } // namespace content |
| OLD | NEW |