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"
29 class GpuWatchdogThread
;
31 // The main thread of the GPU child process. There will only ever be one of
32 // these per process. It does process initialization and shutdown. It forwards
33 // IPC messages to GpuChannelManager, which is responsible for issuing rendering
34 // commands to the GPU.
35 class GpuChildThread
: public ChildThread
{
37 explicit GpuChildThread(GpuWatchdogThread
* gpu_watchdog_thread
,
39 const GPUInfo
& gpu_info
);
41 // For single-process mode.
42 explicit GpuChildThread(const std::string
& channel_id
);
44 virtual ~GpuChildThread();
46 void Init(const base::Time
& process_start_time
);
49 // ChildThread overrides.
50 virtual bool Send(IPC::Message
* msg
) OVERRIDE
;
51 virtual bool OnControlMessageReceived(const IPC::Message
& msg
) OVERRIDE
;
56 void OnCollectGraphicsInfo();
57 void OnGetVideoMemoryUsageStats();
58 void OnSetVideoMemoryWindowCount(uint32 window_count
);
63 void OnDisableWatchdog();
65 #if defined(USE_TCMALLOC)
66 void OnGetGpuTcmalloc();
69 // Set this flag to true if a fatal error occurred before we receive the
70 // OnInitialize message, in which case we just declare ourselves DOA.
71 bool dead_on_arrival_
;
72 base::Time process_start_time_
;
73 scoped_refptr
<GpuWatchdogThread
> watchdog_thread_
;
76 // Windows specific client sandbox interface.
77 sandbox::TargetServices
* target_services_
;
80 scoped_ptr
<GpuChannelManager
> gpu_channel_manager_
;
82 // Information about the GPU, such as device and vendor ID.
85 DISALLOW_COPY_AND_ASSIGN(GpuChildThread
);
88 } // namespace content
90 #endif // CONTENT_GPU_GPU_CHILD_THREAD_H_