Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / content / gpu / gpu_child_thread.h
blobff0c9258cd11fed094001d32487961a8d65e3ea4
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_
8 #include <queue>
9 #include <string>
11 #include "base/basictypes.h"
12 #include "base/command_line.h"
13 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/time/time.h"
16 #include "build/build_config.h"
17 #include "content/child/child_thread.h"
18 #include "content/common/gpu/gpu_channel.h"
19 #include "content/common/gpu/gpu_channel_manager.h"
20 #include "content/common/gpu/gpu_config.h"
21 #include "content/common/gpu/x_util.h"
22 #include "gpu/config/gpu_info.h"
23 #include "ui/gfx/native_widget_types.h"
25 namespace sandbox {
26 class TargetServices;
29 namespace content {
30 class GpuWatchdogThread;
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
34 // IPC messages to GpuChannelManager, which is responsible for issuing rendering
35 // commands to the GPU.
36 class GpuChildThread : public ChildThread {
37 public:
38 typedef std::queue<IPC::Message*> DeferredMessages;
40 explicit GpuChildThread(GpuWatchdogThread* gpu_watchdog_thread,
41 bool dead_on_arrival,
42 const gpu::GPUInfo& gpu_info,
43 const DeferredMessages& deferred_messages);
45 // For single-process mode.
46 explicit GpuChildThread(const std::string& channel_id);
48 virtual ~GpuChildThread();
50 virtual void Shutdown() OVERRIDE;
52 void Init(const base::Time& process_start_time);
53 void StopWatchdog();
55 // ChildThread overrides.
56 virtual bool Send(IPC::Message* msg) OVERRIDE;
57 virtual bool OnControlMessageReceived(const IPC::Message& msg) OVERRIDE;
59 private:
60 // Message handlers.
61 void OnInitialize();
62 void OnCollectGraphicsInfo();
63 void OnGetVideoMemoryUsageStats();
64 void OnSetVideoMemoryWindowCount(uint32 window_count);
66 void OnClean();
67 void OnCrash();
68 void OnHang();
69 void OnDisableWatchdog();
71 #if defined(USE_TCMALLOC)
72 void OnGetGpuTcmalloc();
73 #endif
75 // 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_;
78 base::Time process_start_time_;
79 scoped_refptr<GpuWatchdogThread> watchdog_thread_;
81 #if defined(OS_WIN)
82 // Windows specific client sandbox interface.
83 sandbox::TargetServices* target_services_;
84 #endif
86 scoped_ptr<GpuChannelManager> gpu_channel_manager_;
88 // Information about the GPU, such as device and vendor ID.
89 gpu::GPUInfo gpu_info_;
91 // Error messages collected in gpu_main() before the thread is created.
92 DeferredMessages deferred_messages_;
94 // Whether the GPU thread is running in the browser process.
95 bool in_browser_process_;
97 DISALLOW_COPY_AND_ASSIGN(GpuChildThread);
100 } // namespace content
102 #endif // CONTENT_GPU_GPU_CHILD_THREAD_H_