| 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/gpu/gpu_child_thread.h" | 5 #include "content/gpu/gpu_child_thread.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
| 9 #include "base/threading/worker_pool.h" | 9 #include "base/threading/worker_pool.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 std::string header = str.substr(0, message_start); | 38 std::string header = str.substr(0, message_start); |
| 39 std::string message = str.substr(message_start); | 39 std::string message = str.substr(message_start); |
| 40 | 40 |
| 41 g_thread_safe_sender.Get()->Send(new GpuHostMsg_OnLogMessage( | 41 g_thread_safe_sender.Get()->Send(new GpuHostMsg_OnLogMessage( |
| 42 severity, header, message)); | 42 severity, header, message)); |
| 43 | 43 |
| 44 return false; | 44 return false; |
| 45 } | 45 } |
| 46 | 46 |
| 47 ChildThreadImpl::Options GetOptions() { | 47 ChildThreadImpl::Options GetOptions() { |
| 48 ChildThreadImpl::Options options; | 48 ChildThreadImpl::Options::Builder builder; |
| 49 | 49 |
| 50 #if defined(USE_OZONE) | 50 #if defined(USE_OZONE) |
| 51 IPC::MessageFilter* message_filter = ui::OzonePlatform::GetInstance() | 51 IPC::MessageFilter* message_filter = ui::OzonePlatform::GetInstance() |
| 52 ->GetGpuPlatformSupport() | 52 ->GetGpuPlatformSupport() |
| 53 ->GetMessageFilter(); | 53 ->GetMessageFilter(); |
| 54 if (message_filter) | 54 if (message_filter) |
| 55 options.startup_filters.push_back(message_filter); | 55 builder.AddStartupFilter(message_filter); |
| 56 #endif | 56 #endif |
| 57 | 57 |
| 58 return options; | 58 return builder.Build(); |
| 59 } | 59 } |
| 60 | 60 |
| 61 } // namespace | 61 } // namespace |
| 62 | 62 |
| 63 GpuChildThread::GpuChildThread(GpuWatchdogThread* watchdog_thread, | 63 GpuChildThread::GpuChildThread(GpuWatchdogThread* watchdog_thread, |
| 64 bool dead_on_arrival, | 64 bool dead_on_arrival, |
| 65 const gpu::GPUInfo& gpu_info, | 65 const gpu::GPUInfo& gpu_info, |
| 66 const DeferredMessages& deferred_messages) | 66 const DeferredMessages& deferred_messages) |
| 67 : ChildThreadImpl(GetOptions()), | 67 : ChildThreadImpl(GetOptions()), |
| 68 dead_on_arrival_(dead_on_arrival), | 68 dead_on_arrival_(dead_on_arrival), |
| 69 gpu_info_(gpu_info), | 69 gpu_info_(gpu_info), |
| 70 deferred_messages_(deferred_messages), | 70 deferred_messages_(deferred_messages), |
| 71 in_browser_process_(false) { | 71 in_browser_process_(false) { |
| 72 watchdog_thread_ = watchdog_thread; | 72 watchdog_thread_ = watchdog_thread; |
| 73 #if defined(OS_WIN) | 73 #if defined(OS_WIN) |
| 74 target_services_ = NULL; | 74 target_services_ = NULL; |
| 75 #endif | 75 #endif |
| 76 g_thread_safe_sender.Get() = thread_safe_sender(); | 76 g_thread_safe_sender.Get() = thread_safe_sender(); |
| 77 } | 77 } |
| 78 | 78 |
| 79 GpuChildThread::GpuChildThread(const std::string& channel_id) | 79 GpuChildThread::GpuChildThread(const std::string& channel_id) |
| 80 : ChildThreadImpl(Options(channel_id, false)), | 80 : ChildThreadImpl(Options::Builder() |
| 81 .InBrowserProcess(true) |
| 82 .WithChannelName(channel_id) |
| 83 .Build()), |
| 81 dead_on_arrival_(false), | 84 dead_on_arrival_(false), |
| 82 in_browser_process_(true) { | 85 in_browser_process_(true) { |
| 83 #if defined(OS_WIN) | 86 #if defined(OS_WIN) |
| 84 target_services_ = NULL; | 87 target_services_ = NULL; |
| 85 #endif | 88 #endif |
| 86 DCHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( | 89 DCHECK(base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 87 switches::kSingleProcess) || | 90 switches::kSingleProcess) || |
| 88 base::CommandLine::ForCurrentProcess()->HasSwitch( | 91 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 89 switches::kInProcessGPU)); | 92 switches::kInProcessGPU)); |
| 90 #if !defined(OS_ANDROID) | 93 #if !defined(OS_ANDROID) |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 } | 287 } |
| 285 | 288 |
| 286 void GpuChildThread::OnGpuSwitched() { | 289 void GpuChildThread::OnGpuSwitched() { |
| 287 DVLOG(1) << "GPU: GPU has switched"; | 290 DVLOG(1) << "GPU: GPU has switched"; |
| 288 // Notify observers in the GPU process. | 291 // Notify observers in the GPU process. |
| 289 ui::GpuSwitchingManager::GetInstance()->NotifyGpuSwitched(); | 292 ui::GpuSwitchingManager::GetInstance()->NotifyGpuSwitched(); |
| 290 } | 293 } |
| 291 | 294 |
| 292 } // namespace content | 295 } // namespace content |
| 293 | 296 |
| OLD | NEW |