Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(415)

Side by Side Diff: content/gpu/gpu_watchdog_thread.h

Issue 836473003: Avoid gpu watchdog crash on timeout if X is un-responsive. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments addressed. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | content/gpu/gpu_watchdog_thread.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_GPU_GPU_WATCHDOG_THREAD_H_ 5 #ifndef CONTENT_GPU_GPU_WATCHDOG_THREAD_H_
6 #define CONTENT_GPU_GPU_WATCHDOG_THREAD_H_ 6 #define CONTENT_GPU_GPU_WATCHDOG_THREAD_H_
7 7
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "base/power_monitor/power_observer.h" 11 #include "base/power_monitor/power_observer.h"
12 #include "base/threading/thread.h" 12 #include "base/threading/thread.h"
13 #include "base/time/time.h" 13 #include "base/time/time.h"
14 #include "content/common/gpu/gpu_watchdog.h" 14 #include "content/common/gpu/gpu_watchdog.h"
15 #include "ui/gfx/native_widget_types.h"
16
17 #if defined(USE_X11)
18 extern "C" {
19 #include <X11/Xlib.h>
20 #include <X11/Xatom.h>
21 }
22 #include <sys/poll.h>
23 #include "ui/base/x/x11_util.h"
24 #include "ui/gfx/x/x11_types.h"
25
26 #endif
15 27
16 namespace content { 28 namespace content {
17 29
18 // A thread that intermitently sends tasks to a group of watched message loops 30 // A thread that intermitently sends tasks to a group of watched message loops
19 // and deliberately crashes if one of them does not respond after a timeout. 31 // and deliberately crashes if one of them does not respond after a timeout.
20 class GpuWatchdogThread : public base::Thread, 32 class GpuWatchdogThread : public base::Thread,
21 public GpuWatchdog, 33 public GpuWatchdog,
22 public base::PowerObserver, 34 public base::PowerObserver,
23 public base::RefCountedThreadSafe<GpuWatchdogThread> { 35 public base::RefCountedThreadSafe<GpuWatchdogThread> {
24 public: 36 public:
(...skipping 30 matching lines...) Expand all
55 67
56 private: 68 private:
57 GpuWatchdogThread* watchdog_; 69 GpuWatchdogThread* watchdog_;
58 }; 70 };
59 71
60 ~GpuWatchdogThread() override; 72 ~GpuWatchdogThread() override;
61 73
62 void OnAcknowledge(); 74 void OnAcknowledge();
63 void OnCheck(bool after_suspend); 75 void OnCheck(bool after_suspend);
64 void DeliberatelyTerminateToRecoverFromHang(); 76 void DeliberatelyTerminateToRecoverFromHang();
77 #if defined(USE_X11)
78 void SetupXServer();
79 void SetupXChangeProp();
80 bool MatchXEventAtom(XEvent* event);
81 #endif
65 82
66 void OnAddPowerObserver(); 83 void OnAddPowerObserver();
67 84
68 // Implement PowerObserver. 85 // Implement PowerObserver.
69 void OnSuspend() override; 86 void OnSuspend() override;
70 void OnResume() override; 87 void OnResume() override;
71 88
72 #if defined(OS_WIN) 89 #if defined(OS_WIN)
73 base::TimeDelta GetWatchedThreadTime(); 90 base::TimeDelta GetWatchedThreadTime();
74 #endif 91 #endif
(...skipping 11 matching lines...) Expand all
86 // Time after which it's assumed that the computer has been suspended since 103 // Time after which it's assumed that the computer has been suspended since
87 // the task was posted. 104 // the task was posted.
88 base::Time suspension_timeout_; 105 base::Time suspension_timeout_;
89 106
90 bool suspended_; 107 bool suspended_;
91 108
92 #if defined(OS_CHROMEOS) 109 #if defined(OS_CHROMEOS)
93 FILE* tty_file_; 110 FILE* tty_file_;
94 #endif 111 #endif
95 112
113 #if defined(USE_X11)
114 XDisplay* display_;
115 gfx::AcceleratedWidget window_;
116 XAtom atom_;
117 #endif
118
96 base::WeakPtrFactory<GpuWatchdogThread> weak_factory_; 119 base::WeakPtrFactory<GpuWatchdogThread> weak_factory_;
97 120
98 DISALLOW_COPY_AND_ASSIGN(GpuWatchdogThread); 121 DISALLOW_COPY_AND_ASSIGN(GpuWatchdogThread);
99 }; 122 };
100 123
101 } // namespace content 124 } // namespace content
102 125
103 #endif // CONTENT_GPU_GPU_WATCHDOG_THREAD_H_ 126 #endif // CONTENT_GPU_GPU_WATCHDOG_THREAD_H_
OLDNEW
« no previous file with comments | « no previous file | content/gpu/gpu_watchdog_thread.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698