blob: 7f1350fd4ab6173abf13ff7a1fc250cca86dab77 [file] [log] [blame]
[email protected]7a31f7c2011-03-21 23:22:041// Copyright (c) 2011 The Chromium Authors. All rights reserved.
2// 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_
7#pragma once
8
9#include <string>
10
11#include "base/basictypes.h"
12#include "base/command_line.h"
13#include "base/ref_counted.h"
14#include "base/scoped_ptr.h"
15#include "base/time.h"
16#include "build/build_config.h"
17#include "content/common/child_thread.h"
18#include "content/common/gpu_info.h"
19#include "content/gpu/gpu_channel.h"
20#include "content/gpu/gpu_config.h"
21#include "content/gpu/gpu_render_thread.h"
22#include "content/gpu/x_util.h"
23#include "ui/gfx/native_widget_types.h"
24
25namespace IPC {
26struct ChannelHandle;
27}
28
29namespace sandbox {
30class TargetServices;
31}
32
33class GpuWatchdogThread;
34
35// The main thread of the GPU child process. There will only ever be one of
36// these per process. It does process initialization and shutdown. It forwards
37// IPC messages to GpuRenderThread, which is responsible for issuing rendering
38// commands to the GPU.
39class GpuChildThread : public ChildThread {
40 public:
41#if defined(OS_WIN)
42 explicit GpuChildThread(sandbox::TargetServices* target_services);
43#else
44 GpuChildThread();
45#endif
46
47 // For single-process mode.
48 explicit GpuChildThread(const std::string& channel_id);
49
50 ~GpuChildThread();
51
52 void Init(const base::Time& process_start_time);
53 void StopWatchdog();
54
55 // ChildThread overrides.
56 virtual bool Send(IPC::Message* msg);
57 virtual bool OnControlMessageReceived(const IPC::Message& msg);
58
59 private:
60 // Message handlers.
61 void OnInitialize();
62 void OnCollectGraphicsInfo();
63 void OnCrash();
64 void OnHang();
65
66#if defined(OS_WIN)
67 static void CollectDxDiagnostics(GpuChildThread* thread);
68 static void SetDxDiagnostics(GpuChildThread* thread, const DxDiagNode& node);
69#endif
70
71 base::Time process_start_time_;
72 scoped_refptr<GpuWatchdogThread> watchdog_thread_;
73
74#if defined(OS_WIN)
75 // Windows specific client sandbox interface.
76 sandbox::TargetServices* target_services_;
77
78 // Indicates whether DirectX Diagnostics collection is ongoing.
79 bool collecting_dx_diagnostics_;
80#endif
81
82 scoped_ptr<GpuRenderThread> render_thread_;
83
84 // Information about the GPU, such as device and vendor ID.
85 GPUInfo gpu_info_;
86
87 DISALLOW_COPY_AND_ASSIGN(GpuChildThread);
88};
89
90#endif // CONTENT_GPU_GPU_CHILD_THREAD_H_