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 "content/gpu/in_process_gpu_thread.h" | 5 #include "content/gpu/in_process_gpu_thread.h" |
6 | 6 |
| 7 #include "base/time/time.h" |
7 #include "content/common/gpu/gpu_memory_buffer_factory.h" | 8 #include "content/common/gpu/gpu_memory_buffer_factory.h" |
8 #include "content/gpu/gpu_child_thread.h" | 9 #include "content/gpu/gpu_child_thread.h" |
9 #include "content/gpu/gpu_process.h" | 10 #include "content/gpu/gpu_process.h" |
10 #include "gpu/command_buffer/service/sync_point_manager.h" | 11 #include "gpu/command_buffer/service/sync_point_manager.h" |
11 | 12 |
12 namespace content { | 13 namespace content { |
13 | 14 |
14 InProcessGpuThread::InProcessGpuThread( | 15 InProcessGpuThread::InProcessGpuThread( |
15 const InProcessChildThreadParams& params, | 16 const InProcessChildThreadParams& params, |
16 gpu::SyncPointManager* sync_point_manager_override) | 17 gpu::SyncPointManager* sync_point_manager_override) |
17 : base::Thread("Chrome_InProcGpuThread"), | 18 : base::Thread("Chrome_InProcGpuThread"), |
18 params_(params), | 19 params_(params), |
19 gpu_process_(NULL), | 20 gpu_process_(NULL), |
20 sync_point_manager_override_(sync_point_manager_override), | 21 sync_point_manager_override_(sync_point_manager_override), |
21 gpu_memory_buffer_factory_(GpuMemoryBufferFactory::Create( | 22 gpu_memory_buffer_factory_(GpuMemoryBufferFactory::Create( |
22 GpuChildThread::GetGpuMemoryBufferFactoryType())) { | 23 GpuChildThread::GetGpuMemoryBufferFactoryType())) { |
23 if (!sync_point_manager_override_) { | 24 if (!sync_point_manager_override_) { |
24 sync_point_manager_.reset(new gpu::SyncPointManager(false)); | 25 sync_point_manager_.reset(new gpu::SyncPointManager(false)); |
25 sync_point_manager_override_ = sync_point_manager_.get(); | 26 sync_point_manager_override_ = sync_point_manager_.get(); |
26 } | 27 } |
27 } | 28 } |
28 | 29 |
29 InProcessGpuThread::~InProcessGpuThread() { | 30 InProcessGpuThread::~InProcessGpuThread() { |
30 Stop(); | 31 Stop(); |
31 } | 32 } |
32 | 33 |
33 void InProcessGpuThread::Init() { | 34 void InProcessGpuThread::Init() { |
34 gpu_process_ = new GpuProcess(); | 35 gpu_process_ = new GpuProcess(); |
| 36 |
35 // The process object takes ownership of the thread object, so do not | 37 // The process object takes ownership of the thread object, so do not |
36 // save and delete the pointer. | 38 // save and delete the pointer. |
37 gpu_process_->set_main_thread(new GpuChildThread( | 39 GpuChildThread* child_thread = new GpuChildThread( |
38 params_, gpu_memory_buffer_factory_.get(), sync_point_manager_override_)); | 40 params_, gpu_memory_buffer_factory_.get(), sync_point_manager_override_); |
| 41 |
| 42 // Since we are in the browser process, use the thread start time as the |
| 43 // process start time. |
| 44 child_thread->Init(base::Time::Now()); |
| 45 |
| 46 gpu_process_->set_main_thread(child_thread); |
39 } | 47 } |
40 | 48 |
41 void InProcessGpuThread::CleanUp() { | 49 void InProcessGpuThread::CleanUp() { |
42 SetThreadWasQuitProperly(true); | 50 SetThreadWasQuitProperly(true); |
43 delete gpu_process_; | 51 delete gpu_process_; |
44 } | 52 } |
45 | 53 |
46 base::Thread* CreateInProcessGpuThread( | 54 base::Thread* CreateInProcessGpuThread( |
47 const InProcessChildThreadParams& params) { | 55 const InProcessChildThreadParams& params) { |
48 return new InProcessGpuThread(params, nullptr); | 56 return new InProcessGpuThread(params, nullptr); |
49 } | 57 } |
50 | 58 |
51 } // namespace content | 59 } // namespace content |
OLD | NEW |