| 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 "base/time/time.h" |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 #include "content/common/gpu/gpu_memory_buffer_factory.h" | 9 #include "content/common/gpu/gpu_memory_buffer_factory.h" |
| 10 #include "content/gpu/gpu_child_thread.h" | 10 #include "content/gpu/gpu_child_thread.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 sync_point_manager_.reset(new gpu::SyncPointManager(false)); | 32 sync_point_manager_.reset(new gpu::SyncPointManager(false)); |
| 33 sync_point_manager_override_ = sync_point_manager_.get(); | 33 sync_point_manager_override_ = sync_point_manager_.get(); |
| 34 } | 34 } |
| 35 } | 35 } |
| 36 | 36 |
| 37 InProcessGpuThread::~InProcessGpuThread() { | 37 InProcessGpuThread::~InProcessGpuThread() { |
| 38 Stop(); | 38 Stop(); |
| 39 } | 39 } |
| 40 | 40 |
| 41 void InProcessGpuThread::Init() { | 41 void InProcessGpuThread::Init() { |
| 42 base::ThreadPriority io_thread_priority = base::ThreadPriority::NORMAL; |
| 43 |
| 44 #if defined(OS_ANDROID) |
| 42 // Call AttachCurrentThreadWithName, before any other AttachCurrentThread() | 45 // Call AttachCurrentThreadWithName, before any other AttachCurrentThread() |
| 43 // calls. The latter causes Java VM to assign Thread-??? to the thread name. | 46 // calls. The latter causes Java VM to assign Thread-??? to the thread name. |
| 44 // Please note calls to AttachCurrentThreadWithName after AttachCurrentThread | 47 // Please note calls to AttachCurrentThreadWithName after AttachCurrentThread |
| 45 // will not change the thread name kept in Java VM. | 48 // will not change the thread name kept in Java VM. |
| 46 #if defined(OS_ANDROID) | |
| 47 base::android::AttachCurrentThreadWithName(thread_name()); | 49 base::android::AttachCurrentThreadWithName(thread_name()); |
| 50 // Up the priority of the |io_thread_| on Android. |
| 51 io_thread_priority = base::ThreadPriority::DISPLAY; |
| 48 #endif | 52 #endif |
| 49 | 53 |
| 50 gpu_process_ = new GpuProcess(); | 54 gpu_process_ = new GpuProcess(io_thread_priority); |
| 51 | 55 |
| 52 // The process object takes ownership of the thread object, so do not | 56 // The process object takes ownership of the thread object, so do not |
| 53 // save and delete the pointer. | 57 // save and delete the pointer. |
| 54 GpuChildThread* child_thread = new GpuChildThread( | 58 GpuChildThread* child_thread = new GpuChildThread( |
| 55 params_, gpu_memory_buffer_factory_.get(), sync_point_manager_override_); | 59 params_, gpu_memory_buffer_factory_.get(), sync_point_manager_override_); |
| 56 | 60 |
| 57 // Since we are in the browser process, use the thread start time as the | 61 // Since we are in the browser process, use the thread start time as the |
| 58 // process start time. | 62 // process start time. |
| 59 child_thread->Init(base::Time::Now()); | 63 child_thread->Init(base::Time::Now()); |
| 60 | 64 |
| 61 gpu_process_->set_main_thread(child_thread); | 65 gpu_process_->set_main_thread(child_thread); |
| 62 } | 66 } |
| 63 | 67 |
| 64 void InProcessGpuThread::CleanUp() { | 68 void InProcessGpuThread::CleanUp() { |
| 65 SetThreadWasQuitProperly(true); | 69 SetThreadWasQuitProperly(true); |
| 66 delete gpu_process_; | 70 delete gpu_process_; |
| 67 } | 71 } |
| 68 | 72 |
| 69 base::Thread* CreateInProcessGpuThread( | 73 base::Thread* CreateInProcessGpuThread( |
| 70 const InProcessChildThreadParams& params) { | 74 const InProcessChildThreadParams& params) { |
| 71 return new InProcessGpuThread(params, nullptr); | 75 return new InProcessGpuThread(params, nullptr); |
| 72 } | 76 } |
| 73 | 77 |
| 74 } // namespace content | 78 } // namespace content |
| OLD | NEW |