Fix bug in load time stats.
[chromium-blink-merge.git] / content / gpu / gpu_child_thread.h
blob3590cf32d61c606b86c7de3a7569b7aca909cfad
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 <string>
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"
24 namespace sandbox {
25 class TargetServices;
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 {
35 public:
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);
45 void StopWatchdog();
47 // ChildThread overrides.
48 virtual bool Send(IPC::Message* msg) OVERRIDE;
49 virtual bool OnControlMessageReceived(const IPC::Message& msg) OVERRIDE;
51 private:
52 // Message handlers.
53 void OnInitialize();
54 void OnCollectGraphicsInfo();
55 void OnGetVideoMemoryUsageStats();
56 void OnClean();
57 void OnCrash();
58 void OnHang();
60 #if defined(USE_TCMALLOC)
61 void OnGetGpuTcmalloc();
62 #endif
64 #if defined(OS_WIN)
65 static void CollectDxDiagnostics(GpuChildThread* thread);
66 static void SetDxDiagnostics(GpuChildThread* thread,
67 const content::DxDiagNode& node);
68 #endif
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_;
76 #if defined(OS_WIN)
77 // Windows specific client sandbox interface.
78 sandbox::TargetServices* target_services_;
80 // Indicates whether DirectX Diagnostics collection is ongoing.
81 bool collecting_dx_diagnostics_;
82 #endif
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_