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

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

Issue 5278006: GPU thread acknowledges an armed watchdog every time it returns to the messag... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 CHROME_GPU_GPU_WATCHDOG_THREAD_H_ 5 #ifndef CHROME_GPU_GPU_WATCHDOG_THREAD_H_
6 #define CHROME_GPU_GPU_WATCHDOG_THREAD_H_ 6 #define CHROME_GPU_GPU_WATCHDOG_THREAD_H_
7 7
8 #include "base/message_loop.h"
8 #include "base/ref_counted.h" 9 #include "base/ref_counted.h"
9 #include "base/scoped_ptr.h" 10 #include "base/scoped_ptr.h"
10 #include "base/task.h" 11 #include "base/task.h"
11 #include "base/thread.h" 12 #include "base/thread.h"
12 13
13 // A thread that intermitently sends tasks to a group of watched message loops 14 // A thread that intermitently sends tasks to a group of watched message loops
14 // and deliberately crashes if one of them does not respond after a timeout. 15 // and deliberately crashes if one of them does not respond after a timeout.
15 class GpuWatchdogThread : public base::Thread, 16 class GpuWatchdogThread : public base::Thread,
16 public base::RefCountedThreadSafe<GpuWatchdogThread> { 17 public base::RefCountedThreadSafe<GpuWatchdogThread> {
17 public: 18 public:
18 GpuWatchdogThread(MessageLoop* watched_message_loop, int timeout); 19 GpuWatchdogThread(MessageLoop* watched_message_loop, int timeout);
19 virtual ~GpuWatchdogThread(); 20 virtual ~GpuWatchdogThread();
20 21
22 // Accessible on watched thread but only modified by watchdog thread.
23 bool armed() const { return armed_; }
24 void PostAcknowledge();
25
21 protected: 26 protected:
22 virtual void Init(); 27 virtual void Init();
23 virtual void CleanUp(); 28 virtual void CleanUp();
24 29
25 private: 30 private:
31
32 // An object of this type intercepts the reception and completion of all tasks
33 // on the watched thread and checks whether the watchdog is armed.
34 class GpuWatchdogTaskObserver : public MessageLoop::TaskObserver {
35 public:
36 explicit GpuWatchdogTaskObserver(GpuWatchdogThread* watchdog);
37 virtual ~GpuWatchdogTaskObserver();
38
39 // Implements MessageLoop::TaskObserver.
40 virtual void WillProcessTask(const Task* task);
41 virtual void DidProcessTask(const Task* task);
42
43 private:
44 void CheckArmed();
45 GpuWatchdogThread* watchdog_;
46 };
47
26 void OnAcknowledge(); 48 void OnAcknowledge();
27 void OnCheck(); 49 void OnCheck();
28 void PostAcknowledge();
29 void OnExit(); 50 void OnExit();
30 void Disable(); 51 void Disable();
31 52
32 MessageLoop* watched_message_loop_; 53 MessageLoop* watched_message_loop_;
33 int timeout_; 54 int timeout_;
55 bool armed_;
Ken Russell (switch to Gerrit) 2010/11/23 23:03:12 This should probably be volatile.
56 GpuWatchdogTaskObserver task_observer_;
34 57
35 typedef ScopedRunnableMethodFactory<GpuWatchdogThread> MethodFactory; 58 typedef ScopedRunnableMethodFactory<GpuWatchdogThread> MethodFactory;
36 scoped_ptr<MethodFactory> method_factory_; 59 scoped_ptr<MethodFactory> method_factory_;
37 60
38 DISALLOW_COPY_AND_ASSIGN(GpuWatchdogThread); 61 DISALLOW_COPY_AND_ASSIGN(GpuWatchdogThread);
39 }; 62 };
40 63
41 #endif // CHROME_GPU_GPU_WATCHDOG_THREAD_H_ 64 #endif // CHROME_GPU_GPU_WATCHDOG_THREAD_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/gpu/gpu_watchdog_thread.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698