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

Side by Side Diff: gpu/ipc/service/gpu_watchdog_thread.h

Issue 2286063003: gpu: Move GpuWatchdogThread into //gpu/ipc/service from content. (Closed)
Patch Set: tot merge Created 4 years, 3 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 | « gpu/ipc/service/gpu_watchdog.h ('k') | gpu/ipc/service/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 GPU_IPC_SERVICE_GPU_WATCHDOG_THREAD_H_
6 #define CONTENT_GPU_GPU_WATCHDOG_THREAD_H_ 6 #define GPU_IPC_SERVICE_GPU_WATCHDOG_THREAD_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
11 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
12 #include "base/power_monitor/power_observer.h" 12 #include "base/power_monitor/power_observer.h"
13 #include "base/threading/thread.h" 13 #include "base/threading/thread.h"
14 #include "base/time/time.h" 14 #include "base/time/time.h"
15 #include "build/build_config.h" 15 #include "build/build_config.h"
16 #include "gpu/ipc/service/gpu_watchdog.h" 16 #include "gpu/gpu_export.h"
17 #include "ui/gfx/native_widget_types.h" 17 #include "ui/gfx/native_widget_types.h"
18 18
19 #if defined(USE_X11) 19 #if defined(USE_X11)
20 extern "C" { 20 extern "C" {
21 #include <X11/Xlib.h> 21 #include <X11/Xlib.h>
22 #include <X11/Xatom.h> 22 #include <X11/Xatom.h>
23 } 23 }
24 #include <sys/poll.h> 24 #include <sys/poll.h>
25 #include "ui/base/x/x11_util.h" // nogncheck 25 #include "ui/base/x/x11_util.h" // nogncheck
26 #include "ui/gfx/x/x11_types.h" // nogncheck 26 #include "ui/gfx/x/x11_types.h" // nogncheck
27 #endif 27 #endif // defined(USE_X11)
28 28
29 namespace content { 29 namespace gpu {
30 30
31 // A thread that intermitently sends tasks to a group of watched message loops 31 // A thread that intermitently sends tasks to a group of watched message loops
32 // and deliberately crashes if one of them does not respond after a timeout. 32 // and deliberately crashes if one of them does not respond after a timeout.
33 class GpuWatchdogThread : public base::Thread, 33 class GPU_EXPORT GpuWatchdogThread
34 public gpu::GpuWatchdog, 34 : public base::Thread,
35 public base::PowerObserver, 35 public base::PowerObserver,
36 public base::RefCountedThreadSafe<GpuWatchdogThread> { 36 public base::RefCountedThreadSafe<GpuWatchdogThread> {
37 public: 37 public:
38 explicit GpuWatchdogThread(int timeout); 38 static scoped_refptr<GpuWatchdogThread> Create();
39 39
40 // Accessible on watched thread but only modified by watchdog thread. 40 // Accessible on watched thread but only modified by watchdog thread.
41 bool armed() const { return armed_; } 41 bool armed() const { return armed_; }
42 void PostAcknowledge(); 42 void PostAcknowledge();
43 43
44 // Implement gpu::GpuWatchdog. 44 void CheckArmed();
45 void CheckArmed() override;
46 45
47 // Must be called after a PowerMonitor has been created. Can be called from 46 // Must be called after a PowerMonitor has been created. Can be called from
48 // any thread. 47 // any thread.
49 void AddPowerObserver(); 48 void AddPowerObserver();
50 49
51 protected: 50 protected:
52 void Init() override; 51 void Init() override;
53 void CleanUp() override; 52 void CleanUp() override;
54 53
55 private: 54 private:
56 friend class base::RefCountedThreadSafe<GpuWatchdogThread>; 55 friend class base::RefCountedThreadSafe<GpuWatchdogThread>;
57 56
58 // An object of this type intercepts the reception and completion of all tasks 57 // An object of this type intercepts the reception and completion of all tasks
59 // on the watched thread and checks whether the watchdog is armed. 58 // on the watched thread and checks whether the watchdog is armed.
60 class GpuWatchdogTaskObserver : public base::MessageLoop::TaskObserver { 59 class GpuWatchdogTaskObserver : public base::MessageLoop::TaskObserver {
61 public: 60 public:
62 explicit GpuWatchdogTaskObserver(GpuWatchdogThread* watchdog); 61 explicit GpuWatchdogTaskObserver(GpuWatchdogThread* watchdog);
63 ~GpuWatchdogTaskObserver() override; 62 ~GpuWatchdogTaskObserver() override;
64 63
65 // Implements MessageLoop::TaskObserver. 64 // Implements MessageLoop::TaskObserver.
66 void WillProcessTask(const base::PendingTask& pending_task) override; 65 void WillProcessTask(const base::PendingTask& pending_task) override;
67 void DidProcessTask(const base::PendingTask& pending_task) override; 66 void DidProcessTask(const base::PendingTask& pending_task) override;
68 67
69 private: 68 private:
70 GpuWatchdogThread* watchdog_; 69 GpuWatchdogThread* watchdog_;
71 }; 70 };
72 71
72 GpuWatchdogThread();
73 ~GpuWatchdogThread() override; 73 ~GpuWatchdogThread() override;
74 74
75 void OnAcknowledge(); 75 void OnAcknowledge();
76 void OnCheck(bool after_suspend); 76 void OnCheck(bool after_suspend);
77 void DeliberatelyTerminateToRecoverFromHang(); 77 void DeliberatelyTerminateToRecoverFromHang();
78 #if defined(USE_X11) 78 #if defined(USE_X11)
79 void SetupXServer(); 79 void SetupXServer();
80 void SetupXChangeProp(); 80 void SetupXChangeProp();
81 bool MatchXEventAtom(XEvent* event); 81 bool MatchXEventAtom(XEvent* event);
82 #endif 82 #endif
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 XAtom atom_; 137 XAtom atom_;
138 FILE* tty_file_; 138 FILE* tty_file_;
139 int host_tty_; 139 int host_tty_;
140 #endif 140 #endif
141 141
142 base::WeakPtrFactory<GpuWatchdogThread> weak_factory_; 142 base::WeakPtrFactory<GpuWatchdogThread> weak_factory_;
143 143
144 DISALLOW_COPY_AND_ASSIGN(GpuWatchdogThread); 144 DISALLOW_COPY_AND_ASSIGN(GpuWatchdogThread);
145 }; 145 };
146 146
147 } // namespace content 147 } // namespace gpu
148 148
149 #endif // CONTENT_GPU_GPU_WATCHDOG_THREAD_H_ 149 #endif // GPU_IPC_SERVICE_GPU_WATCHDOG_THREAD_H_
OLDNEW
« no previous file with comments | « gpu/ipc/service/gpu_watchdog.h ('k') | gpu/ipc/service/gpu_watchdog_thread.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698