OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "content/common/process_watcher.h" | 5 #include "content/common/process_watcher.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/win/object_watcher.h" | 9 #include "base/win/object_watcher.h" |
10 #include "content/common/result_codes.h" | 10 #include "content/common/result_codes.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 CloseHandle(process_); | 45 CloseHandle(process_); |
46 process_ = NULL; | 46 process_ = NULL; |
47 } | 47 } |
48 | 48 |
49 private: | 49 private: |
50 void KillProcess() { | 50 void KillProcess() { |
51 // OK, time to get frisky. We don't actually care when the process | 51 // OK, time to get frisky. We don't actually care when the process |
52 // terminates. We just care that it eventually terminates, and that's what | 52 // terminates. We just care that it eventually terminates, and that's what |
53 // TerminateProcess should do for us. Don't check for the result code since | 53 // TerminateProcess should do for us. Don't check for the result code since |
54 // it fails quite often. This should be investigated eventually. | 54 // it fails quite often. This should be investigated eventually. |
55 base::KillProcess(process_, ResultCodes::HUNG, false); | 55 base::KillProcess(process_, content::RESULT_CODE_HUNG, false); |
56 | 56 |
57 // Now, just cleanup as if the process exited normally. | 57 // Now, just cleanup as if the process exited normally. |
58 OnObjectSignaled(process_); | 58 OnObjectSignaled(process_); |
59 } | 59 } |
60 | 60 |
61 // The process that we are watching. | 61 // The process that we are watching. |
62 base::ProcessHandle process_; | 62 base::ProcessHandle process_; |
63 | 63 |
64 base::win::ObjectWatcher watcher_; | 64 base::win::ObjectWatcher watcher_; |
65 | 65 |
66 DISALLOW_COPY_AND_ASSIGN(TimerExpiredTask); | 66 DISALLOW_COPY_AND_ASSIGN(TimerExpiredTask); |
67 }; | 67 }; |
68 | 68 |
69 } // namespace | 69 } // namespace |
70 | 70 |
71 // static | 71 // static |
72 void ProcessWatcher::EnsureProcessTerminated(base::ProcessHandle process) { | 72 void ProcessWatcher::EnsureProcessTerminated(base::ProcessHandle process) { |
73 DCHECK(process != GetCurrentProcess()); | 73 DCHECK(process != GetCurrentProcess()); |
74 | 74 |
75 // If already signaled, then we are done! | 75 // If already signaled, then we are done! |
76 if (WaitForSingleObject(process, 0) == WAIT_OBJECT_0) { | 76 if (WaitForSingleObject(process, 0) == WAIT_OBJECT_0) { |
77 CloseHandle(process); | 77 CloseHandle(process); |
78 return; | 78 return; |
79 } | 79 } |
80 | 80 |
81 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 81 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
82 new TimerExpiredTask(process), | 82 new TimerExpiredTask(process), |
83 kWaitInterval); | 83 kWaitInterval); |
84 } | 84 } |
OLD | NEW |