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
3 // found in the LICENSE file.
5 #ifndef CONTENT_GPU_GPU_CHILD_THREAD_H_
6 #define CONTENT_GPU_GPU_CHILD_THREAD_H_
10 #include "base/basictypes.h"
11 #include "base/command_line.h"
12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/time.h"
15 #include "build/build_config.h"
16 #include "content/common/child_thread.h"
17 #include "content/common/gpu/gpu_channel.h"
18 #include "content/common/gpu/gpu_channel_manager.h"
19 #include "content/common/gpu/gpu_config.h"
20 #include "content/common/gpu/x_util.h"
21 #include "content/public/common/gpu_info.h"
22 #include "ui/gfx/native_widget_types.h"
28 class GpuWatchdogThread
;
30 // The main thread of the GPU child process. There will only ever be one of
31 // these per process. It does process initialization and shutdown. It forwards
32 // IPC messages to GpuChannelManager, which is responsible for issuing rendering
33 // commands to the GPU.
34 class GpuChildThread
: public ChildThread
{
36 explicit GpuChildThread(bool dead_on_arrival
,
37 const content::GPUInfo
& gpu_info
);
39 // For single-process mode.
40 explicit GpuChildThread(const std::string
& channel_id
);
42 virtual ~GpuChildThread();
44 void Init(const base::Time
& process_start_time
);
47 // ChildThread overrides.
48 virtual bool Send(IPC::Message
* msg
) OVERRIDE
;
49 virtual bool OnControlMessageReceived(const IPC::Message
& msg
) OVERRIDE
;
54 void OnCollectGraphicsInfo();
55 void OnGetVideoMemoryUsageStats();
60 #if defined(USE_TCMALLOC)
61 void OnGetGpuTcmalloc();
65 static void CollectDxDiagnostics(GpuChildThread
* thread
);
66 static void SetDxDiagnostics(GpuChildThread
* thread
,
67 const content::DxDiagNode
& node
);
70 // Set this flag to true if a fatal error occurred before we receive the
71 // OnInitialize message, in which case we just declare ourselves DOA.
72 bool dead_on_arrival_
;
73 base::Time process_start_time_
;
74 scoped_refptr
<GpuWatchdogThread
> watchdog_thread_
;
77 // Windows specific client sandbox interface.
78 sandbox::TargetServices
* target_services_
;
80 // Indicates whether DirectX Diagnostics collection is ongoing.
81 bool collecting_dx_diagnostics_
;
84 scoped_ptr
<GpuChannelManager
> gpu_channel_manager_
;
86 // Information about the GPU, such as device and vendor ID.
87 content::GPUInfo gpu_info_
;
89 DISALLOW_COPY_AND_ASSIGN(GpuChildThread
);
92 #endif // CONTENT_GPU_GPU_CHILD_THREAD_H_