| OLD | NEW |
| 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 #include "chrome/common/process_watcher.h" | 5 #include "chrome/common/process_watcher.h" |
| 6 | 6 |
| 7 #include "base/scoped_ptr.h" | 7 #include "base/scoped_ptr.h" |
| 8 #include "base/environment.h" | 8 #include "base/environment.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/object_watcher.h" | 10 #include "base/object_watcher.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 // watching. the process handle, so make sure it has stopped. | 43 // watching. the process handle, so make sure it has stopped. |
| 44 watcher_.StopWatching(); | 44 watcher_.StopWatching(); |
| 45 | 45 |
| 46 CloseHandle(process_); | 46 CloseHandle(process_); |
| 47 process_ = NULL; | 47 process_ = NULL; |
| 48 } | 48 } |
| 49 | 49 |
| 50 private: | 50 private: |
| 51 void KillProcess() { | 51 void KillProcess() { |
| 52 scoped_ptr<base::Environment> env(base::Environment::Create()); | 52 scoped_ptr<base::Environment> env(base::Environment::Create()); |
| 53 if (env->HasEnv(env_vars::kHeadless)) { | 53 if (env->HasVar(env_vars::kHeadless)) { |
| 54 // If running the distributed tests, give the renderer a little time | 54 // If running the distributed tests, give the renderer a little time |
| 55 // to figure out that the channel is shutdown and unwind. | 55 // to figure out that the channel is shutdown and unwind. |
| 56 if (WaitForSingleObject(process_, kWaitInterval) == WAIT_OBJECT_0) { | 56 if (WaitForSingleObject(process_, kWaitInterval) == WAIT_OBJECT_0) { |
| 57 OnObjectSignaled(process_); | 57 OnObjectSignaled(process_); |
| 58 return; | 58 return; |
| 59 } | 59 } |
| 60 } | 60 } |
| 61 | 61 |
| 62 // OK, time to get frisky. We don't actually care when the process | 62 // OK, time to get frisky. We don't actually care when the process |
| 63 // terminates. We just care that it eventually terminates, and that's what | 63 // terminates. We just care that it eventually terminates, and that's what |
| (...skipping 22 matching lines...) Expand all Loading... |
| 86 // If already signaled, then we are done! | 86 // If already signaled, then we are done! |
| 87 if (WaitForSingleObject(process, 0) == WAIT_OBJECT_0) { | 87 if (WaitForSingleObject(process, 0) == WAIT_OBJECT_0) { |
| 88 CloseHandle(process); | 88 CloseHandle(process); |
| 89 return; | 89 return; |
| 90 } | 90 } |
| 91 | 91 |
| 92 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 92 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
| 93 new TimerExpiredTask(process), | 93 new TimerExpiredTask(process), |
| 94 kWaitInterval); | 94 kWaitInterval); |
| 95 } | 95 } |
| OLD | NEW |