| 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 WaitAndExitDelegate* leaking_delegate = delegate.release(); | 110 WaitAndExitDelegate* leaking_delegate = delegate.release(); |
| 111 ANNOTATE_LEAKING_OBJECT_PTR(leaking_delegate); | 111 ANNOTATE_LEAKING_OBJECT_PTR(leaking_delegate); |
| 112 ignore_result(leaking_delegate); | 112 ignore_result(leaking_delegate); |
| 113 return true; | 113 return true; |
| 114 } | 114 } |
| 115 #endif | 115 #endif |
| 116 | 116 |
| 117 class SuicideOnChannelErrorFilter : public IPC::MessageFilter { | 117 class SuicideOnChannelErrorFilter : public IPC::MessageFilter { |
| 118 public: | 118 public: |
| 119 // IPC::MessageFilter | 119 // IPC::MessageFilter |
| 120 virtual void OnChannelError() override { | 120 void OnChannelError() override { |
| 121 // For renderer/worker processes: | 121 // For renderer/worker processes: |
| 122 // On POSIX, at least, one can install an unload handler which loops | 122 // On POSIX, at least, one can install an unload handler which loops |
| 123 // forever and leave behind a renderer process which eats 100% CPU forever. | 123 // forever and leave behind a renderer process which eats 100% CPU forever. |
| 124 // | 124 // |
| 125 // This is because the terminate signals (ViewMsg_ShouldClose and the error | 125 // This is because the terminate signals (ViewMsg_ShouldClose and the error |
| 126 // from the IPC sender) are routed to the main message loop but never | 126 // from the IPC sender) are routed to the main message loop but never |
| 127 // processed (because that message loop is stuck in V8). | 127 // processed (because that message loop is stuck in V8). |
| 128 // | 128 // |
| 129 // One could make the browser SIGKILL the renderers, but that leaves open a | 129 // One could make the browser SIGKILL the renderers, but that leaves open a |
| 130 // large window where a browser failure (or a user, manually terminating | 130 // large window where a browser failure (or a user, manually terminating |
| (...skipping 13 matching lines...) Expand all Loading... |
| 144 // Invoke LeakSanitizer early to avoid detecting shutdown-only leaks. If | 144 // Invoke LeakSanitizer early to avoid detecting shutdown-only leaks. If |
| 145 // leaks are found, the process will exit here. | 145 // leaks are found, the process will exit here. |
| 146 __lsan_do_leak_check(); | 146 __lsan_do_leak_check(); |
| 147 #endif | 147 #endif |
| 148 #else | 148 #else |
| 149 _exit(0); | 149 _exit(0); |
| 150 #endif | 150 #endif |
| 151 } | 151 } |
| 152 | 152 |
| 153 protected: | 153 protected: |
| 154 virtual ~SuicideOnChannelErrorFilter() {} | 154 ~SuicideOnChannelErrorFilter() override {} |
| 155 }; | 155 }; |
| 156 | 156 |
| 157 #endif // OS(POSIX) | 157 #endif // OS(POSIX) |
| 158 | 158 |
| 159 #if defined(OS_ANDROID) | 159 #if defined(OS_ANDROID) |
| 160 ChildThread* g_child_thread = NULL; | 160 ChildThread* g_child_thread = NULL; |
| 161 | 161 |
| 162 // A lock protects g_child_thread. | 162 // A lock protects g_child_thread. |
| 163 base::LazyInstance<base::Lock> g_lazy_child_thread_lock = | 163 base::LazyInstance<base::Lock> g_lazy_child_thread_lock = |
| 164 LAZY_INSTANCE_INITIALIZER; | 164 LAZY_INSTANCE_INITIALIZER; |
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 | 595 |
| 596 void ChildThread::OnProcessBackgrounded(bool background) { | 596 void ChildThread::OnProcessBackgrounded(bool background) { |
| 597 // Set timer slack to maximum on main thread when in background. | 597 // Set timer slack to maximum on main thread when in background. |
| 598 base::TimerSlack timer_slack = base::TIMER_SLACK_NONE; | 598 base::TimerSlack timer_slack = base::TIMER_SLACK_NONE; |
| 599 if (background) | 599 if (background) |
| 600 timer_slack = base::TIMER_SLACK_MAXIMUM; | 600 timer_slack = base::TIMER_SLACK_MAXIMUM; |
| 601 base::MessageLoop::current()->SetTimerSlack(timer_slack); | 601 base::MessageLoop::current()->SetTimerSlack(timer_slack); |
| 602 } | 602 } |
| 603 | 603 |
| 604 } // namespace content | 604 } // namespace content |
| OLD | NEW |