blob: ff0c9258cd11fed094001d32487961a8d65e3ea4 [file] [log] [blame]
[email protected]f0918242012-02-18 00:30:501// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]7a31f7c2011-03-21 23:22:042// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CONTENT_GPU_GPU_CHILD_THREAD_H_
6#define CONTENT_GPU_GPU_CHILD_THREAD_H_
[email protected]7a31f7c2011-03-21 23:22:047
[email protected]ec4bda62013-06-14 15:51:038#include <queue>
[email protected]7a31f7c2011-03-21 23:22:049#include <string>
10
11#include "base/basictypes.h"
12#include "base/command_line.h"
[email protected]3b63f8f42011-03-28 01:54:1513#include "base/memory/ref_counted.h"
14#include "base/memory/scoped_ptr.h"
[email protected]abb522162013-06-28 01:54:1615#include "base/time/time.h"
[email protected]7a31f7c2011-03-21 23:22:0416#include "build/build_config.h"
[email protected]10208ea2013-06-06 20:08:0317#include "content/child/child_thread.h"
[email protected]f24a1e2b2011-04-08 01:48:4818#include "content/common/gpu/gpu_channel.h"
19#include "content/common/gpu/gpu_channel_manager.h"
20#include "content/common/gpu/gpu_config.h"
[email protected]f24a1e2b2011-04-08 01:48:4821#include "content/common/gpu/x_util.h"
[email protected]d7b5cc72013-05-23 20:05:0022#include "gpu/config/gpu_info.h"
[email protected]7a31f7c2011-03-21 23:22:0423#include "ui/gfx/native_widget_types.h"
24
[email protected]7a31f7c2011-03-21 23:22:0425namespace sandbox {
26class TargetServices;
27}
28
[email protected]eb398192012-10-22 20:16:1929namespace content {
[email protected]7a31f7c2011-03-21 23:22:0430class GpuWatchdogThread;
31
32// The main thread of the GPU child process. There will only ever be one of
33// these per process. It does process initialization and shutdown. It forwards
[email protected]f24a1e2b2011-04-08 01:48:4834// IPC messages to GpuChannelManager, which is responsible for issuing rendering
[email protected]7a31f7c2011-03-21 23:22:0435// commands to the GPU.
36class GpuChildThread : public ChildThread {
37 public:
[email protected]ec4bda62013-06-14 15:51:0338 typedef std::queue<IPC::Message*> DeferredMessages;
39
[email protected]db6101db2012-10-25 15:20:0840 explicit GpuChildThread(GpuWatchdogThread* gpu_watchdog_thread,
41 bool dead_on_arrival,
[email protected]ec4bda62013-06-14 15:51:0342 const gpu::GPUInfo& gpu_info,
43 const DeferredMessages& deferred_messages);
[email protected]7a31f7c2011-03-21 23:22:0444
45 // For single-process mode.
46 explicit GpuChildThread(const std::string& channel_id);
47
[email protected]3690ebe02011-05-25 09:08:1948 virtual ~GpuChildThread();
[email protected]7a31f7c2011-03-21 23:22:0449
[email protected]ce79d8512013-04-22 22:44:4150 virtual void Shutdown() OVERRIDE;
51
[email protected]7a31f7c2011-03-21 23:22:0452 void Init(const base::Time& process_start_time);
53 void StopWatchdog();
54
55 // ChildThread overrides.
[email protected]edc64de2011-11-17 20:07:3856 virtual bool Send(IPC::Message* msg) OVERRIDE;
57 virtual bool OnControlMessageReceived(const IPC::Message& msg) OVERRIDE;
[email protected]7a31f7c2011-03-21 23:22:0458
59 private:
60 // Message handlers.
61 void OnInitialize();
62 void OnCollectGraphicsInfo();
[email protected]fb246af2012-08-18 03:11:4163 void OnGetVideoMemoryUsageStats();
[email protected]07cb03a2012-10-01 23:52:1164 void OnSetVideoMemoryWindowCount(uint32 window_count);
65
[email protected]184e3f3802011-05-04 20:48:5266 void OnClean();
[email protected]7a31f7c2011-03-21 23:22:0467 void OnCrash();
68 void OnHang();
[email protected]31583a9d2012-11-30 00:37:1769 void OnDisableWatchdog();
[email protected]7a31f7c2011-03-21 23:22:0470
[email protected]3d662c32012-04-25 00:05:1771#if defined(USE_TCMALLOC)
72 void OnGetGpuTcmalloc();
73#endif
74
[email protected]0b2cec62011-07-22 18:13:2875 // Set this flag to true if a fatal error occurred before we receive the
76 // OnInitialize message, in which case we just declare ourselves DOA.
77 bool dead_on_arrival_;
[email protected]7a31f7c2011-03-21 23:22:0478 base::Time process_start_time_;
79 scoped_refptr<GpuWatchdogThread> watchdog_thread_;
80
81#if defined(OS_WIN)
82 // Windows specific client sandbox interface.
83 sandbox::TargetServices* target_services_;
[email protected]7a31f7c2011-03-21 23:22:0484#endif
85
[email protected]f24a1e2b2011-04-08 01:48:4886 scoped_ptr<GpuChannelManager> gpu_channel_manager_;
[email protected]7a31f7c2011-03-21 23:22:0487
88 // Information about the GPU, such as device and vendor ID.
[email protected]d7b5cc72013-05-23 20:05:0089 gpu::GPUInfo gpu_info_;
[email protected]7a31f7c2011-03-21 23:22:0490
[email protected]ec4bda62013-06-14 15:51:0391 // Error messages collected in gpu_main() before the thread is created.
92 DeferredMessages deferred_messages_;
93
[email protected]2d3de5452013-01-18 10:03:4094 // Whether the GPU thread is running in the browser process.
95 bool in_browser_process_;
96
[email protected]7a31f7c2011-03-21 23:22:0497 DISALLOW_COPY_AND_ASSIGN(GpuChildThread);
98};
99
[email protected]eb398192012-10-22 20:16:19100} // namespace content
101
[email protected]7a31f7c2011-03-21 23:22:04102#endif // CONTENT_GPU_GPU_CHILD_THREAD_H_