| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/gpu/browser_gpu_channel_host_factory.h" | 5 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
| 9 #include "base/synchronization/waitable_event.h" | 9 #include "base/synchronization/waitable_event.h" |
| 10 #include "base/threading/thread_restrictions.h" | 10 #include "base/threading/thread_restrictions.h" |
| 11 #include "base/tracked_objects.h" |
| 11 #include "content/browser/gpu/gpu_data_manager_impl.h" | 12 #include "content/browser/gpu/gpu_data_manager_impl.h" |
| 12 #include "content/browser/gpu/gpu_memory_buffer_factory_host_impl.h" | 13 #include "content/browser/gpu/gpu_memory_buffer_factory_host_impl.h" |
| 13 #include "content/browser/gpu/gpu_process_host.h" | 14 #include "content/browser/gpu/gpu_process_host.h" |
| 14 #include "content/browser/gpu/gpu_surface_tracker.h" | 15 #include "content/browser/gpu/gpu_surface_tracker.h" |
| 15 #include "content/common/child_process_host_impl.h" | 16 #include "content/common/child_process_host_impl.h" |
| 16 #include "content/common/gpu/client/gpu_memory_buffer_impl.h" | 17 #include "content/common/gpu/client/gpu_memory_buffer_impl.h" |
| 17 #include "content/common/gpu/gpu_messages.h" | 18 #include "content/common/gpu/gpu_messages.h" |
| 18 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
| 19 #include "content/public/browser/gpu_data_manager.h" | 20 #include "content/public/browser/gpu_data_manager.h" |
| 20 #include "content/public/common/content_client.h" | 21 #include "content/public/common/content_client.h" |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 BrowserGpuChannelHostFactory* factory = | 190 BrowserGpuChannelHostFactory* factory = |
| 190 BrowserGpuChannelHostFactory::instance(); | 191 BrowserGpuChannelHostFactory::instance(); |
| 191 factory->GpuChannelEstablished(); | 192 factory->GpuChannelEstablished(); |
| 192 finished_ = true; | 193 finished_ = true; |
| 193 } | 194 } |
| 194 } | 195 } |
| 195 | 196 |
| 196 void BrowserGpuChannelHostFactory::EstablishRequest::Wait() { | 197 void BrowserGpuChannelHostFactory::EstablishRequest::Wait() { |
| 197 DCHECK(main_loop_->BelongsToCurrentThread()); | 198 DCHECK(main_loop_->BelongsToCurrentThread()); |
| 198 { | 199 { |
| 200 // Since the current task synchronously waits for establishing a GPU |
| 201 // channel, it shouldn't be tallied because its execution time has nothing |
| 202 // to do with its efficiency. Using task stopwatch to exclude the waiting |
| 203 // time from the current task run time. |
| 204 tracked_objects::TaskStopwatch stopwatch; |
| 199 // We're blocking the UI thread, which is generally undesirable. | 205 // We're blocking the UI thread, which is generally undesirable. |
| 200 // In this case we need to wait for this before we can show any UI | 206 // In this case we need to wait for this before we can show any UI |
| 201 // /anyway/, so it won't cause additional jank. | 207 // /anyway/, so it won't cause additional jank. |
| 202 // TODO(piman): Make this asynchronous (http://crbug.com/125248). | 208 // TODO(piman): Make this asynchronous (http://crbug.com/125248). |
| 203 TRACE_EVENT0("browser", | 209 TRACE_EVENT0("browser", |
| 204 "BrowserGpuChannelHostFactory::EstablishGpuChannelSync"); | 210 "BrowserGpuChannelHostFactory::EstablishGpuChannelSync"); |
| 205 base::ThreadRestrictions::ScopedAllowWait allow_wait; | 211 base::ThreadRestrictions::ScopedAllowWait allow_wait; |
| 206 event_.Wait(); | 212 event_.Wait(); |
| 213 |
| 214 stopwatch.Stop(); |
| 207 } | 215 } |
| 208 FinishOnMain(); | 216 FinishOnMain(); |
| 209 } | 217 } |
| 210 | 218 |
| 211 void BrowserGpuChannelHostFactory::EstablishRequest::Cancel() { | 219 void BrowserGpuChannelHostFactory::EstablishRequest::Cancel() { |
| 212 DCHECK(main_loop_->BelongsToCurrentThread()); | 220 DCHECK(main_loop_->BelongsToCurrentThread()); |
| 213 finished_ = true; | 221 finished_ = true; |
| 214 } | 222 } |
| 215 | 223 |
| 216 bool BrowserGpuChannelHostFactory::CanUseForTesting() { | 224 bool BrowserGpuChannelHostFactory::CanUseForTesting() { |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 void BrowserGpuChannelHostFactory::OnGpuMemoryBufferCreated( | 485 void BrowserGpuChannelHostFactory::OnGpuMemoryBufferCreated( |
| 478 AllocateGpuMemoryBufferRequest* request, | 486 AllocateGpuMemoryBufferRequest* request, |
| 479 scoped_ptr<GpuMemoryBufferImpl> buffer) { | 487 scoped_ptr<GpuMemoryBufferImpl> buffer) { |
| 480 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 488 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 481 | 489 |
| 482 request->result = buffer.PassAs<gfx::GpuMemoryBuffer>(); | 490 request->result = buffer.PassAs<gfx::GpuMemoryBuffer>(); |
| 483 request->event.Signal(); | 491 request->event.Signal(); |
| 484 } | 492 } |
| 485 | 493 |
| 486 } // namespace content | 494 } // namespace content |
| OLD | NEW |