OLD | NEW |
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 #include "content/common/child_thread.h" | 5 #include "content/common/child_thread.h" |
6 | 6 |
7 #include "base/allocator/allocator_extension.h" | 7 #include "base/allocator/allocator_extension.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/process.h" | 10 #include "base/process.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 // large window where a browser failure (or a user, manually terminating | 52 // large window where a browser failure (or a user, manually terminating |
53 // the browser because "it's stuck") will leave behind a process eating all | 53 // the browser because "it's stuck") will leave behind a process eating all |
54 // the CPU. | 54 // the CPU. |
55 // | 55 // |
56 // So, we install a filter on the channel so that we can process this event | 56 // So, we install a filter on the channel so that we can process this event |
57 // here and kill the process. | 57 // here and kill the process. |
58 // | 58 // |
59 // We want to kill this process after giving it 30 seconds to run the exit | 59 // We want to kill this process after giving it 30 seconds to run the exit |
60 // handlers. SIGALRM has a default disposition of terminating the | 60 // handlers. SIGALRM has a default disposition of terminating the |
61 // application. | 61 // application. |
| 62 LOG(INFO) << "SuicideOnChannelErrorFilter::OnChannelError"; |
62 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kChildCleanExit)) | 63 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kChildCleanExit)) |
63 alarm(30); | 64 alarm(30); |
64 else | 65 else |
65 _exit(0); | 66 _exit(0); |
66 } | 67 } |
67 | 68 |
68 protected: | 69 protected: |
69 virtual ~SuicideOnChannelErrorFilter() {} | 70 virtual ~SuicideOnChannelErrorFilter() {} |
70 }; | 71 }; |
71 | 72 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 // NOTE: this also has the side-effect of not closing the main IPC channel to | 130 // NOTE: this also has the side-effect of not closing the main IPC channel to |
130 // the browser process. This is needed because this is the signal that the | 131 // the browser process. This is needed because this is the signal that the |
131 // browser uses to know that this process has died, so we need it to be alive | 132 // browser uses to know that this process has died, so we need it to be alive |
132 // until this process is shut down, and the OS closes the handle | 133 // until this process is shut down, and the OS closes the handle |
133 // automatically. We used to watch the object handle on Windows to do this, | 134 // automatically. We used to watch the object handle on Windows to do this, |
134 // but it wasn't possible to do so on POSIX. | 135 // but it wasn't possible to do so on POSIX. |
135 channel_->ClearIPCTaskRunner(); | 136 channel_->ClearIPCTaskRunner(); |
136 } | 137 } |
137 | 138 |
138 void ChildThread::OnChannelError() { | 139 void ChildThread::OnChannelError() { |
| 140 LOG(INFO) << "ChildThread::OnChannelError"; |
139 set_on_channel_error_called(true); | 141 set_on_channel_error_called(true); |
140 MessageLoop::current()->Quit(); | 142 MessageLoop::current()->Quit(); |
141 } | 143 } |
142 | 144 |
143 bool ChildThread::Send(IPC::Message* msg) { | 145 bool ChildThread::Send(IPC::Message* msg) { |
144 DCHECK(MessageLoop::current() == message_loop()); | 146 DCHECK(MessageLoop::current() == message_loop()); |
145 if (!channel_.get()) { | 147 if (!channel_.get()) { |
146 delete msg; | 148 delete msg; |
147 return false; | 149 return false; |
148 } | 150 } |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 } | 327 } |
326 | 328 |
327 // The child process shutdown sequence is a request response based mechanism, | 329 // The child process shutdown sequence is a request response based mechanism, |
328 // where we send out an initial feeler request to the child process host | 330 // where we send out an initial feeler request to the child process host |
329 // instance in the browser to verify if it's ok to shutdown the child process. | 331 // instance in the browser to verify if it's ok to shutdown the child process. |
330 // The browser then sends back a response if it's ok to shutdown. This avoids | 332 // The browser then sends back a response if it's ok to shutdown. This avoids |
331 // race conditions if the process refcount is 0 but there's an IPC message | 333 // race conditions if the process refcount is 0 but there's an IPC message |
332 // inflight that would addref it. | 334 // inflight that would addref it. |
333 Send(new ChildProcessHostMsg_ShutdownRequest); | 335 Send(new ChildProcessHostMsg_ShutdownRequest); |
334 } | 336 } |
OLD | NEW |