| 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 <string> |    7 #include <string> | 
|    8 #include <vector> |    8 #include <vector> | 
|    9  |    9  | 
|   10 #include "base/bind.h" |   10 #include "base/bind.h" | 
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   67   if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess) || |   67   if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess) || | 
|   68       CommandLine::ForCurrentProcess()->HasSwitch(switches::kInProcessGPU)) { |   68       CommandLine::ForCurrentProcess()->HasSwitch(switches::kInProcessGPU)) { | 
|   69     // For single process and in-process GPU mode, we need to load and |   69     // For single process and in-process GPU mode, we need to load and | 
|   70     // initialize the GL implementation and locate the GL entry points here. |   70     // initialize the GL implementation and locate the GL entry points here. | 
|   71     if (!gfx::GLSurface::InitializeOneOff()) { |   71     if (!gfx::GLSurface::InitializeOneOff()) { | 
|   72       VLOG(1) << "gfx::GLSurface::InitializeOneOff()"; |   72       VLOG(1) << "gfx::GLSurface::InitializeOneOff()"; | 
|   73     } |   73     } | 
|   74   } |   74   } | 
|   75 } |   75 } | 
|   76  |   76  | 
|   77  |  | 
|   78 GpuChildThread::~GpuChildThread() { |   77 GpuChildThread::~GpuChildThread() { | 
|   79   logging::SetLogMessageHandler(NULL); |   78   logging::SetLogMessageHandler(NULL); | 
|   80 } |   79 } | 
|   81  |   80  | 
|   82 void GpuChildThread::Init(const base::Time& process_start_time) { |   81 void GpuChildThread::Init(const base::Time& process_start_time) { | 
|   83   process_start_time_ = process_start_time; |   82   process_start_time_ = process_start_time; | 
|   84 } |   83 } | 
|   85  |   84  | 
|   86 bool GpuChildThread::Send(IPC::Message* msg) { |   85 bool GpuChildThread::Send(IPC::Message* msg) { | 
|   87   // The GPU process must never send a synchronous IPC message to the browser |   86   // The GPU process must never send a synchronous IPC message to the browser | 
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  127   // We don't need to pipe log messages if we are running the GPU thread in |  126   // We don't need to pipe log messages if we are running the GPU thread in | 
|  128   // the browser process. |  127   // the browser process. | 
|  129   if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess) && |  128   if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess) && | 
|  130       !CommandLine::ForCurrentProcess()->HasSwitch(switches::kInProcessGPU)) |  129       !CommandLine::ForCurrentProcess()->HasSwitch(switches::kInProcessGPU)) | 
|  131     logging::SetLogMessageHandler(GpuProcessLogMessageHandler); |  130     logging::SetLogMessageHandler(GpuProcessLogMessageHandler); | 
|  132  |  131  | 
|  133   // Record initialization only after collecting the GPU info because that can |  132   // Record initialization only after collecting the GPU info because that can | 
|  134   // take a significant amount of time. |  133   // take a significant amount of time. | 
|  135   gpu_info_.initialization_time = base::Time::Now() - process_start_time_; |  134   gpu_info_.initialization_time = base::Time::Now() - process_start_time_; | 
|  136  |  135  | 
|  137  |  | 
|  138   // Defer creation of the render thread. This is to prevent it from handling |  136   // Defer creation of the render thread. This is to prevent it from handling | 
|  139   // IPC messages before the sandbox has been enabled and all other necessary |  137   // IPC messages before the sandbox has been enabled and all other necessary | 
|  140   // initialization has succeeded. |  138   // initialization has succeeded. | 
|  141   gpu_channel_manager_.reset(new GpuChannelManager( |  139   gpu_channel_manager_.reset(new GpuChannelManager( | 
|  142       this, |  140       this, | 
|  143       watchdog_thread_, |  141       watchdog_thread_, | 
|  144       ChildProcess::current()->io_message_loop_proxy(), |  142       ChildProcess::current()->io_message_loop_proxy(), | 
|  145       ChildProcess::current()->GetShutDownEvent())); |  143       ChildProcess::current()->GetShutDownEvent())); | 
|  146  |  144  | 
|  147 #if defined(OS_LINUX) |  | 
|  148   // Ensure the browser process receives the GPU info before a reply to any |  145   // Ensure the browser process receives the GPU info before a reply to any | 
|  149   // subsequent IPC it might send. |  146   // subsequent IPC it might send. | 
|  150   Send(new GpuHostMsg_GraphicsInfoCollected(gpu_info_)); |  147   Send(new GpuHostMsg_GraphicsInfoCollected(gpu_info_)); | 
|  151 #endif |  | 
|  152 } |  148 } | 
|  153  |  149  | 
|  154 void GpuChildThread::StopWatchdog() { |  150 void GpuChildThread::StopWatchdog() { | 
|  155   if (watchdog_thread_.get()) { |  151   if (watchdog_thread_.get()) { | 
|  156     watchdog_thread_->Stop(); |  152     watchdog_thread_->Stop(); | 
|  157   } |  153   } | 
|  158 } |  154 } | 
|  159  |  155  | 
|  160 void GpuChildThread::OnCollectGraphicsInfo() { |  156 void GpuChildThread::OnCollectGraphicsInfo() { | 
|  161 #if defined(OS_WIN) |  157 #if defined(OS_WIN) | 
|  162   // GPU full info collection should only happen on un-sandboxed GPU process |  158   // GPU full info collection should only happen on un-sandboxed GPU process | 
|  163   // or single process/in-process gpu mode on Windows. |  159   // or single process/in-process gpu mode on Windows. | 
|  164   CommandLine* command_line = CommandLine::ForCurrentProcess(); |  160   CommandLine* command_line = CommandLine::ForCurrentProcess(); | 
|  165   DCHECK(command_line->HasSwitch(switches::kDisableGpuSandbox) || |  161   DCHECK(command_line->HasSwitch(switches::kDisableGpuSandbox) || | 
|  166          command_line->HasSwitch(switches::kSingleProcess) || |  162          command_line->HasSwitch(switches::kSingleProcess) || | 
|  167          command_line->HasSwitch(switches::kInProcessGPU)); |  163          command_line->HasSwitch(switches::kInProcessGPU)); | 
|  168 #endif  // OS_WIN |  164 #endif  // OS_WIN | 
|  169  |  165  | 
|  170   // Sandbox state is not part of the gpu info collection.  It is determined |  166   if (!gpu_info_collector::CollectContextGraphicsInfo(&gpu_info_)) | 
|  171   // in GpuMain() and passed down to GpuChildThread. |  | 
|  172   bool sandboxed = gpu_info_.sandboxed; |  | 
|  173   if (!gpu_info_collector::CollectGraphicsInfo(&gpu_info_)) |  | 
|  174     VLOG(1) << "gpu_info_collector::CollectGraphicsInfo failed"; |  167     VLOG(1) << "gpu_info_collector::CollectGraphicsInfo failed"; | 
|  175   gpu_info_.sandboxed = sandboxed; |  | 
|  176   GetContentClient()->SetGpuInfo(gpu_info_); |  168   GetContentClient()->SetGpuInfo(gpu_info_); | 
|  177  |  169  | 
|  178 #if defined(OS_WIN) |  170 #if defined(OS_WIN) | 
|  179   // This is slow, but it's the only thing the unsandboxed GPU process does, |  171   // This is slow, but it's the only thing the unsandboxed GPU process does, | 
|  180   // and GpuDataManager prevents us from sending multiple collecting requests, |  172   // and GpuDataManager prevents us from sending multiple collecting requests, | 
|  181   // so it's OK to be blocking. |  173   // so it's OK to be blocking. | 
|  182   gpu_info_collector::GetDxDiagnostics(&gpu_info_.dx_diagnostics); |  174   gpu_info_collector::GetDxDiagnostics(&gpu_info_.dx_diagnostics); | 
|  183   gpu_info_.finalized = true; |  175   gpu_info_.finalized = true; | 
|  184 #endif  // OS_WIN |  176 #endif  // OS_WIN | 
|  185  |  177  | 
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  235     // the future posting of tasks to the message loop. |  227     // the future posting of tasks to the message loop. | 
|  236     if (watchdog_thread_->message_loop()) |  228     if (watchdog_thread_->message_loop()) | 
|  237       watchdog_thread_->PostAcknowledge(); |  229       watchdog_thread_->PostAcknowledge(); | 
|  238     // Prevent rearming. |  230     // Prevent rearming. | 
|  239     watchdog_thread_->Stop(); |  231     watchdog_thread_->Stop(); | 
|  240   } |  232   } | 
|  241 } |  233 } | 
|  242  |  234  | 
|  243 }  // namespace content |  235 }  // namespace content | 
|  244  |  236  | 
| OLD | NEW |