| 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/child/child_thread.h" | 5 #include "content/child/child_thread.h" |
| 6 | 6 |
| 7 #include <signal.h> | 7 #include <signal.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 | 113 |
| 114 class SuicideOnChannelErrorFilter : public IPC::MessageFilter { | 114 class SuicideOnChannelErrorFilter : public IPC::MessageFilter { |
| 115 public: | 115 public: |
| 116 // IPC::MessageFilter | 116 // IPC::MessageFilter |
| 117 virtual void OnChannelError() OVERRIDE { | 117 virtual void OnChannelError() OVERRIDE { |
| 118 // For renderer/worker processes: | 118 // For renderer/worker processes: |
| 119 // On POSIX, at least, one can install an unload handler which loops | 119 // On POSIX, at least, one can install an unload handler which loops |
| 120 // forever and leave behind a renderer process which eats 100% CPU forever. | 120 // forever and leave behind a renderer process which eats 100% CPU forever. |
| 121 // | 121 // |
| 122 // This is because the terminate signals (ViewMsg_ShouldClose and the error | 122 // This is because the terminate signals (ViewMsg_ShouldClose and the error |
| 123 // from the IPC channel) are routed to the main message loop but never | 123 // from the IPC sender) are routed to the main message loop but never |
| 124 // processed (because that message loop is stuck in V8). | 124 // processed (because that message loop is stuck in V8). |
| 125 // | 125 // |
| 126 // One could make the browser SIGKILL the renderers, but that leaves open a | 126 // One could make the browser SIGKILL the renderers, but that leaves open a |
| 127 // large window where a browser failure (or a user, manually terminating | 127 // large window where a browser failure (or a user, manually terminating |
| 128 // the browser because "it's stuck") will leave behind a process eating all | 128 // the browser because "it's stuck") will leave behind a process eating all |
| 129 // the CPU. | 129 // the CPU. |
| 130 // | 130 // |
| 131 // So, we install a filter on the channel so that we can process this event | 131 // So, we install a filter on the sender so that we can process this event |
| 132 // here and kill the process. | 132 // here and kill the process. |
| 133 // TODO(earthdok): Re-enable on CrOS http://crbug.com/360622 | 133 // TODO(earthdok): Re-enable on CrOS http://crbug.com/360622 |
| 134 #if (defined(ADDRESS_SANITIZER) || defined(LEAK_SANITIZER) || \ | 134 #if (defined(ADDRESS_SANITIZER) || defined(LEAK_SANITIZER) || \ |
| 135 defined(THREAD_SANITIZER)) && !defined(OS_CHROMEOS) | 135 defined(THREAD_SANITIZER)) && !defined(OS_CHROMEOS) |
| 136 // Some sanitizer tools rely on exit handlers (e.g. to run leak detection, | 136 // Some sanitizer tools rely on exit handlers (e.g. to run leak detection, |
| 137 // or dump code coverage data to disk). Instead of exiting the process | 137 // or dump code coverage data to disk). Instead of exiting the process |
| 138 // immediately, we give it 60 seconds to run exit handlers. | 138 // immediately, we give it 60 seconds to run exit handlers. |
| 139 CHECK(CreateWaitAndExitThread(base::TimeDelta::FromSeconds(60))); | 139 CHECK(CreateWaitAndExitThread(base::TimeDelta::FromSeconds(60))); |
| 140 #if defined(LEAK_SANITIZER) | 140 #if defined(LEAK_SANITIZER) |
| 141 // Invoke LeakSanitizer early to avoid detecting shutdown-only leaks. If | 141 // Invoke LeakSanitizer early to avoid detecting shutdown-only leaks. If |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 base::MessageLoop::current()->SetTimerSlack(timer_slack); | 561 base::MessageLoop::current()->SetTimerSlack(timer_slack); |
| 562 | 562 |
| 563 #ifdef OS_WIN | 563 #ifdef OS_WIN |
| 564 // Windows Vista+ has a fancy process backgrounding mode that can only be set | 564 // Windows Vista+ has a fancy process backgrounding mode that can only be set |
| 565 // from within the process. | 565 // from within the process. |
| 566 base::Process::Current().SetProcessBackgrounded(background); | 566 base::Process::Current().SetProcessBackgrounded(background); |
| 567 #endif // OS_WIN | 567 #endif // OS_WIN |
| 568 } | 568 } |
| 569 | 569 |
| 570 } // namespace content | 570 } // namespace content |
| OLD | NEW |