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_process_host.h" | 13 #include "content/browser/gpu/gpu_process_host.h" |
13 #include "content/browser/gpu/gpu_surface_tracker.h" | 14 #include "content/browser/gpu/gpu_surface_tracker.h" |
14 #include "content/common/child_process_host_impl.h" | 15 #include "content/common/child_process_host_impl.h" |
15 #include "content/common/gpu/client/gpu_memory_buffer_impl.h" | 16 #include "content/common/gpu/client/gpu_memory_buffer_impl.h" |
16 #include "content/common/gpu/gpu_messages.h" | 17 #include "content/common/gpu/gpu_messages.h" |
17 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
18 #include "content/public/browser/gpu_data_manager.h" | 19 #include "content/public/browser/gpu_data_manager.h" |
19 #include "content/public/common/content_client.h" | 20 #include "content/public/common/content_client.h" |
20 #include "ipc/ipc_channel_handle.h" | 21 #include "ipc/ipc_channel_handle.h" |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 BrowserGpuChannelHostFactory* factory = | 163 BrowserGpuChannelHostFactory* factory = |
163 BrowserGpuChannelHostFactory::instance(); | 164 BrowserGpuChannelHostFactory::instance(); |
164 factory->GpuChannelEstablished(); | 165 factory->GpuChannelEstablished(); |
165 finished_ = true; | 166 finished_ = true; |
166 } | 167 } |
167 } | 168 } |
168 | 169 |
169 void BrowserGpuChannelHostFactory::EstablishRequest::Wait() { | 170 void BrowserGpuChannelHostFactory::EstablishRequest::Wait() { |
170 DCHECK(main_loop_->BelongsToCurrentThread()); | 171 DCHECK(main_loop_->BelongsToCurrentThread()); |
171 { | 172 { |
| 173 // Since the current task synchronously waits for establishing a GPU |
| 174 // channel, it shouldn't be tallied because its execution time has nothing |
| 175 // to do with its efficiency. Using task stopwatch to exclude the waiting |
| 176 // time from the current task run time. |
| 177 tracked_objects::TaskStopwatch stopwatch; |
| 178 stopwatch.Start(); |
172 // We're blocking the UI thread, which is generally undesirable. | 179 // We're blocking the UI thread, which is generally undesirable. |
173 // In this case we need to wait for this before we can show any UI | 180 // In this case we need to wait for this before we can show any UI |
174 // /anyway/, so it won't cause additional jank. | 181 // /anyway/, so it won't cause additional jank. |
175 // TODO(piman): Make this asynchronous (http://crbug.com/125248). | 182 // TODO(piman): Make this asynchronous (http://crbug.com/125248). |
176 TRACE_EVENT0("browser", | 183 TRACE_EVENT0("browser", |
177 "BrowserGpuChannelHostFactory::EstablishGpuChannelSync"); | 184 "BrowserGpuChannelHostFactory::EstablishGpuChannelSync"); |
178 base::ThreadRestrictions::ScopedAllowWait allow_wait; | 185 base::ThreadRestrictions::ScopedAllowWait allow_wait; |
179 event_.Wait(); | 186 event_.Wait(); |
| 187 |
| 188 stopwatch.Stop(); |
180 } | 189 } |
181 FinishOnMain(); | 190 FinishOnMain(); |
182 } | 191 } |
183 | 192 |
184 void BrowserGpuChannelHostFactory::EstablishRequest::Cancel() { | 193 void BrowserGpuChannelHostFactory::EstablishRequest::Cancel() { |
185 DCHECK(main_loop_->BelongsToCurrentThread()); | 194 DCHECK(main_loop_->BelongsToCurrentThread()); |
186 finished_ = true; | 195 finished_ = true; |
187 } | 196 } |
188 | 197 |
189 bool BrowserGpuChannelHostFactory::CanUseForTesting() { | 198 bool BrowserGpuChannelHostFactory::CanUseForTesting() { |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 filter->AddRoute(MSG_ROUTING_CONTROL, handler); | 472 filter->AddRoute(MSG_ROUTING_CONTROL, handler); |
464 | 473 |
465 GetIOLoopProxy()->PostTask( | 474 GetIOLoopProxy()->PostTask( |
466 FROM_HERE, | 475 FROM_HERE, |
467 base::Bind(&BrowserGpuChannelHostFactory::AddFilterOnIO, | 476 base::Bind(&BrowserGpuChannelHostFactory::AddFilterOnIO, |
468 gpu_host_id_, | 477 gpu_host_id_, |
469 filter)); | 478 filter)); |
470 } | 479 } |
471 | 480 |
472 } // namespace content | 481 } // namespace content |
OLD | NEW |